Browse Source

Logging

7rc0
Laurent Kislaire 3 years ago
parent
commit
80b5b8eef6
  1. 13
      pyfbx/client.py

13
pyfbx/client.py

@ -42,14 +42,14 @@ class FbxTransport():
def set_url(self, url, nomdns):
if url is None:
if nomdns:
self._url = self.get_local_base()
self._url = self.local_base()
else:
self._url = mdns.FbxMDNS().search() or self.get_local_base()
self._url = mdns.FbxMDNS().search() or self.local_base()
else:
if re.search("https?://", url) is None:
url = "http://" + url
if "/api/" not in url:
self._url = self.get_local_base(url)
self._url = self.local_base(url)
else:
self._url = url
@ -71,7 +71,7 @@ class FbxTransport():
else:
raise FbxErrorResponse(response['error_code'], response['msg'])
def get_local_base(self, url=api._DISC_HTTP_URL):
def local_base(self, url=api._DISC_HTTP_URL):
response = self._session.get("{}/api_version".format(url)).json()
self.log.debug("<< Detected api {}".format(response['api_version']))
return "%s%sv%s" % (url, response['api_base_url'],
@ -87,6 +87,7 @@ class Fbx():
self.log = logging.getLogger("pyfbx.fbx")
self._trn = FbxTransport(url, nomdns=nomdns, session=session)
self.app_id = None
self.token = None
# Create on the fly attributes to classes
_globals = globals()
@ -113,6 +114,8 @@ class Fbx():
return s == "granted" and self.token
def mksession(self, app_id=None, token=None):
self.log.debug("Making session with token={}[{}], app_id={}[{}]".format(
token, self.token, self.app_id, app_id))
if token: # Don't overwrite previous token (used for refresh)
self.token = token
if app_id:
@ -131,7 +134,7 @@ class Fbx():
session_token = resp["session_token"]
self.app_id = app_id
self._trn.set_session_header(session_token)
self.log.info("Authenticated".format())
self.log.info("Authenticated. Storing token={}, app_id={}".format(self.token, self.app_id))
return resp["permissions"]

Loading…
Cancel
Save