From c0453b3302454d10be2a705276c8caa503d77128 Mon Sep 17 00:00:00 2001 From: Shubham Mittal <98mittalshubham@gmail.com> Date: Fri, 16 Jun 2023 23:10:05 +0530 Subject: [PATCH 1/2] Change api to get ip address from ipify to amazonaws. The ipify api is considerably slow and takes more than 30 seconds. The amazonaws ip endpoint is very fast in comparison and is already used by the java version of smart connect. --- SmartApi/smartConnect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartApi/smartConnect.py b/SmartApi/smartConnect.py index 272633fc..85851412 100644 --- a/SmartApi/smartConnect.py +++ b/SmartApi/smartConnect.py @@ -55,7 +55,7 @@ class SmartConnect(object): try: - clientPublicIp= " " + get('https://api.ipify.org').text + clientPublicIp= " " + get('https://checkip.amazonaws.com').text if " " in clientPublicIp: clientPublicIp=clientPublicIp.replace(" ","") hostname = socket.gethostname() From 170fb3ee647586c3648dca4e35d8118c8b027f9e Mon Sep 17 00:00:00 2001 From: Shubham Mittal <98mittalshubham@gmail.com> Date: Mon, 19 Jun 2023 08:15:16 +0530 Subject: [PATCH 2/2] Better error handling for login --- .gitignore | 3 ++- SmartApi/smartConnect.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0b843705..22ca50b2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .idea/smartapi-python.iml build/* smartapi_python.egg-info -dist/* \ No newline at end of file +dist/* +.vscode/* diff --git a/SmartApi/smartConnect.py b/SmartApi/smartConnect.py index 85851412..527b04f7 100644 --- a/SmartApi/smartConnect.py +++ b/SmartApi/smartConnect.py @@ -245,7 +245,8 @@ def generateSession(self,clientCode,password,totp): return user else: - return loginResultObject + raise Exception(loginResultObject) + def terminateSession(self,clientCode): logoutResponseObject=self._postRequest("api.logout",{"clientcode":clientCode}) return logoutResponseObject