|
|
@ -66,14 +66,14 @@ class FbxTransport(): |
|
|
|
response = req_response.json() |
|
|
|
if response['success']: |
|
|
|
if 'result' in response: |
|
|
|
self.log.debug(f"<< Got {response['result']}") |
|
|
|
self.log.debug("<< Got {}".format(response['result'])) |
|
|
|
return response['result'] |
|
|
|
else: |
|
|
|
raise FbxErrorResponse(response['error_code'], response['msg']) |
|
|
|
|
|
|
|
def get_local_base(self, url=api._DISC_HTTP_URL): |
|
|
|
response = self._session.get(f"{url}/api_version").json() |
|
|
|
self.log.debug(f"<< Detected api {response['api_version']}") |
|
|
|
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'], |
|
|
|
response['api_version'][0]) |
|
|
|
|
|
|
@ -105,10 +105,10 @@ class Fbx(): |
|
|
|
s = "pending" |
|
|
|
self.log.info("Press Ok on the freebox to register application") |
|
|
|
while s == "pending": |
|
|
|
s = self._trn.api_exec("GET", f"login/authorize/{trackid}")["status"] |
|
|
|
s = self._trn.api_exec("GET", "login/authorize/{}".format(trackid))["status"] |
|
|
|
if s == "pending": |
|
|
|
time.sleep(1) |
|
|
|
self.log.debug(f"Registration returned: {s}") |
|
|
|
self.log.debug("Registration returned: {}".format(s)) |
|
|
|
return s == "granted" and self.token |
|
|
|
|
|
|
|
def mksession(self, app_id=None, token=None): |
|
|
@ -128,7 +128,7 @@ class Fbx(): |
|
|
|
session_token = resp["session_token"] |
|
|
|
self.app_id = app_id |
|
|
|
self._trn.set_session_header(session_token) |
|
|
|
self.log.info(f"Authenticated") |
|
|
|
self.log.info("Authenticated".format()) |
|
|
|
return resp["permissions"] |
|
|
|
|
|
|
|
|
|
|
@ -138,13 +138,13 @@ class FbxErrorResponse(Exception): |
|
|
|
self.msg = msg |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return f'{self.msg} [{self.error_code}]' |
|
|
|
return '{} [{}]'.format(self.msg, self.error_code) |
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger("pyfbx") |
|
|
|
|
|
|
|
# All FB subsystems are classes deriving from FbxClass |
|
|
|
for _classname in api.SYSTEMS: |
|
|
|
log.debug(f"Adding class {_classname} to locals") |
|
|
|
log.debug("Adding class {} to locals".format(_classname)) |
|
|
|
locals()[_classname] = type(_classname, (FbxClass, ), {}) |
|
|
|
__all__.append(_classname) |
|
|
|