chellow 1754570085.0.0__py3-none-any.whl → 1754580326.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chellow might be problematic. Click here for more details.
- chellow/e/energy_management.py +231 -247
- chellow/e/views.py +1 -8
- chellow/templates/e/em_totals.html +19 -0
- {chellow-1754570085.0.0.dist-info → chellow-1754580326.0.0.dist-info}/METADATA +1 -1
- {chellow-1754570085.0.0.dist-info → chellow-1754580326.0.0.dist-info}/RECORD +6 -6
- {chellow-1754570085.0.0.dist-info → chellow-1754580326.0.0.dist-info}/WHEEL +0 -0
chellow/e/energy_management.py
CHANGED
|
@@ -13,278 +13,262 @@ from chellow.e.computer import (
|
|
|
13
13
|
forecast_date,
|
|
14
14
|
)
|
|
15
15
|
from chellow.models import Era, Session, Site, SiteEra, Source, Supply
|
|
16
|
-
from chellow.utils import c_months_u, ct_datetime_now, hh_max, hh_min
|
|
16
|
+
from chellow.utils import c_months_u, ct_datetime_now, hh_format, hh_max, hh_min
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
sess = None
|
|
31
|
-
titles = ["Quantity"]
|
|
32
|
-
titles.extend(CATS)
|
|
33
|
-
log_list = []
|
|
34
|
-
problem = ""
|
|
19
|
+
CATS = ("imp_grid", "exp_grid", "used", "displaced")
|
|
20
|
+
QUANTS = (
|
|
21
|
+
"kwh",
|
|
22
|
+
"net_gbp",
|
|
23
|
+
# "p_per_kwh",
|
|
24
|
+
"triad_gbp",
|
|
25
|
+
"duos_gbp",
|
|
26
|
+
"red_duos_gbp",
|
|
27
|
+
"md_kw",
|
|
28
|
+
)
|
|
35
29
|
|
|
36
|
-
jval = {"titles": titles, "rows": [], "status": "running", "log": log_list}
|
|
37
|
-
try:
|
|
38
|
-
with Session() as sess:
|
|
39
|
-
site = Site.get_by_id(sess, site_id)
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
def _process(sess, log, start_year, start_month, mem_id, jval, site):
|
|
32
|
+
log("started thread")
|
|
33
|
+
f_date = forecast_date()
|
|
34
|
+
report_context = {}
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
for month_num, (month_start, month_finish) in enumerate(
|
|
37
|
+
c_months_u(start_year=start_year, start_month=start_month, months=12)
|
|
38
|
+
):
|
|
39
|
+
jval["progress"] = month_num
|
|
40
|
+
put_mem_val(mem_id, jval)
|
|
41
|
+
vals = {cat: defaultdict(int) for cat in CATS}
|
|
42
|
+
vals["problem"] = ""
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
for era in sess.execute(
|
|
45
|
+
select(Era)
|
|
46
|
+
.join(SiteEra)
|
|
47
|
+
.join(Supply)
|
|
48
|
+
.join(Source)
|
|
49
|
+
.where(
|
|
50
|
+
SiteEra.site == site,
|
|
51
|
+
Era.start_date <= month_finish,
|
|
52
|
+
or_(Era.finish_date == null(), Era.finish_date >= month_start),
|
|
53
|
+
Era.imp_mpan_core != null(),
|
|
54
|
+
Source.code.in_(("grid", "gen-grid")),
|
|
55
|
+
)
|
|
56
|
+
.options(
|
|
57
|
+
joinedload(Era.imp_supplier_contract),
|
|
58
|
+
joinedload(Era.exp_supplier_contract),
|
|
59
|
+
joinedload(Era.mop_contract),
|
|
60
|
+
joinedload(Era.dc_contract),
|
|
61
|
+
)
|
|
62
|
+
).scalars():
|
|
63
|
+
chunk_start = hh_max(era.start_date, month_start)
|
|
64
|
+
chunk_finish = hh_min(era.finish_date, month_finish)
|
|
65
|
+
|
|
66
|
+
log("about to call first supplysource")
|
|
67
|
+
supply_ds = SupplySource(
|
|
68
|
+
sess, chunk_start, chunk_finish, f_date, era, True, report_context
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
supplier_contract = era.imp_supplier_contract
|
|
72
|
+
import_vb_function = contract_func(
|
|
73
|
+
report_context, supplier_contract, "virtual_bill"
|
|
74
|
+
)
|
|
75
|
+
if import_vb_function is None:
|
|
76
|
+
raise Exception(
|
|
77
|
+
"Can't find the import_virtual_bill function in the "
|
|
78
|
+
"supplier contract. "
|
|
79
|
+
)
|
|
55
80
|
else:
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
import_vb_function(supply_ds)
|
|
82
|
+
v_bill = supply_ds.supplier_bill
|
|
58
83
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
):
|
|
62
|
-
jval["progress"] = progress
|
|
63
|
-
put_mem_val(mem_id, jval)
|
|
84
|
+
if "problem" in v_bill and len(v_bill["problem"]) > 0:
|
|
85
|
+
raise Exception("Supplier Problem: " + v_bill["problem"])
|
|
64
86
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Source.code.in_(("net", "gen-net")),
|
|
76
|
-
)
|
|
77
|
-
.options(
|
|
78
|
-
joinedload(Era.imp_supplier_contract),
|
|
79
|
-
joinedload(Era.exp_supplier_contract),
|
|
80
|
-
joinedload(Era.mop_contract),
|
|
81
|
-
joinedload(Era.dc_contract),
|
|
87
|
+
try:
|
|
88
|
+
vals["imp_grid"]["net_gbp"] += v_bill["net-gbp"]
|
|
89
|
+
if "triad-gbp" in v_bill:
|
|
90
|
+
vals["imp_grid"]["triad_gbp"] += v_bill["triad-gbp"]
|
|
91
|
+
if "duos-red-gbp" in v_bill:
|
|
92
|
+
vals["imp_grid"]["red_duos_gbp"] += v_bill["duos-red-gbp"]
|
|
93
|
+
vals["imp_grid"]["duos_gbp"] += sum(
|
|
94
|
+
v
|
|
95
|
+
for k, v in v_bill.items()
|
|
96
|
+
if k.endswith("-gbp") and k.startswith("duos-")
|
|
82
97
|
)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
supply_ds = SupplySource(
|
|
89
|
-
sess,
|
|
90
|
-
chunk_start,
|
|
91
|
-
chunk_finish,
|
|
92
|
-
f_date,
|
|
93
|
-
era,
|
|
94
|
-
True,
|
|
95
|
-
report_context,
|
|
98
|
+
except KeyError:
|
|
99
|
+
raise Exception(
|
|
100
|
+
f"For the era {era.id} the virtual bill {v_bill} "
|
|
101
|
+
f"from the contract {supplier_contract} does not "
|
|
102
|
+
f"contain the net-gbp key."
|
|
96
103
|
)
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
vals["imp_net"]["triad_gbp"] += v_bill["triad-gbp"]
|
|
118
|
-
if "duos-red-gbp" in v_bill:
|
|
119
|
-
vals["imp_net"]["red_duos_gbp"] += v_bill[
|
|
120
|
-
"duos-red-gbp"
|
|
121
|
-
]
|
|
122
|
-
vals["imp_net"]["duos_gbp"] += sum(
|
|
123
|
-
v
|
|
124
|
-
for k, v in v_bill.items()
|
|
125
|
-
if k.endswith("-gbp") and k.startswith("duos-")
|
|
126
|
-
)
|
|
127
|
-
except KeyError:
|
|
128
|
-
raise Exception(
|
|
129
|
-
f"For the era {era.id} the virtual bill {v_bill} "
|
|
130
|
-
f"from the contract {supplier_contract} does not "
|
|
131
|
-
f"contain the net-gbp key."
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
dc_contract = era.dc_contract
|
|
135
|
-
supply_ds.contract_func(dc_contract, "virtual_bill")(supply_ds)
|
|
136
|
-
dc_bill = supply_ds.dc_bill
|
|
137
|
-
vals["imp_net"]["gbp"] += dc_bill["net-gbp"]
|
|
138
|
-
if "problem" in dc_bill and len(dc_bill["problem"]) > 0:
|
|
139
|
-
problem += "DC Problem: " + dc_bill["problem"]
|
|
140
|
-
|
|
141
|
-
mop_contract = era.mop_contract
|
|
142
|
-
mop_bill_function = supply_ds.contract_func(
|
|
143
|
-
mop_contract, "virtual_bill"
|
|
144
|
-
)
|
|
145
|
-
mop_bill_function(supply_ds)
|
|
146
|
-
mop_bill = supply_ds.mop_bill
|
|
147
|
-
vals["imp_net"]["gbp"] += mop_bill["net-gbp"]
|
|
148
|
-
if "problem" in mop_bill and len(mop_bill["problem"]) > 0:
|
|
149
|
-
problem += "MOP Problem: " + mop_bill["problem"]
|
|
150
|
-
|
|
151
|
-
exp_supplier_contract = era.exp_supplier_contract
|
|
152
|
-
if exp_supplier_contract is not None:
|
|
153
|
-
log("about to call second supply source")
|
|
154
|
-
exp_supply_ds = SupplySource(
|
|
155
|
-
sess,
|
|
156
|
-
chunk_start,
|
|
157
|
-
chunk_finish,
|
|
158
|
-
f_date,
|
|
159
|
-
era,
|
|
160
|
-
False,
|
|
161
|
-
report_context,
|
|
162
|
-
)
|
|
163
|
-
exp_vb_function = contract_func(
|
|
164
|
-
report_context, exp_supplier_contract, "virtual_bill"
|
|
165
|
-
)
|
|
166
|
-
if exp_vb_function is None:
|
|
167
|
-
problem += (
|
|
168
|
-
"Can't find the export_virtual_bill function in the "
|
|
169
|
-
"supplier contract. "
|
|
170
|
-
)
|
|
171
|
-
else:
|
|
172
|
-
exp_vb_function(exp_supply_ds)
|
|
173
|
-
v_bill = exp_supply_ds.supplier_bill
|
|
174
|
-
|
|
175
|
-
if "problem" in v_bill and len(v_bill["problem"]) > 0:
|
|
176
|
-
problem += (
|
|
177
|
-
f"Export supplier Problem: {v_bill['problem']}"
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
try:
|
|
181
|
-
vals["exp_net"]["gbp"] += v_bill["net-gbp"]
|
|
182
|
-
if "triad-gbp" in v_bill:
|
|
183
|
-
vals["exp_net"]["triad_gbp"] += v_bill["triad-gbp"]
|
|
184
|
-
if "duos-red-gbp" in v_bill:
|
|
185
|
-
vals["exp_net"]["red_duos_gbp"] += v_bill[
|
|
186
|
-
"duos-red-gbp"
|
|
187
|
-
]
|
|
188
|
-
vals["exp_net"]["duos_gbp"] += sum(
|
|
189
|
-
v
|
|
190
|
-
for k, v in v_bill.items()
|
|
191
|
-
if k.endswith("-gbp") and k.startswith("duos-")
|
|
192
|
-
)
|
|
193
|
-
except KeyError:
|
|
194
|
-
problem += (
|
|
195
|
-
f"For the era {era.id} the virtual bill "
|
|
196
|
-
f"{v_bill} from the contract "
|
|
197
|
-
f"{supplier_contract} does not contain the "
|
|
198
|
-
f"net-gbp key."
|
|
199
|
-
)
|
|
200
|
-
problem += v_bill["problem"]
|
|
201
|
-
|
|
202
|
-
disp_era = displaced_era(
|
|
203
|
-
sess, report_context, site, month_start, month_finish, f_date
|
|
204
|
-
)
|
|
205
|
-
log("about to call sitesource")
|
|
206
|
-
site_ds = SiteSource(
|
|
105
|
+
dc_contract = era.dc_contract
|
|
106
|
+
supply_ds.contract_func(dc_contract, "virtual_bill")(supply_ds)
|
|
107
|
+
dc_bill = supply_ds.dc_bill
|
|
108
|
+
vals["imp_grid"]["gbp"] += dc_bill["net-gbp"]
|
|
109
|
+
if "problem" in dc_bill and len(dc_bill["problem"]) > 0:
|
|
110
|
+
raise Exception(f'DC Problem: {dc_bill["problem"]}')
|
|
111
|
+
|
|
112
|
+
mop_contract = era.mop_contract
|
|
113
|
+
mop_bill_function = supply_ds.contract_func(mop_contract, "virtual_bill")
|
|
114
|
+
mop_bill_function(supply_ds)
|
|
115
|
+
mop_bill = supply_ds.mop_bill
|
|
116
|
+
vals["imp_grid"]["gbp"] += mop_bill["net-gbp"]
|
|
117
|
+
if "problem" in mop_bill and len(mop_bill["problem"]) > 0:
|
|
118
|
+
raise Exception(f'MOP Problem: {mop_bill["problem"]}')
|
|
119
|
+
|
|
120
|
+
exp_supplier_contract = era.exp_supplier_contract
|
|
121
|
+
if exp_supplier_contract is not None:
|
|
122
|
+
log("about to call second supply source")
|
|
123
|
+
exp_supply_ds = SupplySource(
|
|
207
124
|
sess,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
month_finish,
|
|
125
|
+
chunk_start,
|
|
126
|
+
chunk_finish,
|
|
211
127
|
f_date,
|
|
128
|
+
era,
|
|
129
|
+
False,
|
|
212
130
|
report_context,
|
|
213
|
-
disp_era,
|
|
214
|
-
exclude_virtual=False,
|
|
215
131
|
)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
132
|
+
exp_vb_function = contract_func(
|
|
133
|
+
report_context, exp_supplier_contract, "virtual_bill"
|
|
134
|
+
)
|
|
135
|
+
if exp_vb_function is None:
|
|
136
|
+
raise Exception(
|
|
137
|
+
"Can't find the export_virtual_bill function in the "
|
|
138
|
+
"supplier contract. "
|
|
221
139
|
)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
disp_supplier_bill = site_ds.supplier_bill
|
|
140
|
+
else:
|
|
141
|
+
exp_vb_function(exp_supply_ds)
|
|
142
|
+
v_bill = exp_supply_ds.supplier_bill
|
|
143
|
+
|
|
144
|
+
if "problem" in v_bill and len(v_bill["problem"]) > 0:
|
|
145
|
+
raise Exception(f"Export supplier Problem: {v_bill['problem']}")
|
|
229
146
|
|
|
230
147
|
try:
|
|
231
|
-
vals["
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
148
|
+
vals["exp_grid"]["net_gbp"] += v_bill["net-gbp"]
|
|
149
|
+
if "triad-gbp" in v_bill:
|
|
150
|
+
vals["exp_grid"]["triad_gbp"] += v_bill["triad-gbp"]
|
|
151
|
+
if "duos-red-gbp" in v_bill:
|
|
152
|
+
vals["exp_grid"]["red_duos_gbp"] += v_bill["duos-red-gbp"]
|
|
153
|
+
vals["exp_grid"]["duos_gbp"] += sum(
|
|
154
|
+
v
|
|
155
|
+
for k, v in v_bill.items()
|
|
156
|
+
if k.endswith("-gbp") and k.startswith("duos-")
|
|
157
|
+
)
|
|
158
|
+
except KeyError as e:
|
|
159
|
+
raise Exception(
|
|
160
|
+
f"For the era {era.id} the virtual bill {v_bill} from the "
|
|
161
|
+
f"contract {supplier_contract} does not contain the key {e}"
|
|
238
162
|
)
|
|
239
|
-
log(str(disp_supplier_bill))
|
|
240
|
-
if "triad-gbp" in disp_supplier_bill:
|
|
241
|
-
vals["displaced"]["triad_gbp"] += disp_supplier_bill[
|
|
242
|
-
"triad-gbp"
|
|
243
|
-
]
|
|
244
|
-
if "duos-red-gbp" in disp_supplier_bill:
|
|
245
|
-
vals["displaced"]["red_duos_gbp"] += disp_supplier_bill[
|
|
246
|
-
"duos-red-gbp"
|
|
247
|
-
]
|
|
248
|
-
vals["displaced"]["duos_gbp"] += sum(
|
|
249
|
-
v
|
|
250
|
-
for k, v in disp_supplier_bill.items()
|
|
251
|
-
if k.endswith("-gbp") and k.startswith("duos-")
|
|
252
|
-
)
|
|
253
163
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
164
|
+
disp_era = displaced_era(
|
|
165
|
+
sess, report_context, site, month_start, month_finish, f_date
|
|
166
|
+
)
|
|
167
|
+
log("about to call sitesource")
|
|
168
|
+
site_ds = SiteSource(
|
|
169
|
+
sess,
|
|
170
|
+
site,
|
|
171
|
+
month_start,
|
|
172
|
+
month_finish,
|
|
173
|
+
f_date,
|
|
174
|
+
report_context,
|
|
175
|
+
disp_era,
|
|
176
|
+
exclude_virtual=False,
|
|
177
|
+
)
|
|
261
178
|
|
|
262
|
-
|
|
263
|
-
|
|
179
|
+
if disp_era is not None:
|
|
180
|
+
disp_supplier_contract = disp_era.imp_supplier_contract
|
|
181
|
+
disp_vb_function = contract_func(
|
|
182
|
+
report_context, disp_supplier_contract, "displaced_virtual_bill"
|
|
183
|
+
)
|
|
184
|
+
if disp_vb_function is None:
|
|
185
|
+
raise Exception(
|
|
186
|
+
f"The supplier contract {disp_supplier_contract} "
|
|
187
|
+
"doesn't have the displaced_virtual_bill() function."
|
|
188
|
+
)
|
|
189
|
+
disp_vb_function(site_ds)
|
|
190
|
+
disp_supplier_bill = site_ds.supplier_bill
|
|
191
|
+
|
|
192
|
+
try:
|
|
193
|
+
vals["displaced"]["net_gbp"] += disp_supplier_bill["net-gbp"]
|
|
194
|
+
except KeyError:
|
|
195
|
+
disp_supplier_bill["problem"] += (
|
|
196
|
+
f"For the supply {site_ds.mpan_core} the virtual bill "
|
|
197
|
+
f"{disp_supplier_bill} from the contract {disp_supplier_contract} "
|
|
198
|
+
f"does not contain the net-gbp key."
|
|
199
|
+
)
|
|
200
|
+
log(str(disp_supplier_bill))
|
|
201
|
+
if "triad-gbp" in disp_supplier_bill:
|
|
202
|
+
vals["displaced"]["triad_gbp"] += disp_supplier_bill["triad-gbp"]
|
|
203
|
+
if "duos-red-gbp" in disp_supplier_bill:
|
|
204
|
+
vals["displaced"]["red_duos_gbp"] += disp_supplier_bill["duos-red-gbp"]
|
|
205
|
+
vals["displaced"]["duos_gbp"] += sum(
|
|
206
|
+
v
|
|
207
|
+
for k, v in disp_supplier_bill.items()
|
|
208
|
+
if k.endswith("-gbp") and k.startswith("duos-")
|
|
209
|
+
)
|
|
264
210
|
|
|
211
|
+
for hh in site.hh_data(sess, month_start, month_finish, exclude_virtual=True):
|
|
265
212
|
for cat in CATS:
|
|
266
213
|
vals_cat = vals[cat]
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
"
|
|
278
|
-
|
|
279
|
-
"
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
214
|
+
vals_cat["md_kw"] = max(vals_cat["md_kw"], hh[cat] * 2)
|
|
215
|
+
vals_cat["kwh"] += float(hh[cat])
|
|
216
|
+
|
|
217
|
+
for quant in ("net_gbp", "triad_gbp", "duos_gbp", "red_duos_gbp"):
|
|
218
|
+
vals["used"][quant] += vals["imp_grid"][quant] + vals["displaced"][quant]
|
|
219
|
+
|
|
220
|
+
"""
|
|
221
|
+
for cat in CATS:
|
|
222
|
+
vals_cat = vals[cat]
|
|
223
|
+
if vals_cat["kwh"] > 0:
|
|
224
|
+
vals_cat["p_per_kwh"] = vals_cat["gbp"] / vals_cat["kwh"] * 100
|
|
225
|
+
else:
|
|
226
|
+
vals_cat["p_per_kwh"] = 0
|
|
227
|
+
"""
|
|
228
|
+
|
|
229
|
+
FORMAT_LOOKUP = {
|
|
230
|
+
"kwh": "{:,.0f}",
|
|
231
|
+
"net_gbp": "{:,.2f}",
|
|
232
|
+
"p_per_kwh": "{:,.2f}",
|
|
233
|
+
"triad_gbp": "{:,.2f}",
|
|
234
|
+
"duos_gbp": "{:,.2f}",
|
|
235
|
+
"red_duos_gbp": "{:,.2f}",
|
|
236
|
+
"md_kw": "{:,.2f}",
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for quant in QUANTS:
|
|
240
|
+
row = [hh_format(month_start)[:7], quant]
|
|
241
|
+
fmt = FORMAT_LOOKUP[quant]
|
|
242
|
+
for cat in CATS:
|
|
243
|
+
row.append(fmt.format(vals[cat][quant]))
|
|
244
|
+
jval["rows"].append(row)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def totals_runner(mem_id, site_id, start_date):
|
|
248
|
+
sess = None
|
|
249
|
+
titles = ["month", "quantity"]
|
|
250
|
+
titles.extend(CATS)
|
|
251
|
+
log_list = []
|
|
252
|
+
|
|
253
|
+
jval = {"titles": titles, "rows": [], "status": "running", "log": log_list}
|
|
254
|
+
try:
|
|
255
|
+
with Session() as sess:
|
|
256
|
+
site = Site.get_by_id(sess, site_id)
|
|
257
|
+
|
|
258
|
+
def log(msg):
|
|
259
|
+
return
|
|
260
|
+
log_list.append(msg)
|
|
261
|
+
put_mem_val(mem_id, jval)
|
|
262
|
+
|
|
263
|
+
if start_date is None:
|
|
264
|
+
now = ct_datetime_now()
|
|
265
|
+
start_year = now.year - 1
|
|
266
|
+
start_month = now.month
|
|
267
|
+
else:
|
|
268
|
+
start_year = start_date.year
|
|
269
|
+
start_month = start_date.month
|
|
270
|
+
|
|
271
|
+
_process(sess, log, start_year, start_month, mem_id, jval, site)
|
|
288
272
|
|
|
289
273
|
except BaseException:
|
|
290
274
|
msg = traceback.format_exc()
|
chellow/e/views.py
CHANGED
|
@@ -6,7 +6,6 @@ from datetime import datetime as Datetime
|
|
|
6
6
|
from decimal import Decimal
|
|
7
7
|
from io import BytesIO, StringIO
|
|
8
8
|
from itertools import chain, islice
|
|
9
|
-
from random import random
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
from dateutil.relativedelta import relativedelta
|
|
@@ -4156,16 +4155,10 @@ def em_totals(site_id):
|
|
|
4156
4155
|
if "mem_id" in request.values:
|
|
4157
4156
|
mem_id = req_int("mem_id")
|
|
4158
4157
|
site_info = chellow.dloads.get_mem_val(mem_id)
|
|
4159
|
-
random_number = random()
|
|
4160
4158
|
|
|
4161
4159
|
status_code = 200 if site_info["status"] == "running" else 286
|
|
4162
4160
|
return make_response(
|
|
4163
|
-
render_template(
|
|
4164
|
-
"em_totals.html",
|
|
4165
|
-
site=site,
|
|
4166
|
-
site_info=site_info,
|
|
4167
|
-
random_number=random_number,
|
|
4168
|
-
),
|
|
4161
|
+
render_template("em_totals.html", site=site, site_info=site_info),
|
|
4169
4162
|
status_code,
|
|
4170
4163
|
)
|
|
4171
4164
|
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
<div
|
|
3
3
|
hx-get="/e/sites/{{site.id}}/energy_management/totals?mem_id={{mem_id}}"
|
|
4
4
|
hx-trigger="every 3s">
|
|
5
|
+
<label>
|
|
6
|
+
Calculating:
|
|
7
|
+
<progress value="0" max="12">
|
|
8
|
+
0 months
|
|
9
|
+
</progress>
|
|
10
|
+
</label>
|
|
5
11
|
</div>
|
|
6
12
|
{% elif site_info.status == 'running' %}
|
|
7
13
|
<label>
|
|
@@ -11,6 +17,11 @@
|
|
|
11
17
|
</progress>
|
|
12
18
|
</label>
|
|
13
19
|
{% else %}
|
|
20
|
+
{% if site_info['problem']|length > 0 %}
|
|
21
|
+
<pre>
|
|
22
|
+
{{site_info['problem']}}
|
|
23
|
+
</pre>
|
|
24
|
+
{% endif %}
|
|
14
25
|
<table>
|
|
15
26
|
<caption>Last 12 months</caption>
|
|
16
27
|
<thead>
|
|
@@ -30,4 +41,12 @@
|
|
|
30
41
|
{% endfor %}
|
|
31
42
|
</tbody>
|
|
32
43
|
</table>
|
|
44
|
+
|
|
45
|
+
<h3>Log</h3>
|
|
46
|
+
|
|
47
|
+
<ul>
|
|
48
|
+
{% for line in site_info.log %}
|
|
49
|
+
<li>>{{line}}</li>
|
|
50
|
+
{% endfor %}
|
|
51
|
+
</ul>
|
|
33
52
|
{% endif %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1754580326.0.0
|
|
4
4
|
Summary: Web Application for checking UK energy bills.
|
|
5
5
|
Project-URL: Homepage, https://github.com/WessexWater/chellow
|
|
6
6
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
@@ -25,7 +25,7 @@ chellow/e/computer.py,sha256=lt4Zlr8EOClL1acuuvKA-tNPCI5RRHnAZbsaGQnB9j4,68835
|
|
|
25
25
|
chellow/e/dno_rate_parser.py,sha256=EO3uIYD0uiT8uumI5wnODMsFwYGrdB5HexuOu-2aFkw,21875
|
|
26
26
|
chellow/e/duos.py,sha256=RHrn93I1ASO2uYkuF18qlhG4p-jpuJhd_g3o69wtP4U,31004
|
|
27
27
|
chellow/e/elexon.py,sha256=eOmX_wpxj6Ty6eaEgGAgXX-MgyJkYQSAT6DtJeP1rUE,5544
|
|
28
|
-
chellow/e/energy_management.py,sha256=
|
|
28
|
+
chellow/e/energy_management.py,sha256=tRQJ-7_caG91oKnh5qIuK9qE_Nr3BmZ3ddaj5GTHIKQ,10487
|
|
29
29
|
chellow/e/hh_importer.py,sha256=JBVCNSpM-DMu9_io516KojvujwZEQq6upDSsMbtu_sI,21511
|
|
30
30
|
chellow/e/hh_parser_bg_csv.py,sha256=W5SU2MSpa8BGA0VJw1JXF-IwbCNLFy8fe35yxLZ7gEw,2453
|
|
31
31
|
chellow/e/hh_parser_df2.py,sha256=nZT198EZWo_G26IfJZncI_kOo-UdsXzFYDmDf3qyEs8,5089
|
|
@@ -44,7 +44,7 @@ chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,623
|
|
|
44
44
|
chellow/e/tlms.py,sha256=pyL32hPiYd09FbpXVMnBjHsWFEQHs-Az945V7EShGiY,9116
|
|
45
45
|
chellow/e/tnuos.py,sha256=NBmc-f3oezrl4gviAKobljHfICTpBKxxxEGBGJi_lRk,4927
|
|
46
46
|
chellow/e/triad.py,sha256=uQIngSrz8irBXQ0Rp_s8nAUzu-y2Ms7aj4B38_Ff8y8,13720
|
|
47
|
-
chellow/e/views.py,sha256=
|
|
47
|
+
chellow/e/views.py,sha256=lHE1MAfVmv_4U8Yikirduf_DeDky8KAhbzSMReJLz7I,220455
|
|
48
48
|
chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=opjXRrqrgBTbSKzL0JfTLP0fnz3DL3oRZZ4P0DifQ3I,4119
|
|
50
50
|
chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
|
|
@@ -228,7 +228,7 @@ chellow/templates/e/elexon.html,sha256=QW2EKdTMBTIzUkiXpYIHVZidZHNca3GmyiwWKaWkv
|
|
|
228
228
|
chellow/templates/e/em_hh_data.html,sha256=2Ndvpo2ngO2dOpEZa05-6xRCy3IKNkWHJwW6sVjhhWY,2032
|
|
229
229
|
chellow/templates/e/em_months.html,sha256=_WdOxiQ8dMEke1_nmD2yglY2zYzMx0AsaQgOw_6kDk8,6657
|
|
230
230
|
chellow/templates/e/em_site.html,sha256=vbax2Je_DNCSWNDM0XLuvegRXNlDs71Vf4l07LCABSE,3066
|
|
231
|
-
chellow/templates/e/em_totals.html,sha256=
|
|
231
|
+
chellow/templates/e/em_totals.html,sha256=pg8XmCGj-40hLCuJ3pfjNUGFteXe_xUgp7w2A5-oPtE,976
|
|
232
232
|
chellow/templates/e/energisation_status.html,sha256=hvD1qMpLYjmWWGIrv-5Ko3KbRL3a6MdQXcO3Fr4_cHA,478
|
|
233
233
|
chellow/templates/e/energisation_statuses.html,sha256=qwRIH7jqKA1MgajsWOeZAH89iRpOfsNW_fAqXymUQ3E,587
|
|
234
234
|
chellow/templates/e/era_edit.html,sha256=MoJ7yS8BWGz7ptqxDPpBio0cnYDYDOoa4jNcpz4NAbk,4094
|
|
@@ -385,6 +385,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
|
|
|
385
385
|
chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
|
|
386
386
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
387
387
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
388
|
-
chellow-
|
|
389
|
-
chellow-
|
|
390
|
-
chellow-
|
|
388
|
+
chellow-1754580326.0.0.dist-info/METADATA,sha256=EbhUmrch9GYbSCjoziMmbow40xhY8rApLwP0V-TDTqw,12519
|
|
389
|
+
chellow-1754580326.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
390
|
+
chellow-1754580326.0.0.dist-info/RECORD,,
|
|
File without changes
|