Skip to content

Commit

Permalink
more error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Allen committed Jul 19, 2022
1 parent e011c0f commit 8fccada
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
./__pycache
./__pycache
./testing.py
3 changes: 3 additions & 0 deletions RenphoWeight.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def getScaleUsers(self):
r = requests.get(url = 'https://renpho.qnclouds.com/api/v3/scale_users/list_scale_user?locale=en&terminal_user_session_key=' + self.session_key)
parsed = json.loads(r.text)

if not len(parsed['scale_users']):
_LOGGER.error("No users set up on scale")

self.user_id = parsed['scale_users'][0]['user_id']
return parsed['scale_users']

Expand Down
Binary file added __pycache__/RenphoWeight.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/const.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/sensor.cpython-39.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
from base64 import b64encode
import sys

key = RSA.importKey('-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+25I2upukpfQ7rIaaTZtVE744\nu2zV+HaagrUhDOTq8fMVf9yFQvEZh2/HKxFudUxP0dXUa8F6X4XmWumHdQnum3zm\nJr04fz2b2WCcN0ta/rbF2nYAnMVAk2OJVZAMudOiMWhcxV1nNJiKgTNNr13de0EQ\nIiOL2CUBzu+HmIfUbQIDAQAB\n-----END PUBLIC KEY-----')
cipher = PKCS1_v1_5.new(key)
newPassword = b64encode(cipher.encrypt(bytes(sys.argv[1])))

print(newPassword)

0 comments on commit 8fccada

Please sign in to comment.