Hydro-Quebec-API-Wrapper 4.4.0__py3-none-any.whl → 4.5.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.
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/METADATA +1 -1
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/RECORD +9 -9
- hydroqc/hydro_api/client.py +73 -1
- hydroqc/hydro_api/consts.py +8 -0
- hydroqc/webuser.py +4 -0
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/WHEEL +0 -0
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/entry_points.txt +0 -0
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/licenses/LICENSE +0 -0
- {hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/top_level.txt +0 -0
{hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/RECORD
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
hydro_quebec_api_wrapper-4.
|
|
1
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
2
2
|
hydroqc/__init__.py,sha256=sFhCh7-LWoISCQuAtdrLQOmj2x5wjHBGbAAPg4SN6Pc,40
|
|
3
3
|
hydroqc/account.py,sha256=84PO2npB_VG8cEzGIbmXj9sD1whG8qynkiGd-yEYddM,3375
|
|
4
4
|
hydroqc/consts.py,sha256=CcqeInTfcpBe-u1-KGHUHd2SVv6Hq_27I8vLW5W53oM,768
|
|
@@ -10,7 +10,7 @@ hydroqc/public_client.py,sha256=pUXA9rkgA8b4wIA3EMsd8FAC-swp-IRa4S-VK0v60SQ,3065
|
|
|
10
10
|
hydroqc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
hydroqc/timerange.py,sha256=MXR9yau72m4UZBSmN1qB0jMs0x4_jEZYnwtaUnGq-MQ,1137
|
|
12
12
|
hydroqc/utils.py,sha256=sxA5qkOA-Ui5jgEYItFQIeQdBsS_5z8J3xn8YxKZMow,232
|
|
13
|
-
hydroqc/webuser.py,sha256=
|
|
13
|
+
hydroqc/webuser.py,sha256=MWnV19uQXXu1U0NLDiUBP6B1IAgSudhGzRXZbX6km1g,7693
|
|
14
14
|
hydroqc/contract/__init__.py,sha256=uqxjOgyhpKFd-n_umxdaW5FB_DkJJaettWnEFC0nRYc,548
|
|
15
15
|
hydroqc/contract/common.py,sha256=xVw9z_Yjqp95SGCPNAfJVABvgp_C-KM51VTBEU9wjeM,15705
|
|
16
16
|
hydroqc/contract/contract_d.py,sha256=6jPYTCjFq8zonfbXPrEujDVz58n5RUEuq54VCGqph6o,856
|
|
@@ -23,8 +23,8 @@ hydroqc/contract/contract_residential.py,sha256=v88mWvJsJP7FsY5cHmr0ZYYT_S-6xtSk
|
|
|
23
23
|
hydroqc/contract/outage.py,sha256=K5XX0enSKMVpL-JCkWsykuKUw-5_GcSJLzcSR1SqQDk,3979
|
|
24
24
|
hydroqc/hydro_api/__init__.py,sha256=bIIjTkhQcXG7kn4cQr_Q6tFSKGjAx-AXLjMMlRCjclY,32
|
|
25
25
|
hydroqc/hydro_api/cache.py,sha256=14nLVxV8Q2d9qnEi2iKK9exkhe5WCFueGu9uX5y_tyU,1716
|
|
26
|
-
hydroqc/hydro_api/client.py,sha256=
|
|
27
|
-
hydroqc/hydro_api/consts.py,sha256=
|
|
26
|
+
hydroqc/hydro_api/client.py,sha256=yCGsDy6suQsKM5oVAjBtBi2KTSrR5LJ6MYpW_h1OT2E,64160
|
|
27
|
+
hydroqc/hydro_api/consts.py,sha256=fWzawKy95zrzjpmXVIEoyxp1VcDrF_u26Cj7Zkn5hFw,7051
|
|
28
28
|
hydroqc/hydro_api/mfa.py,sha256=UDfmXHjb4l5ggM1K9noAUQy2kO_yLZBHB-fqnUwtSx0,27825
|
|
29
29
|
hydroqc/peak/__init__.py,sha256=ye2KbWXhJEHZnBDaFylWioy3W-mzJw_lDplsJNAapNs,19
|
|
30
30
|
hydroqc/peak/basepeak.py,sha256=DMXjZXyNRHWnuhB0Vp3ZINGhNQngG7AU15cDLajmC7M,1954
|
|
@@ -47,8 +47,8 @@ hydroqc/types/cpc.py,sha256=ghmtBTT1FKuqVodJJ0kCtUbYNTLCOrngxgcrzjJYvok,2116
|
|
|
47
47
|
hydroqc/types/dpc.py,sha256=mwA5T9fGcNTA-kb_f25wq2ALJCwa5lKABOS73L6znY0,1981
|
|
48
48
|
hydroqc/types/dt.py,sha256=rEXDgNewhlOsRbso0Shlq69TvJFoT56EGYOAjTFZU80,693
|
|
49
49
|
hydroqc/types/outage.py,sha256=XTsNyu8mmxUx44XWvOOUHKSoijp-lgbXwQroiqm9S0o,3932
|
|
50
|
-
hydro_quebec_api_wrapper-4.
|
|
51
|
-
hydro_quebec_api_wrapper-4.
|
|
52
|
-
hydro_quebec_api_wrapper-4.
|
|
53
|
-
hydro_quebec_api_wrapper-4.
|
|
54
|
-
hydro_quebec_api_wrapper-4.
|
|
50
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/METADATA,sha256=UKXmy1UZN8OVvYzp1dItBUIoImgYi9bA5IDTehJsX5s,10017
|
|
51
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
52
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/entry_points.txt,sha256=G2YKkCH9rFt2dXbFyHINBp4bmqY2HTEIaf7F1CwbC_k,57
|
|
53
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/top_level.txt,sha256=YAcYLnu5YYkbxt1psUoBfo_opl-lAZKq0A7B3IN_P6M,8
|
|
54
|
+
hydro_quebec_api_wrapper-4.5.0.dist-info/RECORD,,
|
hydroqc/hydro_api/client.py
CHANGED
|
@@ -53,6 +53,9 @@ from hydroqc.hydro_api.consts import (
|
|
|
53
53
|
OPEN_DATA_PEAK_URL,
|
|
54
54
|
OUTAGES,
|
|
55
55
|
PERIOD_DATA_URL,
|
|
56
|
+
PORTAL_UNAVAILABILITY_DATE_FORMAT,
|
|
57
|
+
PORTAL_UNAVAILABILITY_SERVICES,
|
|
58
|
+
PORTAL_UNAVAILABILITY_URL,
|
|
56
59
|
PORTRAIT_URL,
|
|
57
60
|
RELATION_URL,
|
|
58
61
|
REQUESTS_TIMEOUT,
|
|
@@ -406,8 +409,77 @@ class HydroClient:
|
|
|
406
409
|
await self._session.close()
|
|
407
410
|
self._session = None
|
|
408
411
|
|
|
412
|
+
async def get_portal_unavailability(self) -> dict[str, str] | None:
|
|
413
|
+
"""Return the planned unavailability window in effect, if any.
|
|
414
|
+
|
|
415
|
+
Reads the feed the Espace client uses to show its maintenance page. The
|
|
416
|
+
result holds ``service``, ``from``, ``to`` (Hydro-Quebec local time) and
|
|
417
|
+
the ``messages_fr``/``messages_en`` HTML. ``None`` when no window covers
|
|
418
|
+
the current time or when the feed cannot be read.
|
|
419
|
+
"""
|
|
420
|
+
await self._get_httpsession()
|
|
421
|
+
try:
|
|
422
|
+
# Same cache buster as the Espace client, so an early end shows up.
|
|
423
|
+
params = {"date": str(int(datetime.now().timestamp() * 1000))}
|
|
424
|
+
response = await self.http_request(
|
|
425
|
+
PORTAL_UNAVAILABILITY_URL, "get", params=params, status=None
|
|
426
|
+
)
|
|
427
|
+
if response.status != 200:
|
|
428
|
+
self._logger.debug(
|
|
429
|
+
"Unavailability feed answered HTTP %s", response.status
|
|
430
|
+
)
|
|
431
|
+
return None
|
|
432
|
+
feed = await response.json(content_type=None)
|
|
433
|
+
except (HydroQcError, aiohttp.ClientError, asyncio.TimeoutError, ValueError):
|
|
434
|
+
self._logger.debug("Could not read the unavailability feed", exc_info=True)
|
|
435
|
+
return None
|
|
436
|
+
if not isinstance(feed, dict):
|
|
437
|
+
return None
|
|
438
|
+
|
|
439
|
+
now = datetime.now(EST_TIMEZONE)
|
|
440
|
+
for service in PORTAL_UNAVAILABILITY_SERVICES:
|
|
441
|
+
windows = feed.get(service)
|
|
442
|
+
if not isinstance(windows, list):
|
|
443
|
+
continue
|
|
444
|
+
for window in windows:
|
|
445
|
+
try:
|
|
446
|
+
start = EST_TIMEZONE.localize(
|
|
447
|
+
datetime.strptime(
|
|
448
|
+
window["from"], PORTAL_UNAVAILABILITY_DATE_FORMAT
|
|
449
|
+
)
|
|
450
|
+
)
|
|
451
|
+
end = EST_TIMEZONE.localize(
|
|
452
|
+
datetime.strptime(
|
|
453
|
+
window["to"], PORTAL_UNAVAILABILITY_DATE_FORMAT
|
|
454
|
+
)
|
|
455
|
+
)
|
|
456
|
+
except (KeyError, TypeError, ValueError):
|
|
457
|
+
continue
|
|
458
|
+
if start <= now < end:
|
|
459
|
+
return {
|
|
460
|
+
"service": service,
|
|
461
|
+
"from": window["from"],
|
|
462
|
+
"to": window["to"],
|
|
463
|
+
"messages_fr": str(window.get("messages_fr", "")),
|
|
464
|
+
"messages_en": str(window.get("messages_en", "")),
|
|
465
|
+
}
|
|
466
|
+
return None
|
|
467
|
+
|
|
409
468
|
async def check_portal_status(self) -> bool:
|
|
410
|
-
"""Check if Hydro Quebec portal is UP.
|
|
469
|
+
"""Check if Hydro Quebec portal is UP.
|
|
470
|
+
|
|
471
|
+
The portal page keeps answering 200 during a planned maintenance, so the
|
|
472
|
+
unavailability feed is checked first.
|
|
473
|
+
"""
|
|
474
|
+
if (unavailability := await self.get_portal_unavailability()) is not None:
|
|
475
|
+
self._logger.info(
|
|
476
|
+
"Hydro Quebec announces a maintenance of %s from %s to %s",
|
|
477
|
+
unavailability["service"],
|
|
478
|
+
unavailability["from"],
|
|
479
|
+
unavailability["to"],
|
|
480
|
+
)
|
|
481
|
+
return False
|
|
482
|
+
|
|
411
483
|
# Get http session
|
|
412
484
|
await self._get_httpsession()
|
|
413
485
|
self._logger.info("Checking if the Hydro Quebec portal is UP")
|
hydroqc/hydro_api/consts.py
CHANGED
|
@@ -196,3 +196,11 @@ AUTH_CLIENTS = {
|
|
|
196
196
|
api_channel="mobile",
|
|
197
197
|
),
|
|
198
198
|
}
|
|
199
|
+
|
|
200
|
+
# Maintenance windows the Espace client reads (indisponibiliteUrl in its config/app.json).
|
|
201
|
+
PORTAL_UNAVAILABILITY_URL = (
|
|
202
|
+
"https://clientele-statique.solutions.hydroquebec.com/config/indispo/"
|
|
203
|
+
"indisponibilites.json"
|
|
204
|
+
)
|
|
205
|
+
PORTAL_UNAVAILABILITY_SERVICES = ("libreService", "appMobileAuthentifiee")
|
|
206
|
+
PORTAL_UNAVAILABILITY_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
hydroqc/webuser.py
CHANGED
|
@@ -65,6 +65,10 @@ class WebUser:
|
|
|
65
65
|
"""Check if the Hydro Quebec website/portal is available."""
|
|
66
66
|
return await self._hydro_client.check_portal_status()
|
|
67
67
|
|
|
68
|
+
async def get_hq_portal_unavailability(self) -> dict[str, str] | None:
|
|
69
|
+
"""Return the planned Hydro Quebec unavailability in effect, if any."""
|
|
70
|
+
return await self._hydro_client.get_portal_unavailability()
|
|
71
|
+
|
|
68
72
|
async def login(self) -> LoginStatus:
|
|
69
73
|
"""Login to Hydroquebec website.
|
|
70
74
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hydro_quebec_api_wrapper-4.4.0.dist-info → hydro_quebec_api_wrapper-4.5.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|