Skip to content

Commit

Permalink
fixup: Format Python code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
ngardiner committed May 16, 2024
1 parent 5639a4d commit b4d1536
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/TWCManager/Vehicle/TeslaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def apiRefresh(self):
# on web interface. I feel this is safer than trying to log in every
# ten minutes with a bad token because Tesla might decide to block
# remote access to your car after too many authorization errors.
self.master.queue_background_task({"cmd": "saveSettings"})
self.master.queue_background_task({"cmd": "saveSettings"})
return False
except json.decoder.JSONDecodeError:
logger.log(
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def setCarApiBearerToken(self, token=None):
self.baseURL = self.regionURL["OwnerAPI"]
elif decoded.get("ou_code", "") in self.regionURL:
self.baseURL = self.regionURL[decoded["ou_code"]]

if "exp" in decoded:
self.setCarApiTokenExpireTime(int(decoded["exp"]))
else:
Expand All @@ -1155,9 +1155,13 @@ def setCarApiBearerToken(self, token=None):

def setCarApiRefreshToken(self, token):
self.carApiRefreshToken = token
if token and not self.master.tokenSyncEnabled() and (
self.getCarApiBearerToken() == ""
or self.getCarApiTokenExpireTime() - time.time() < 60 * 60
if (
token
and not self.master.tokenSyncEnabled()
and (
self.getCarApiBearerToken() == ""
or self.getCarApiTokenExpireTime() - time.time() < 60 * 60
)
):
return self.apiRefresh()
return True
Expand Down

0 comments on commit b4d1536

Please sign in to comment.