Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
xannz committed Dec 5, 2019
1 parent df11cf6 commit 61b4917
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions obelisk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# from ObeliskClient import Obelisk, ObeliskError
from obelisk.obeliskclient import Obelisk, ObeliskError, ObeliskPrecisions

import logging
Expand All @@ -9,7 +8,7 @@
__all__ = [
Obelisk,
ObeliskError,
ObeliskPrecisions
ObeliskPrecisions,
]

__version__ = '0.0.1'
8 changes: 4 additions & 4 deletions obelisk/obeliskclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __request_access_token(self):
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
body = 'grant_type=client_credentials'
r = requests.post("{}/auth/realms/idlab-iot/protocol/openid-connect/token".format(self._base_url), data=body,
auth=HTTPBasicAuth(self._client_id, self._client_secret), headers=headers, timeout=10)
auth=HTTPBasicAuth(self._client_id, self._client_secret), headers=headers, timeout=10)
r.raise_for_status()
message = r.json()
return message['access_token']
Expand All @@ -76,7 +76,7 @@ def __request_rpt_token(self):
'audience': 'policy-enforcer',
}
r = requests.post("{}/auth/realms/idlab-iot/protocol/openid-connect/token".format(self._base_url), data=payload,
headers=headers, timeout=10)
headers=headers, timeout=10)
r.raise_for_status()
message = r.json()
self._rpt_token = message['access_token']
Expand Down Expand Up @@ -118,7 +118,7 @@ def send_to_obelisk(self, data, refresh_rpt=False):
else:
self.__refresh_rpt_token()
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer {}'.format(self._rpt_token)}
'Authorization': 'Bearer {}'.format(self._rpt_token)}
url = "{}/api/{}/scopes/{}/ingest?precision={}".format(
self._base_url, self._version, self._scope_id, obelisk_precisions[self._precision])
resp = requests.post(url, json=data, headers=headers, timeout=10)
Expand All @@ -129,4 +129,4 @@ def send_to_obelisk(self, data, refresh_rpt=False):
resp.raise_for_status()
except requests.exceptions.HTTPError as e:
logger.error(e)
raise ObeliskError("Could not send data to Obelisk.")
raise ObeliskError("Could not send data to Obelisk.")

0 comments on commit 61b4917

Please sign in to comment.