e-data 1.3.2__tar.gz → 1.3.3__tar.gz
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.
- {e_data-1.3.2/e_data.egg-info → e_data-1.3.3}/PKG-INFO +1 -1
- {e_data-1.3.2 → e_data-1.3.3/e_data.egg-info}/PKG-INFO +1 -1
- {e_data-1.3.2 → e_data-1.3.3}/e_data.egg-info/SOURCES.txt +1 -0
- e_data-1.3.3/edata/cli.py +24 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/connectors/datadis.py +4 -4
- {e_data-1.3.2 → e_data-1.3.3}/pyproject.toml +1 -1
- {e_data-1.3.2 → e_data-1.3.3}/LICENSE +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/MANIFEST.in +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/README.md +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/e_data.egg-info/dependency_links.txt +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/e_data.egg-info/requires.txt +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/e_data.egg-info/top_level.txt +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/__init__.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/connectors/__init__.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/connectors/redata.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/const.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/definitions.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/helpers.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/__init__.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/base.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/billing.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/consumption.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/maximeter.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/processors/utils.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/storage.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/tests/__init__.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/tests/test_datadis_connector.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/tests/test_helpers.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/tests/test_processors.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/edata/tests/test_redata_connector.py +0 -0
- {e_data-1.3.2 → e_data-1.3.3}/setup.cfg +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from getpass import getpass
|
|
3
|
+
from edata.connectors.datadis import DatadisConnector
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
def main():
|
|
7
|
+
"""CLI básica para mostrar supplies y contracts de Datadis."""
|
|
8
|
+
username = typer.prompt("Usuario (NIF)")
|
|
9
|
+
password = getpass("Contraseña: ")
|
|
10
|
+
connector = DatadisConnector(username, password)
|
|
11
|
+
supplies = connector.get_supplies()
|
|
12
|
+
typer.echo("\nSupplies:")
|
|
13
|
+
typer.echo(json.dumps(supplies, indent=2, default=str))
|
|
14
|
+
if supplies:
|
|
15
|
+
cups = supplies[0]["cups"]
|
|
16
|
+
distributor = supplies[0]["distributorCode"]
|
|
17
|
+
contracts = connector.get_contract_detail(cups, distributor)
|
|
18
|
+
typer.echo("\nContracts:")
|
|
19
|
+
typer.echo(json.dumps(contracts, indent=2, default=str))
|
|
20
|
+
else:
|
|
21
|
+
typer.echo("No se encontraron supplies.")
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
typer.run(main)
|
|
@@ -143,8 +143,8 @@ class DatadisConnector:
|
|
|
143
143
|
async with session.post(
|
|
144
144
|
URL_TOKEN,
|
|
145
145
|
data={
|
|
146
|
-
TOKEN_USERNAME: self._usr
|
|
147
|
-
TOKEN_PASSWD: self._pwd
|
|
146
|
+
TOKEN_USERNAME: self._usr,
|
|
147
|
+
TOKEN_PASSWD: self._pwd,
|
|
148
148
|
},
|
|
149
149
|
) as response:
|
|
150
150
|
text = await response.text()
|
|
@@ -223,7 +223,7 @@ class DatadisConnector:
|
|
|
223
223
|
if reply.status == 200:
|
|
224
224
|
_LOGGER.info("Got 200 OK")
|
|
225
225
|
try:
|
|
226
|
-
json_data = await reply.json()
|
|
226
|
+
json_data = await reply.json(content_type=None)
|
|
227
227
|
if json_data:
|
|
228
228
|
response = json_data
|
|
229
229
|
if not ignore_recent_queries:
|
|
@@ -232,7 +232,7 @@ class DatadisConnector:
|
|
|
232
232
|
_LOGGER.info("Got an empty response")
|
|
233
233
|
if not ignore_recent_queries:
|
|
234
234
|
self._update_recent_queries(url + params)
|
|
235
|
-
except Exception:
|
|
235
|
+
except Exception as e:
|
|
236
236
|
_LOGGER.warning("Failed to parse JSON response")
|
|
237
237
|
elif reply.status == 401 and not refresh_token:
|
|
238
238
|
response = await self._async_get(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|