-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathefficiencyreport
executable file
·76 lines (61 loc) · 2.38 KB
/
efficiencyreport
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
# Copyright (c) 2016 Erik Johansson <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
from pvoutput import PvOutput
import argparse
import configparser
import datetime
import logging
def main():
logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s")
parser = argparse.ArgumentParser(
description="Get efficiency report from PVoutput.org"
)
parser.add_argument("config", help="Configuration file to use")
parser.add_argument(
"-d", "--debug", help="Enable debug output", action="store_true"
)
args = parser.parse_args()
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)
config = configparser.ConfigParser()
config["pvoutput"] = {}
config.read(args.config)
modified = False
if not config["pvoutput"].get("apikey"):
config["pvoutput"]["apikey"] = input("PVOutput API key: ")
modified = True
if not config["pvoutput"].get("systemid"):
config["pvoutput"]["systemid"] = input("PVOutput System Id: ")
modified = True
if modified:
with open(args.config, "w") as configfile:
config.write(configfile)
pvoutput = PvOutput(config["pvoutput"]["apikey"], config["pvoutput"]["systemid"])
output = pvoutput.get_output(limit=10)
extended = pvoutput.get_extended(limit=10)
print(" Total String A String B Diff (A-B)")
for o, e in zip(output, extended):
assert o.date == e.date
a = e.extended_5 / (17 * 330)
b = e.extended_6 / (10 * 330)
print(
"%s %.3f %.3f %.3f %.3f"
% (o.date.strftime("%Y-%m-%d"), o.efficiency, a, b, a - b)
)
if __name__ == "__main__":
main()