beufanet / linkyndle

Fetch dataset from Enedis portal (need Linky) and push it to grafana
53 stars 15 forks source link

astimezone() cannot be applied to a naive datetime #16

Closed nioc closed 4 years ago

nioc commented 5 years ago

Hello,

I have the following execution error (probably a Python lib missing):

nioc@nioc:/home/nioc/linkyndle# python3 linkynflux.py --days=16
2019-05-18 20:06:40,476 logging in InfluxDB Server Host http://localhost...
2019-05-18 20:06:40,478 logged in InfluxDB Server Host http://localhost succesfully
2019-05-18 20:06:40,479 logging in Enedis URI https://espace-client-particuliers.enedis.fr/group/espace-particuliers...
2019-05-18 20:06:40,494 Starting new HTTPS connection (1): espace-client-connexion.enedis.fr:443
2019-05-18 20:06:41,074 https://espace-client-connexion.enedis.fr:443 "POST /auth/UI/Login HTTP/1.1" 302 0
2019-05-18 20:06:41,095 logged in successfully!
Traceback (most recent call last):
  File "linkynflux.py", line 117, in <module>
    firstTS =  _getStartTS(args.days)
  File "linkynflux.py", line 59, in _getStartTS
    return date.astimezone(tz.tzutc()).timestamp()
ValueError: astimezone() cannot be applied to a naive datetime

My pip3 list: acme (0.28.0) certbot (0.28.0) certbot-apache (0.28.0) certifi (2019.3.9) chardet (3.0.4) ConfigArgParse (0.11.0) configobj (5.0.6) cryptography (1.7.1) DateTime (4.3) fail2ban (0.9.6) fake-useragent (0.1.11) future (0.15.2) httplib2 (0.9.2) idna (2.8) influxdb (5.2.2) josepy (1.1.0) keyring (10.1) keyrings.alt (1.3) mock (2.0.0) parsedatetime (2.4) pbr (1.10.0) pip (9.0.1) pyasn1 (0.1.9) pycrypto (2.6.1) pycurl (7.43.0) pygobject (3.22.0) pyinotify (0.9.6) pyOpenSSL (16.2.0) pyRFC3339 (1.0) python-apt (1.4.0b3) python-augeas (0.5.0) python-dateutil (2.8.0) python-debian (0.1.30) python-debianbts (2.6.1) pytz (2016.7) pyxdg (0.25) reportbug (7.1.7) requests (2.22.0) requests-toolbelt (0.7.0) SecretStorage (2.3.1) setuptools (33.1.1) six (1.10.0) systemd-python (233) urllib3 (1.25.2) wheel (0.29.0) zope.component (4.3.0) zope.event (4.2.0) zope.hookable (4.0.4) zope.interface (4.3.2)

tuykroa commented 5 years ago

Try this release fixes the problem: "naive datetime". https://github.com/tuykroa/linkyndle/tree/patch-1

nioc commented 5 years ago

Hello @tuykroa, good work :ok_hand: Missing the same correction on line 65, in _getDateTS function ; I added it and it works perfectly.

beufanet commented 5 years ago

Could you submit a Merge Request ?