]> git.sven.stormbind.net Git - sven/scripts.git/blobdiff - home/portalmonitor.py
Use python f-string for output formating
[sven/scripts.git] / home / portalmonitor.py
index 12a088e1e6970c7baaca183993bb02a6af82c609..1316b2f6807d50233c13f511c81767d56e040091 100755 (executable)
@@ -46,10 +46,7 @@ def getCurrentPower(userName, password, stationId):
                            'pwd': password
                        },
                        timeout=(10, 30))
-        except requests.exceptions.RequestException as e:
-            raise SystemExit(e)
 
-        try:
             r = s.post(
                 'https://www.envertecportal.com/ApiStations/getStationInfo',
                 data={
@@ -57,10 +54,7 @@ def getCurrentPower(userName, password, stationId):
                 },
                 timeout=(10, 60)).json()
             power = r['Data']['Power']
-        except requests.exceptions.RequestException as e:
-            raise SystemExit(e)
 
-        try:
             r = s.post('https://www.envertecportal.com/apiAccount/Logout',
                        timeout=(10, 30))
         except requests.exceptions.RequestException as e:
@@ -81,7 +75,7 @@ if isDaylight(conf['config'].getfloat('lat'), conf['config'].getfloat('lon'),
                                    conf['config']['stationId'])
 
     if options.printStatus:
-        print('Current Power: ' + str(currentPower))
+        print(f"Current Power: {currentPower}")
 
     if currentPower == 0:
         print('Error: Power dropped to 0 but we should have daylight!')