chellow 1707388338.0.0__py3-none-any.whl → 1707995667.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/dloads.py +4 -0
- chellow/e/hh_importer.py +11 -8
- chellow/e/hh_parser_bg_csv.py +3 -3
- chellow/e/hh_parser_df2.py +19 -3
- chellow/e/hh_parser_simple_csv.py +3 -3
- chellow/reports/report_183.py +3 -9
- chellow/templates/e/dc_contract_edit.html +8 -1
- {chellow-1707388338.0.0.dist-info → chellow-1707995667.0.0.dist-info}/METADATA +1 -1
- {chellow-1707388338.0.0.dist-info → chellow-1707995667.0.0.dist-info}/RECORD +10 -10
- {chellow-1707388338.0.0.dist-info → chellow-1707995667.0.0.dist-info}/WHEEL +0 -0
chellow/dloads.py
CHANGED
|
@@ -64,6 +64,10 @@ class DloadFile:
|
|
|
64
64
|
self._check_exists()
|
|
65
65
|
return self.f.truncate(*args, **kwargs)
|
|
66
66
|
|
|
67
|
+
def writestr(self, *args, **kwargs):
|
|
68
|
+
self._check_exists()
|
|
69
|
+
return self.f.writestr(*args, **kwargs)
|
|
70
|
+
|
|
67
71
|
def close(self):
|
|
68
72
|
self.f.close()
|
|
69
73
|
self._check_exists()
|
chellow/e/hh_importer.py
CHANGED
|
@@ -48,6 +48,7 @@ class HhDataImportProcess(threading.Thread):
|
|
|
48
48
|
super().__init__(name=f"HH Manual Import: contract {dc_contract_id}")
|
|
49
49
|
|
|
50
50
|
self.messages = []
|
|
51
|
+
self.error = None
|
|
51
52
|
self.istream = istream
|
|
52
53
|
self.dc_contract_id = dc_contract_id
|
|
53
54
|
self.id = process_id
|
|
@@ -74,14 +75,16 @@ class HhDataImportProcess(threading.Thread):
|
|
|
74
75
|
parser_module = importlib.import_module(
|
|
75
76
|
f"chellow.e.hh_parser_{mod_name}"
|
|
76
77
|
)
|
|
77
|
-
self.converter = parser_module.create_parser(
|
|
78
|
+
self.converter = parser_module.create_parser(
|
|
79
|
+
self.istream, mpan_map, self.messages
|
|
80
|
+
)
|
|
78
81
|
sess.rollback()
|
|
79
82
|
HhDatum.insert(sess, self.converter, contract)
|
|
80
83
|
sess.commit()
|
|
81
84
|
except BadRequest as e:
|
|
82
|
-
self.
|
|
85
|
+
self.error = e.description
|
|
83
86
|
except BaseException:
|
|
84
|
-
self.
|
|
87
|
+
self.error = f"Outer problem {traceback.format_exc()}"
|
|
85
88
|
|
|
86
89
|
def get_status(self):
|
|
87
90
|
return (
|
|
@@ -281,8 +284,8 @@ class HhImportTask(threading.Thread):
|
|
|
281
284
|
for message in self.importer.messages:
|
|
282
285
|
self.log(message)
|
|
283
286
|
|
|
284
|
-
if
|
|
285
|
-
raise BadRequest("Problem loading file.")
|
|
287
|
+
if self.importer.error is not None:
|
|
288
|
+
raise BadRequest(f"Problem loading file. {self.importer.error}")
|
|
286
289
|
|
|
287
290
|
contract = Contract.get_dc_by_id(sess, self.contract_id)
|
|
288
291
|
contract.update_state(state)
|
|
@@ -384,12 +387,12 @@ class HhImportTask(threading.Thread):
|
|
|
384
387
|
|
|
385
388
|
self.importer.run()
|
|
386
389
|
messages = self.importer.messages
|
|
387
|
-
self.importer = None
|
|
388
390
|
for message in messages:
|
|
389
391
|
self.log(message)
|
|
390
392
|
|
|
391
|
-
if
|
|
392
|
-
raise BadRequest("Problem loading file.")
|
|
393
|
+
if self.importer.error is not None:
|
|
394
|
+
raise BadRequest(f"Problem loading file. {self.importer.error}")
|
|
395
|
+
self.importer = None
|
|
393
396
|
|
|
394
397
|
contract = Contract.get_dc_by_id(sess, self.contract_id)
|
|
395
398
|
contract.update_state(state)
|
chellow/e/hh_parser_bg_csv.py
CHANGED
|
@@ -8,12 +8,12 @@ from werkzeug.exceptions import BadRequest
|
|
|
8
8
|
from chellow.utils import parse_mpan_core, utc_datetime
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def create_parser(reader, mpan_map):
|
|
12
|
-
return HhParserBglobal(reader, mpan_map)
|
|
11
|
+
def create_parser(reader, mpan_map, messages):
|
|
12
|
+
return HhParserBglobal(reader, mpan_map, messages)
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class HhParserBglobal:
|
|
16
|
-
def __init__(self, reader, mpan_map):
|
|
16
|
+
def __init__(self, reader, mpan_map, messages):
|
|
17
17
|
self.shredder = zip(itertools.count(1), csv.reader(reader))
|
|
18
18
|
self.line_number, self.values = next(self.shredder)
|
|
19
19
|
self.mpan_map = mpan_map
|
chellow/e/hh_parser_df2.py
CHANGED
|
@@ -6,12 +6,12 @@ from werkzeug.exceptions import BadRequest
|
|
|
6
6
|
from chellow.utils import HH, parse_mpan_core, utc_datetime
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def create_parser(reader, mpan_map):
|
|
10
|
-
return StarkDf2HhParser(reader, mpan_map)
|
|
9
|
+
def create_parser(reader, mpan_map, messages):
|
|
10
|
+
return StarkDf2HhParser(reader, mpan_map, messages)
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class StarkDf2HhParser:
|
|
14
|
-
def __init__(self, reader, mpan_map):
|
|
14
|
+
def __init__(self, reader, mpan_map, messages):
|
|
15
15
|
self.line = self.line_number = None
|
|
16
16
|
self.reader = zip(itertools.count(1), reader)
|
|
17
17
|
|
|
@@ -25,6 +25,9 @@ class StarkDf2HhParser:
|
|
|
25
25
|
4: "REACTIVE_EXP",
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
self.mpan_map = mpan_map
|
|
29
|
+
self.messages = messages
|
|
30
|
+
|
|
28
31
|
def __iter__(self):
|
|
29
32
|
return self
|
|
30
33
|
|
|
@@ -36,6 +39,15 @@ class StarkDf2HhParser:
|
|
|
36
39
|
lline = self.line.strip().upper()
|
|
37
40
|
if lline.startswith("#O"):
|
|
38
41
|
self.core = parse_mpan_core(lline[2:])
|
|
42
|
+
if self.core in self.mpan_map and self.mpan_map[self.core] is None:
|
|
43
|
+
msg = f"The MPAN core {self.core} has been ignored"
|
|
44
|
+
if len(self.messages) == 0 or self.messages[-1] != msg:
|
|
45
|
+
self.messages.append(
|
|
46
|
+
f"The MPAN core {self.core} has been ignored"
|
|
47
|
+
)
|
|
48
|
+
self.core = None
|
|
49
|
+
continue
|
|
50
|
+
|
|
39
51
|
elif lline.startswith("#S"):
|
|
40
52
|
sensor = int(lline[2:].strip())
|
|
41
53
|
try:
|
|
@@ -72,6 +84,10 @@ class StarkDf2HhParser:
|
|
|
72
84
|
except ValueError:
|
|
73
85
|
raise BadRequest("Problem parsing the value: " + fields[2])
|
|
74
86
|
status = fields[3][-1]
|
|
87
|
+
|
|
88
|
+
if self.core is None:
|
|
89
|
+
continue
|
|
90
|
+
|
|
75
91
|
local_datum = {
|
|
76
92
|
"mpan_core": self.core,
|
|
77
93
|
"channel_type": self.channel_type,
|
|
@@ -8,12 +8,12 @@ from werkzeug.exceptions import BadRequest
|
|
|
8
8
|
from chellow.utils import parse_channel_type, parse_mpan_core, to_utc, validate_hh_start
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def create_parser(reader, mpan_map):
|
|
12
|
-
return HhParserCsvSimple(reader, mpan_map)
|
|
11
|
+
def create_parser(reader, mpan_map, messages):
|
|
12
|
+
return HhParserCsvSimple(reader, mpan_map, messages)
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class HhParserCsvSimple:
|
|
16
|
-
def __init__(self, reader, mpan_map):
|
|
16
|
+
def __init__(self, reader, mpan_map, messages):
|
|
17
17
|
self.shredder = zip(itertools.count(1), csv.reader(reader))
|
|
18
18
|
next(self.shredder) # skip the title line
|
|
19
19
|
self.values = None
|
chellow/reports/report_183.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import csv
|
|
2
|
-
import os
|
|
3
2
|
import sys
|
|
4
3
|
import threading
|
|
5
4
|
import traceback
|
|
6
5
|
from io import StringIO
|
|
7
|
-
from zipfile import ZipFile
|
|
8
6
|
|
|
9
7
|
from flask import g, request
|
|
10
8
|
|
|
@@ -12,7 +10,7 @@ from sqlalchemy import or_, select
|
|
|
12
10
|
from sqlalchemy.orm import joinedload
|
|
13
11
|
from sqlalchemy.sql.expression import null, true
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
from chellow.dloads import open_file
|
|
16
14
|
from chellow.models import Era, RSession, Site, SiteEra, Supply, User
|
|
17
15
|
from chellow.utils import (
|
|
18
16
|
csv_make_val,
|
|
@@ -112,7 +110,6 @@ def none_content(site_codes, typ, start_date, finish_date, user_id, file_name):
|
|
|
112
110
|
try:
|
|
113
111
|
with RSession() as rsess:
|
|
114
112
|
user = User.get_by_id(rsess, user_id)
|
|
115
|
-
running_name, finished_name = chellow.dloads.make_names(file_name, user)
|
|
116
113
|
sites_q = (
|
|
117
114
|
select(Site)
|
|
118
115
|
.join(SiteEra)
|
|
@@ -127,7 +124,7 @@ def none_content(site_codes, typ, start_date, finish_date, user_id, file_name):
|
|
|
127
124
|
if site_codes is not None:
|
|
128
125
|
sites_q = sites_q.where(Site.code.in_(site_codes))
|
|
129
126
|
|
|
130
|
-
zf =
|
|
127
|
+
zf = open_file(file_name, user, mode="w", is_zip=True)
|
|
131
128
|
|
|
132
129
|
for site in rsess.execute(sites_q).scalars():
|
|
133
130
|
_process_site(rsess, zf, site, start_date, finish_date, typ)
|
|
@@ -141,7 +138,6 @@ def none_content(site_codes, typ, start_date, finish_date, user_id, file_name):
|
|
|
141
138
|
finally:
|
|
142
139
|
if zf is not None:
|
|
143
140
|
zf.close()
|
|
144
|
-
os.rename(running_name, finished_name)
|
|
145
141
|
|
|
146
142
|
|
|
147
143
|
def site_content(site_id, start_date, finish_date, user_id, file_name):
|
|
@@ -149,8 +145,7 @@ def site_content(site_id, start_date, finish_date, user_id, file_name):
|
|
|
149
145
|
try:
|
|
150
146
|
with RSession() as rsess:
|
|
151
147
|
user = User.get_by_id(rsess, user_id)
|
|
152
|
-
|
|
153
|
-
f = open(running_name, mode="w", newline="")
|
|
148
|
+
f = open_file(file_name, user, mode="w", newline="")
|
|
154
149
|
writer = csv.writer(f, lineterminator="\n")
|
|
155
150
|
site = Site.get_by_id(rsess, site_id)
|
|
156
151
|
sites = rsess.query(Site).filter(Site.id == site_id)
|
|
@@ -229,7 +224,6 @@ def site_content(site_id, start_date, finish_date, user_id, file_name):
|
|
|
229
224
|
finally:
|
|
230
225
|
if f is not None:
|
|
231
226
|
f.close()
|
|
232
|
-
os.rename(running_name, finished_name)
|
|
233
227
|
|
|
234
228
|
|
|
235
229
|
def do_post(sess):
|
|
@@ -62,7 +62,11 @@
|
|
|
62
62
|
"hostname": "example.com",
|
|
63
63
|
"username": "username",
|
|
64
64
|
"password": "password",
|
|
65
|
-
"directories": ["downloads1", "downloads2"]
|
|
65
|
+
"directories": ["downloads1", "downloads2"]
|
|
66
|
+
"mpan_map": { \\ Optional
|
|
67
|
+
"99 0993 2821 985": null, \\ Ignore MPAN
|
|
68
|
+
},
|
|
69
|
+
}
|
|
66
70
|
</pre>
|
|
67
71
|
</code>
|
|
68
72
|
<p>For the HTTPS protocol:</p>
|
|
@@ -81,6 +85,9 @@
|
|
|
81
85
|
"name2": val2,
|
|
82
86
|
}
|
|
83
87
|
}
|
|
88
|
+
"mpan_map": { \\ Optional
|
|
89
|
+
"99 0993 2821 985": null, \\ Ignore MPAN
|
|
90
|
+
},
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
{% endraw %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1707995667.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)
|
|
@@ -2,7 +2,7 @@ chellow/__init__.py,sha256=_9hq4MlC2YB7kUh4iH9hwmx7BqMV6JeyvGVB8uWk8Cs,10127
|
|
|
2
2
|
chellow/api.py,sha256=mk17TfweR76DPFC8lX2SArTjai6y6YshASxqO1w-_-s,11036
|
|
3
3
|
chellow/bank_holidays.py,sha256=22EdNPvUQG_hFt82OKkeKzRFht78Urhu0Sc6Kpj-1wo,4488
|
|
4
4
|
chellow/commands.py,sha256=ESBe9ZWj1c3vdZgqMZ9gFvYAB3hRag2R1PzOwuw9yFo,1302
|
|
5
|
-
chellow/dloads.py,sha256=
|
|
5
|
+
chellow/dloads.py,sha256=vtebrKchBt_oANDO_c-aL2jO-w1KKwBcYaG_VgzUlJI,5209
|
|
6
6
|
chellow/edi_lib.py,sha256=het3R0DBGtXEo-Sy1zvXQuX9EWQ1X6Y33G4l1hYYuds,51859
|
|
7
7
|
chellow/general_import.py,sha256=4LduwzNipxOiHYHQLb0x96_m3RPuDnQMbJzOFDbOqTg,65039
|
|
8
8
|
chellow/models.py,sha256=7EX1oRpIcVRsjpzIC4ROOr-zp1-C7kdoj3WSNp2AKr0,236400
|
|
@@ -24,10 +24,10 @@ chellow/e/dno_rate_parser.py,sha256=5MYEbcYngh7n6Szn2h9zLTwQKXH-WHKy6c80PYwNLLQ,
|
|
|
24
24
|
chellow/e/duos.py,sha256=ISTcNqe9KNjVNM2Qs8IBoQxnmSXOt5W_G7tZxp4T78M,28870
|
|
25
25
|
chellow/e/elexon.py,sha256=s8QdLUQMeylLhghxvvhLyOL3-0ifUnMfmo3vcbot_DY,5487
|
|
26
26
|
chellow/e/energy_management.py,sha256=aXC2qlGt3FAODlNl_frWzVYAQrJLP8FFOiNX3m-QE_Y,12388
|
|
27
|
-
chellow/e/hh_importer.py,sha256=
|
|
28
|
-
chellow/e/hh_parser_bg_csv.py,sha256=
|
|
29
|
-
chellow/e/hh_parser_df2.py,sha256=
|
|
30
|
-
chellow/e/hh_parser_simple_csv.py,sha256=
|
|
27
|
+
chellow/e/hh_importer.py,sha256=nhmlWDNBm8U4salBud8ivdaDGF1lkY82NqQCrGuPYRI,20483
|
|
28
|
+
chellow/e/hh_parser_bg_csv.py,sha256=W5SU2MSpa8BGA0VJw1JXF-IwbCNLFy8fe35yxLZ7gEw,2453
|
|
29
|
+
chellow/e/hh_parser_df2.py,sha256=ynNNRMpLm9qs23tJjfm0vGSaAduXfPMw_7-WfQHXliQ,4209
|
|
30
|
+
chellow/e/hh_parser_simple_csv.py,sha256=RN4QOLvTQeoPrpvXvQ9hkOBZnR5piybLfjCiSJdjpjs,2112
|
|
31
31
|
chellow/e/laf_import.py,sha256=aqkcbjnvfBPszBLSNg6getP7iW1uWiTVHy6N5Z5x39U,5514
|
|
32
32
|
chellow/e/lcc.py,sha256=q5iGbeYZdnozkIdbGuxXoJO-1KDO7AHqYOXEGBIaNHI,4963
|
|
33
33
|
chellow/e/mdd_importer.py,sha256=9GN-at0DC3vOjd-0N2U856O3hInnjkMWWcRfxzQ5DjA,32042
|
|
@@ -71,7 +71,7 @@ chellow/reports/report_111.py,sha256=qU5MYPQzZ_cEvuERE8bxq93D-dN1yd4oML6FIqd0Jdk
|
|
|
71
71
|
chellow/reports/report_169.py,sha256=tnTiHmhigcgZ7E8rUSfgzsVYUCW947xBZZq04-KqfK8,9287
|
|
72
72
|
chellow/reports/report_177.py,sha256=JPfmdJMxRqzV_jpXjH-ziuRMwdK5UIjBUhRETJ2PnvA,10505
|
|
73
73
|
chellow/reports/report_181.py,sha256=Fm2kgqjZvTVU31H6KVBVg3bqcGPHomJG82KXa7I7k4E,4989
|
|
74
|
-
chellow/reports/report_183.py,sha256=
|
|
74
|
+
chellow/reports/report_183.py,sha256=DZX-hHJPl_Tbgkt31C_cuLZg_5L2b6iCPQ5foOZizR0,8817
|
|
75
75
|
chellow/reports/report_187.py,sha256=UvpaYHjyJFNV5puYq8_KxfzoBtVrwFgIGUOmC5oGA9A,9956
|
|
76
76
|
chellow/reports/report_215.py,sha256=_HZO_MhL51ttzmG6IrT8YVG6WmJMkRNWsXOW7AL7GWs,6766
|
|
77
77
|
chellow/reports/report_219.py,sha256=o2eEg3mX9_raP2b4gjc2Gu4vqnMqcvvJBYQ1oQjxvpE,6637
|
|
@@ -186,7 +186,7 @@ chellow/templates/e/dc_bill_edit.html,sha256=0GsN-ZIc4q-z_xs8igC2ZS6t4soo2SvB3qR
|
|
|
186
186
|
chellow/templates/e/dc_bill_import.html,sha256=NHjMSoFizvFQIaPWuVE3nTCtMDTzJB0XmH8jXfV1tiA,2188
|
|
187
187
|
chellow/templates/e/dc_bill_imports.html,sha256=lCaUR47r9KPr0VrQhEvVEaKexM5R_nmkxtzgpWZ0e9s,2135
|
|
188
188
|
chellow/templates/e/dc_contract.html,sha256=_fq_s69kmbrGlScYngRYm4cPdRgh2roMvSfvG0J4xzA,2326
|
|
189
|
-
chellow/templates/e/dc_contract_edit.html,sha256=
|
|
189
|
+
chellow/templates/e/dc_contract_edit.html,sha256=wKK2pXN78VfSJ6gjfNRkikRFkYTiKtGL3UeVFIYSRwc,3115
|
|
190
190
|
chellow/templates/e/dc_contract_hh_import.html,sha256=UODiBFNohb60MjH1w-9JW1JE0O9GR2uKPGw-lD7Da5g,848
|
|
191
191
|
chellow/templates/e/dc_contract_hh_imports.html,sha256=eXFDGyzSgag4JRism81_p5yTzQOjCIXaVkQ8tl3dDcM,8172
|
|
192
192
|
chellow/templates/e/dc_contracts.html,sha256=v8czpEcMzndngfWNXIKXib6Xrz9OwJjQAmNQNrQ6Y08,1705
|
|
@@ -363,6 +363,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
|
|
|
363
363
|
chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
|
|
364
364
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
365
365
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
366
|
-
chellow-
|
|
367
|
-
chellow-
|
|
368
|
-
chellow-
|
|
366
|
+
chellow-1707995667.0.0.dist-info/METADATA,sha256=qAtfNaDLJjw2jkahNM2b5loL8f-MkeEf2NXOo2tun_E,12203
|
|
367
|
+
chellow-1707995667.0.0.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
|
|
368
|
+
chellow-1707995667.0.0.dist-info/RECORD,,
|
|
File without changes
|