chellow 1717082284.0.0__py3-none-any.whl → 1717489198.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/bmarketidx.py CHANGED
@@ -1,9 +1,12 @@
1
1
  import atexit
2
- import collections
3
2
  import threading
4
3
  import traceback
4
+ from collections import deque
5
+ from datetime import datetime as Datetime
5
6
  from decimal import Decimal
6
7
 
8
+ from dateutil.relativedelta import relativedelta
9
+
7
10
  import requests
8
11
 
9
12
  from werkzeug.exceptions import BadRequest
@@ -73,7 +76,7 @@ class BmarketidxImporter(threading.Thread):
73
76
  def __init__(self):
74
77
  super().__init__(name="Bmarketidx Importer")
75
78
  self.lock = threading.RLock()
76
- self.messages = collections.deque(maxlen=100)
79
+ self.messages = deque(maxlen=1000)
77
80
  self.stopped = threading.Event()
78
81
  self.going = threading.Event()
79
82
 
@@ -144,8 +147,8 @@ class BmarketidxImporter(threading.Thread):
144
147
  else:
145
148
  self.global_alert = (
146
149
  f"There's a problem with the <a "
147
- f"href='/e/non_core_contracts/{contract.id}/"
148
- f"automatic_importer'>bmarketidx automatic "
150
+ f"href='/non_core_contracts/{contract.id}/"
151
+ f"auto_importer'>bmarketidx automatic "
149
152
  f"importer</a>."
150
153
  )
151
154
  finally:
@@ -164,24 +167,38 @@ def _process_month(log_f, sess, contract, latest_rs, month_start, month_finish):
164
167
  )
165
168
  rates = {}
166
169
  month_finish_ct = to_ct(month_finish)
170
+ base_url = "https://data.elexon.co.uk/bmrs/api/v1/balancing/pricing/market-index"
167
171
  for d in range(month_finish_ct.day):
168
- day_ct = ct_datetime(month_finish_ct.year, month_finish_ct.month, d + 1)
172
+ day_from_ct = ct_datetime(month_finish_ct.year, month_finish_ct.month, d + 1)
173
+ day_to_ct = day_from_ct + relativedelta(days=1)
169
174
  params = {
170
- "q": f"ajax/alldata/MID/Date,SP,Provider,Price,Volume/NULL/"
171
- f'{day_ct.strftime("%Y-%m-%d")}/ALL'
175
+ "from": f'{day_from_ct.strftime("%Y-%m-%d")}T00:00Z',
176
+ "to": f'{day_to_ct.strftime("%Y-%m-%d")}T00:00Z',
177
+ "settlementPeriodFrom": "1",
178
+ "settlementPeriodTo": "1",
172
179
  }
173
180
  sess.rollback()
174
- r = requests.get(
175
- "https://www.bmreports.com/bmrs/", params=params, timeout=60, verify=False
176
- )
181
+ q_str = "&".join(f"{k}={v}" for k, v in params.items())
182
+ log_f(f"Attempting to download {base_url}?{q_str}")
183
+ r = requests.get(base_url, params=params, timeout=60, verify=False)
177
184
  res = r.json()
178
- for h in res["arr"]:
179
- dt = to_utc(day_ct + (int(h["settlementPeriod"]) - 1) * HH)
180
- try:
181
- rate = rates[dt]
182
- except KeyError:
183
- rate = rates[dt] = {}
184
- rate[h["DataProviderId"]] = Decimal(h["MarketIndexPrice"]) / Decimal(1000)
185
+ for h in res["data"]:
186
+ # {
187
+ # "startTime":"2022-06-01T23:00:00Z",
188
+ # "dataProvider":"N2EXMIDP",
189
+ # "settlementDate":"2022-06-02",
190
+ # "settlementPeriod":1,
191
+ # "price":0.00,
192
+ # "volume":0.000
193
+ # },
194
+ settlement_date = Datetime.strptime(h["settlementDate"], "%Y-%m-%d")
195
+ if settlement_date.month == month_finish_ct.month:
196
+ dt = to_utc(settlement_date + (int(h["settlementPeriod"]) - 1) * HH)
197
+ try:
198
+ rate = rates[dt]
199
+ except KeyError:
200
+ rate = rates[dt] = {}
201
+ rate[h["dataProvider"]] = Decimal(h["price"]) / Decimal(1000)
185
202
 
186
203
  if month_finish in rates:
187
204
  log_f("The whole month's data is there.")
@@ -84,4 +84,5 @@
84
84
  </tbody>
85
85
  </table>
86
86
 
87
+ <pre>{{bill.breakdown}}</pre>
87
88
  {% endblock %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1717082284.0.0
3
+ Version: 1717489198.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)
@@ -15,7 +15,7 @@ chellow/views.py,sha256=eDvTQM_PUqRvrCQvBdlF5q7MEs7w2yJmRjcC8WDbHtE,79584
15
15
  chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
17
17
  chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,7411
18
- chellow/e/bmarketidx.py,sha256=0JCBBnP3xfLq2eFjXO_u-gzHyTizab4Pp6PRK6OZLcw,7134
18
+ chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
19
19
  chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
20
20
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
21
21
  chellow/e/cfd.py,sha256=V1DTT5XBQbt8hO1gae1u3315fZ4iuYk3XC7J2sUbhKQ,14352
@@ -179,7 +179,7 @@ chellow/templates/e/dc_batch_file.html,sha256=O3iedi9NUhqgGcVc1GglZ4205v9h6z2ih7
179
179
  chellow/templates/e/dc_batch_file_edit.html,sha256=7HZFuqiKORq42FTj3Luzof3uZL8VnWnVDgHHQgS2eHM,1876
180
180
  chellow/templates/e/dc_batch_upload_file.html,sha256=n06sewt7vhgm85YVbeFUKUirvP7eDu_CnMHTSu-uDqo,1556
181
181
  chellow/templates/e/dc_batches.html,sha256=B2pOCEzFmu6-CvUr3nxuTNFsuST5euRYh30m_6Wh9Rk,1007
182
- chellow/templates/e/dc_bill.html,sha256=7-ACTqHCgIukHld392CiUs1aXwzAUxgsHIUdgey9J3U,2028
182
+ chellow/templates/e/dc_bill.html,sha256=RyndxSlc-dC2fzPOOoGQAFpR4g2lVE-pXAWpraEtp7Y,2059
183
183
  chellow/templates/e/dc_bill_add.html,sha256=73Sn_MKBsUuYYnDfUMCdX1Dul6GimMC9YXk6UIU17rk,1648
184
184
  chellow/templates/e/dc_bill_edit.html,sha256=0GsN-ZIc4q-z_xs8igC2ZS6t4soo2SvB3qRA6iC-AuM,2707
185
185
  chellow/templates/e/dc_bill_import.html,sha256=NHjMSoFizvFQIaPWuVE3nTCtMDTzJB0XmH8jXfV1tiA,2188
@@ -364,6 +364,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
364
364
  chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
365
365
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
366
366
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
367
- chellow-1717082284.0.0.dist-info/METADATA,sha256=R51vpnZmFopkXyh1C4taeutDYrIwvfVjjyZoox9OX0E,12205
368
- chellow-1717082284.0.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
369
- chellow-1717082284.0.0.dist-info/RECORD,,
367
+ chellow-1717489198.0.0.dist-info/METADATA,sha256=ot9Lf-fyAnN_scgT4ordJTmGiv3CDAIOUQz3lmqiV28,12205
368
+ chellow-1717489198.0.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
369
+ chellow-1717489198.0.0.dist-info/RECORD,,