Skip to content

Commit

Permalink
Merge pull request #7 from infodavide/dev
Browse files Browse the repository at this point in the history
Fixes and package update
  • Loading branch information
infodavide committed Mar 31, 2024
2 parents 9c4d3be + 0ebacd3 commit 656971e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions enedis_data_connect/enedis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ def get_data(self, url: str, headers: dict[str, str] = None, params: dict[str, s
resp = http_session.send(prepared_req)
self._log_response(resp)
if resp.status_code == 401:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
if auto_connect:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
else:
raise InvalidAccess
elif resp.status_code == 200:
return json.loads(resp.text)
else:
Expand Down Expand Up @@ -265,9 +268,12 @@ def post_data_with_result(self, url: str, headers: dict[str, str] = None, params
resp = http_session.send(prepared_req)
self._log_response(resp)
if resp.status_code == 401:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
if auto_connect:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
else:
raise InvalidAccess
elif resp.status_code == 200:
return json.loads(resp.text)
else:
Expand Down Expand Up @@ -313,9 +319,12 @@ def post_data_without_result(self, url: str, headers: dict[str, str], params: di
resp = http_session.send(prepared_req)
self._log_response(resp)
if resp.status_code == 401:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
if auto_connect:
self._logger.warning("Token expired, trying to re-authenticate...")
self._token_data = None
self.connect()
else:
raise InvalidAccess
elif resp.status_code == 200:
return
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
version='1.0.0',
description='Enedis data connect client',
long_description=readme_content,
author='David Rolland',
author='David R',
author_email='contact@infodavid.org',
url='https://github.com/infodavide/enedis_data_connect',
license=license_content,
Expand Down

0 comments on commit 656971e

Please sign in to comment.