Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored Mar 5, 2024
1 parent c57b6d9 commit 669e9ea
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def encrypt_password(public_key_str, password):
try:
rsa_key = RSA.importKey(public_key_str)
cipher = PKCS1_v1_5.new(rsa_key)
return b64encode(cipher.encrypt(password.encode("utf-8"))).decode("utf-8")
return b64encode(cipher.encrypt(password.encode("utf-8")))
except Exception as e:
_LOGGER.error(f"Encryption error: {e}")
raise
Expand Down Expand Up @@ -612,7 +612,7 @@ async def auth(self):
self.auth_in_progress = False
await session.close()

async def get_scale_users(self) -> List[Users]:
async def get_scale_users(self):
"""
Fetch the list of users associated with the scale.
"""
Expand Down Expand Up @@ -676,7 +676,7 @@ async def get_measurements(self):
_LOGGER.error(f"Failed to fetch weight measurements: {e}")
return None

async def get_weight(self) -> Union[float, None]:
async def get_weight(self):
if self.weight and self.weight_info:
return self.weight, self.weight_info
self._last_updated_weight = time.time()
Expand All @@ -686,7 +686,7 @@ async def get_info(self):
self._last_updated_weight = time.time()
return await self.get_measurements()

async def get_device_info(self) -> Optional[List[DeviceBind]]:
async def get_device_info(self):
"""
Fetch device information and update the class attribute with device bind details.
"""
Expand Down Expand Up @@ -736,7 +736,7 @@ async def list_latest_model(self):
_LOGGER.error(f"Failed to fetch latest model: {e}")
return None

async def list_girth(self) -> Optional[dict]:
async def list_girth(self):
url = f"{GIRTH_URL}?user_id={self.user_id}&last_updated_at={self.get_timestamp()}&locale=en&app_id=Renpho&terminal_user_session_key={self.session_key}"
try:
parsed = await self._request("GET", url, skip_auth=True)
Expand Down Expand Up @@ -1240,4 +1240,4 @@ async def message_list(request: Request, renpho: RenphoWeight = Depends(get_curr
except Exception as e:
await renpho.close()
_LOGGER.error(f"Error fetching message list: {e}")
return APIResponse(status="error", message=str(e))
return APIResponse(status="error", message=str(e))

0 comments on commit 669e9ea

Please sign in to comment.