diff --git a/modules/soc_eq/auth.py b/modules/soc_eq/auth.py index b8068c177..e22aefb04 100644 --- a/modules/soc_eq/auth.py +++ b/modules/soc_eq/auth.py @@ -1,83 +1,79 @@ #!/usr/bin/python3 -import requests, json, sys, time, os, html - -#call parameters -ChargePoint = str(sys.argv[1]) -code = str(sys.argv[2]) - -#Debug = int(os.environ.get('debug')) -Debug = 0 - -moddir = '/var/www/html/openWB/modules/soc_eq/' +import requests +import json +import sys +import time +import html +from pathlib import Path + +# call parameters +charge_point = sys.argv[1][-1] # get last Character to identify the Chargepoint +code = sys.argv[2] + +# debug = int(os.environ.get('debug')) +debug = 0 +base_dir = str(Path(__file__).resolve().parents[2]) +module_dir = str(Path(__file__).resolve().parents[0]) +client_id = "" +client_secret = "" +callback = "" def printDebug(message, level): - htmlmsg = html.escape(message) - if level <= Debug: - print("

" + htmlmsg + "

") + if level <= debug: + print("

" + html.escape(message) + "

") def printHtml(message): - htmlmsg = html.escape(message) - print("

" + htmlmsg + "

") - -print("") - -client_id = "" -client_secret = "" -callback = "" - -#get last Character to identify the Chargepoint -ChargePoint = ChargePoint[-1] - -#get SoC module config from openWB cofig -fd = open('/var/www/html/openWB/openwb.conf','r') -for line in fd: - try: - printDebug("owb Conf: " + line,2 ) - (key, val) = line.rstrip().split("=") - if key == "debug": - Debug = int(val) - if key == "soc_eq_client_id_lp" + str(ChargePoint): - printDebug("Found Client ID: " + val ,1) - client_id = val - if key == "soc_eq_client_secret_lp" + str(ChargePoint): - printDebug("Found Client Secret: " + val ,1) - client_secret = val - if key == "soc_eq_cb_lp" + str(ChargePoint): - printDebug("Found callback URL: " + val ,1) - callback = val.replace("'","") - except: - - val = "" - -fd.close() - -tok_url = "https://id.mercedes-benz.com/as/token.oauth2" + print("

" + html.escape(message) + "

") + + +print("\n\n\n\n\n") + +# get SoC module config from openwb.conf +with open(base_dir + '/openwb.conf', 'r') as fd: + for line in fd: + try: + printDebug("owb Conf: " + line, 2) + (key, val) = line.rstrip().split("=") + if key == "debug": + debug = int(val) + if key == "soc_eq_client_id_lp" + str(charge_point): + printDebug("Found Client ID: " + val, 1) + client_id = val + if key == "soc_eq_client_secret_lp" + str(charge_point): + printDebug("Found Client Secret: " + val, 1) + client_secret = val + if key == "soc_eq_cb_lp" + str(charge_point): + printDebug("Found callback URL: " + val, 1) + callback = val.replace("'", "") + except Exception: + val = "" + +# tok_url = "https://id.mercedes-benz.com/as/token.oauth2" +tok_url = "https://ssoalpha.dvb.corpinter.net/v1/token" data = {'grant_type': 'authorization_code', 'code': str(code), 'redirect_uri': callback} -#call API to get Access/Refresh tokens +# call API to get Access/Refresh tokens act = requests.post(tok_url, data=data, verify=True, allow_redirects=False, auth=(client_id, client_secret)) -printDebug(act.url,1) +printDebug(act.url, 1) if act.status_code == 200: - #valid Response - toks = json.loads(act.text) - access_token = toks['access_token'] - refresh_token = toks['refresh_token'] - expires_in = int(time.time()) - - #write tokens to files + # valid Response + tokens = json.loads(act.text) + access_token = tokens['access_token'] + refresh_token = tokens['refresh_token'] + expires_in = tokens['expires_in'] - 60 + int(time.time()) - fd = open(moddir + 'soc_eq_acc_lp' + str(ChargePoint),'w') - json.dump({'expires_in' : expires_in, 'refresh_token' : refresh_token, 'access_token' : access_token}, fd) - fd.close() + # write tokens to files + with open(module_dir + '/' + 'soc_eq_acc_lp' + str(charge_point), 'w') as fd: + json.dump({'expires_in': expires_in, 'refresh_token': refresh_token, 'access_token': access_token}, fd) if act.status_code == 200: - printHtml( "Anmeldung erfolgreich!" ) - print( "Sie können das Fenster schließen." ) -else: + printHtml("Anmeldung erfolgreich!") + print("Sie können das Fenster schließen.") +else: printHtml("Anmeldung Fehlgeschlagen Code: " + str(act.status_code) + " " + act.text) -print("") +print("\n") diff --git a/modules/soc_eq/callback_lp.php b/modules/soc_eq/callback_lp.php index 53b5cc031..b54e20bea 100644 --- a/modules/soc_eq/callback_lp.php +++ b/modules/soc_eq/callback_lp.php @@ -1,7 +1,12 @@ "; diff --git a/modules/soc_eq/callback_lp1.php b/modules/soc_eq/callback_lp1.php index cd12438ea..c6ad17fa7 100644 --- a/modules/soc_eq/callback_lp1.php +++ b/modules/soc_eq/callback_lp1.php @@ -1,6 +1,14 @@ "; + echo "

" . $_GET["error"] . "

"; + echo "

" . $_GET["error_description"] . "

"; + echo ""; } ?> diff --git a/modules/soc_eq/callback_lp2.php b/modules/soc_eq/callback_lp2.php index 0ab7aba02..d0550664f 100644 --- a/modules/soc_eq/callback_lp2.php +++ b/modules/soc_eq/callback_lp2.php @@ -1,6 +1,14 @@ "; + echo "

" . $_GET["error"] . "

"; + echo "

" . $_GET["error_description"] . "

"; + echo ""; } ?> diff --git a/modules/soc_eq/main.sh b/modules/soc_eq/main.sh index dc46b656e..f2c83d06f 100644 --- a/modules/soc_eq/main.sh +++ b/modules/soc_eq/main.sh @@ -1,93 +1,91 @@ #!/bin/bash -OPENWBBASEDIR=$(cd `dirname $0`/../../ && pwd) +OPENWBBASEDIR=$(cd "$(dirname "$0")/../../" && pwd) RAMDISKDIR="$OPENWBBASEDIR/ramdisk" -MODULEDIR=$(cd `dirname $0` && pwd) +MODULEDIR=$(cd "$(dirname "$0")" && pwd) DMOD="EVSOC" MYLOGFILE="$RAMDISKDIR/soc.log" CHARGEPOINT=$1 -myPid=$$ # check if config file is already in env if [[ -z "$debug" ]]; then echo "soc_eq: Seems like openwb.conf is not loaded. Reading file." # try to load config - . $OPENWBBASEDIR/loadconfig.sh + . "$OPENWBBASEDIR/loadconfig.sh" # load helperFunctions - . $OPENWBBASEDIR/helperFunctions.sh + . "$OPENWBBASEDIR/helperFunctions.sh" fi socDebug=$debug -# for developement only +# for development only #socDebug=1 - case $CHARGEPOINT in +2) + # second charge point + ladeleistungfile="$RAMDISKDIR/llaktuells1" + soctimerfile="$RAMDISKDIR/soctimer1" + soc_file="$RAMDISKDIR/soc1" + soc_eq_client_id=$soc_eq_client_id_lp2 + soc_eq_client_secret=$soc_eq_client_secret_lp2 + soc_eq_vin=$soc_eq_vin_lp2 + ;; +*) + # defaults to first charge point for backward compatibility + # set CHARGEPOINT in case it is empty (needed for logging) + CHARGEPOINT=1 + ladeleistungfile="$RAMDISKDIR/llaktuell" + soctimerfile="$RAMDISKDIR/soctimer" + soc_file="$RAMDISKDIR/soc" + soc_eq_client_id=$soc_eq_client_id_lp1 + soc_eq_client_secret=$soc_eq_client_secret_lp1 + soc_eq_vin=$soc_eq_vin_lp1 + ;; +esac + +incrementTimer() { + case $dspeed in + 1) + # Regelgeschwindigkeit 10 Sekunden + ticksize=1 + ;; 2) - # second charge point - ladeleistungfile="$RAMDISKDIR/llaktuells1" - soctimerfile="$RAMDISKDIR/soctimer1" - soc_file="$RAMDISKDIR/soc1" - soc_eq_client_id=$soc_eq_client_id_lp2 - soc_eq_client_secret=$soc_eq_client_secret_lp2 - soc_eq_vin=$soc_eq_vin_lp2 + # Regelgeschwindigkeit 20 Sekunden + ticksize=2 + ;; + 3) + # Regelgeschwindigkeit 60 Sekunden + ticksize=1 ;; *) - # defaults to first charge point for backward compatibility - # set CHARGEPOINT in case it is empty (needed for logging) - CHARGEPOINT=1 - ladeleistungfile="$RAMDISKDIR/llaktuell" - soctimerfile="$RAMDISKDIR/soctimer" - soc_file="$RAMDISKDIR/soc" - soc_eq_client_id=$soc_eq_client_id_lp1 - soc_eq_client_secret=$soc_eq_client_secret_lp1 - soc_eq_vin=$soc_eq_vin_lp1 + # Regelgeschwindigkeit unbekannt + ticksize=1 ;; -esac - -incrementTimer(){ - case $dspeed in - 1) - # Regelgeschwindigkeit 10 Sekunden - ticksize=1 - ;; - 2) - # Regelgeschwindigkeit 20 Sekunden - ticksize=2 - ;; - 3) - # Regelgeschwindigkeit 60 Sekunden - ticksize=1 - ;; - *) - # Regelgeschwindigkeit unbekannt - ticksize=1 - ;; esac - soctimer=$((soctimer+$ticksize)) - echo $soctimer > $soctimerfile + soctimer=$((soctimer + ticksize)) + echo $soctimer >"$soctimerfile" } -soctimer=$(<$soctimerfile) -ladeleistung=$(<$ladeleistungfile) +soctimer=$(<"$soctimerfile") +ladeleistung=$(<"$ladeleistungfile") -if (( ladeleistung > 500 ));then - tmpintervall=$(( 5 * 6 )) +if ((ladeleistung > 500)); then + tmpintervall=$((5 * 6)) else - tmpintervall=$(( 60 * 6 )) + tmpintervall=$((60 * 6)) fi -if (( socDebug > 0 )); then - tmpintervall=6 +if ((socDebug > 0)); then + tmpintervall=12 fi -if (( soctimer < tmpintervall )); then - openwbDebugLog ${DMOD} 1 "Lp$CHARGEPOINT: Nothing to do yet. Incrementing timer. ${soctimer} < ${tmpintervall}" +if ((soctimer < tmpintervall)); then + openwbDebugLog "$DMOD" 1 "Lp$CHARGEPOINT: Nothing to do yet. Incrementing timer. $soctimer < $tmpintervall" incrementTimer else - openwbDebugLog ${DMOD} 1 "Lp$CHARGEPOINT: Requesting SoC" - echo 0 > $soctimerfile - $MODULEDIR/soc.py $soc_eq_client_id $soc_eq_client_secret $soc_eq_vin $soc_file $CHARGEPOINT >>$MYLOGFILE 2>&1 + openwbDebugLog "$DMOD" 1 "Lp$CHARGEPOINT: Requesting SoC" + echo 0 >"$soctimerfile" + "$MODULEDIR/soc.py" "$soc_eq_client_id" "$soc_eq_client_secret" "$soc_eq_vin" "$soc_file" "$CHARGEPOINT" >>"$MYLOGFILE" 2>&1 ret=$? - openwbDebugLog ${DMOD} 1 "Lp$CHARGEPOINT: Py Return: ${ret}" - openwbModulePublishState "EVSOC" "${ret}" "Code: ${ret}" "$CHARGEPOINT" + openwbDebugLog "$DMOD" 1 "Lp$CHARGEPOINT: Py Return: $ret" + openwbModulePublishState "EVSOC" "$ret" "Code: $ret" "$CHARGEPOINT" fi diff --git a/modules/soc_eq/soc.py b/modules/soc_eq/soc.py index 1bef88923..0b7234c70 100644 --- a/modules/soc_eq/soc.py +++ b/modules/soc_eq/soc.py @@ -1,197 +1,199 @@ #!/usr/bin/python3 -import os, requests, json, time, sys, os +import os +import requests +import json +import time +import sys from datetime import datetime, timezone +from pathlib import Path from requests.exceptions import Timeout, RequestException from json import JSONDecodeError -ramdiskdir = '/var/www/html/openWB/ramdisk/' -moduledir = '/var/www/html/openWB/modules/soc_eq/' +ramdisk_dir = str(Path(__file__).resolve().parents[2] / "ramdisk") +module_dir = str(Path(__file__).resolve().parents[0]) -req_timeout=(30,30) #timeout for requests in seconds +req_timeout = (30, 30) # timeout for requests in seconds -client_id = str(sys.argv[1]) +client_id = str(sys.argv[1]) client_secret = str(sys.argv[2]) -VIN = str(sys.argv[3]) -soc_file = str(sys.argv[4]) -ChargePoint = str(sys.argv[5]) +VIN = str(sys.argv[3]) +soc_file = str(sys.argv[4]) +charge_point = str(sys.argv[5]) -Debug = int(os.environ.get('debug')) -myPid = str(os.getpid()) - -tok_url = "https://id.mercedes-benz.com/as/token.oauth2" -soc_url = "https://api.mercedes-benz.com/vehicledata/v2/vehicles/"+VIN+"/containers/electricvehicle" +debug = int(os.environ.get('debug')) +my_pid = str(os.getpid()) +tok_url = "https://ssoalpha.dvb.corpinter.net/v1/token" +soc_url = "https://api.mercedes-benz.com/vehicledata/v2/vehicles/"+VIN+"/containers/electricvehicle" soc = None range = None + def socDebugLog(message): - local_time = datetime.now(timezone.utc).astimezone() - print(local_time.strftime(format = "%Y-%m-%d %H:%M:%S") +": Lp" +ChargePoint + ": PID:"+ myPid + ": " + message) + local_time = datetime.now(timezone.utc).astimezone() + print(local_time.strftime(format="%Y-%m-%d %H:%M:%S") + ": Lp" + charge_point + ": PID:" + my_pid + ": " + message) -def handleResponse(what, status_code, text): - if status_code == 204: - # this is not an error code. Nothing to fetch so nothing to update and no reason to exit(1) - socDebugLog(what + " Request Code: " + str(status_code) + " (no data is available for the resource)") - socDebugLog(text) - elif status_code == 400: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Bad Request)") - socDebugLog(text) - exit(1) - elif status_code == 401: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Invalid or missing authorization in header)") - socDebugLog(text) - exit(1) - elif status_code == 402: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Payment required)") - socDebugLog(text) - exit(1) - elif status_code == 403: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Forbidden)") - socDebugLog(text) - exit(1) - elif status_code == 404: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (The requested resource was not found, e.g.: the selected vehicle could not be found)") - socDebugLog(text) - exit(1) - elif status_code == 429: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (The service received too many requests in a given amount of time)") - socDebugLog(text) - exit(1) - elif status_code == 500: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (The service received too many requests in a given amount of time)") - socDebugLog(text) - exit(1) - elif status_code == 503: - socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (The server is unable to service the request due to a temporary unavailability condition)") - socDebugLog(text) - exit(1) - else: - socDebugLog(what + " Request fehlgeschlagen unbekannter Code: " + str(status_code)) - socDebugLog(text) - exit(1) - -if Debug >= 1: - socDebugLog("Debug Level: " + str(Debug)) -if Debug >= 1: - socDebugLog("client: " + client_id) - - -if Debug >= 2: - socDebugLog("SOC URL: " + soc_url) - -#Get Access token from file - -fd = open(moduledir + 'soc_eq_acc_lp' + str(ChargePoint),'r') -try: - tok = json.load(fd) - access_token = tok['access_token'] -except ValueError: - socDebugLog("ERROR: Access Token not found. Please use Link 'HIER bei Mercedes Me' anmelden in LP Configuration") - exit(3) -refresh_token = tok['refresh_token'] -expires_in = tok['expires_in'] -fd.close() -#socDebugLog("Expire in: " str((int(expires_in)-int(time.time()))) +def handleResponse(what, status_code, text): + if status_code == 204: + # this is not an error code. Nothing to fetch so nothing to update and no reason to exit(1) + socDebugLog(what + " Request Code: " + str(status_code) + " (no data is available for the resource)") + socDebugLog(text) + elif status_code == 400: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Bad Request)") + socDebugLog(text) + exit(1) + elif status_code == 401: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + + " (Invalid or missing authorization in header)") + socDebugLog(text) + exit(1) + elif status_code == 402: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Payment required)") + socDebugLog(text) + exit(1) + elif status_code == 403: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + " (Forbidden)") + socDebugLog(text) + exit(1) + elif status_code == 404: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + + " (The requested resource was not found, e.g.: the selected vehicle could not be found)") + socDebugLog(text) + exit(1) + elif status_code == 429: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + + " (The service received too many requests in a given amount of time)") + socDebugLog(text) + exit(1) + elif status_code == 500: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + + " (The service received too many requests in a given amount of time)") + socDebugLog(text) + exit(1) + elif status_code == 503: + socDebugLog(what + " Request fehlgeschlagen Code: " + str(status_code) + + " (The server is unable to service the request due to a temporary unavailability condition)") + socDebugLog(text) + exit(1) + else: + socDebugLog(what + " Request fehlgeschlagen unbekannter Code: " + str(status_code)) + socDebugLog(text) + exit(1) + + +if debug >= 1: + socDebugLog("Debug Level: " + str(debug)) +if debug >= 1: + socDebugLog("client: " + client_id) + + +if debug >= 2: + socDebugLog("SOC URL: " + soc_url) + +# Get Access token from file +with open(module_dir + "/" + 'soc_eq_acc_lp' + str(charge_point), 'r') as fd: + try: + tok = json.load(fd) + access_token = tok['access_token'] + except ValueError: + socDebugLog( + "ERROR: Access Token not found. Please use Link 'HIER bei Mercedes Me' anmelden in LP Configuration" + ) + exit(3) + refresh_token = tok['refresh_token'] + expires_in = tok['expires_in'] + +socDebugLog("Token expires in: " + str((int(expires_in)-int(time.time())))+"s") if int(expires_in) < int(time.time()): - #Access Token is exired - if Debug >= 1: - socDebugLog("Acc Token Expired") - - #get new Access Token with referesh token - data = {'grant_type': 'refresh_token', 'refresh_token': refresh_token } - ref = requests.post(tok_url, data=data, verify=True, allow_redirects=False, auth=(client_id, client_secret), timeout=req_timeout) - if Debug >= 1: - socDebugLog("Refresh Token Call:" + str(ref.status_code)) - socDebugLog("Refresh Token Text:" + str(ref.text)) - - - #write HTTP reponse code to file - try: - fd = open(ramdiskdir + 'soc_eq_lastresp','w') - fd.write(str(ref.status_code)) - fd.close() - except: - fd.close() - - - if ref.status_code == 200: - #valid response - tok = json.loads(ref.text) - - access_token = tok['access_token'] - refresh_token = tok['refresh_token'] - expires_in = tok['expires_in'] - 60 + int(time.time()) - - #write new tokens - - fd = open(moduledir + 'soc_eq_acc_lp' + str(ChargePoint),'w') - json.dump({'expires_in' : expires_in, 'refresh_token' : refresh_token, 'access_token' : access_token}, fd) - fd.close() - else: - handleResponse("Refresh",ref.status_code,ref.text) - -#call API for SoC + # Access Token is expired + if debug >= 1: + socDebugLog("Acc Token Expired") + + # get new Access Token with refresh token + data = {'grant_type': 'refresh_token', 'refresh_token': refresh_token} + ref = requests.post(tok_url, data=data, verify=True, allow_redirects=False, + auth=(client_id, client_secret), timeout=req_timeout) + if debug >= 1: + socDebugLog("Refresh Token Call:" + str(ref.status_code)) + socDebugLog("Refresh Token Text:" + str(ref.text)) + + # write HTTP response code to file + with open(ramdisk_dir + '/' + 'soc_eq_lastresp', 'w') as fd: + fd.write(str(ref.status_code)) + + if ref.status_code == 200: + # valid response + tokens = json.loads(ref.text) + + access_token = tokens['access_token'] + refresh_token = tokens['refresh_token'] + expires_in = tokens['expires_in'] - 60 + int(time.time()) + id_token = tokens['id_token'] + token_type = tokens['token_type'] + + # write new tokens + with open(module_dir + '/' + 'soc_eq_acc_lp' + str(charge_point), 'w') as fd: + json.dump({'expires_in': expires_in, 'refresh_token': refresh_token, + 'access_token': access_token, 'id_token': id_token, 'token_type': token_type}, fd) + else: + handleResponse("Refresh", ref.status_code, ref.text) + +# call API for SoC header = {'authorization': 'Bearer ' + access_token} try: - req_soc = requests.get(soc_url, headers=header, verify=True) - #req_soc = requests.get(soc_url, headers=header, verify=True, timeout=req_timeout) + req_soc = requests.get(soc_url, headers=header, verify=True) + # req_soc = requests.get(soc_url, headers=header, verify=True, timeout=req_timeout) except Timeout: - socDebugLog("Soc Request Timed Out") - exit(2) + socDebugLog("Soc Request Timed Out") + exit(2) except RequestException: - socDebugLog("Soc Request Request Exception occured " + soc_url) - exit(2) + socDebugLog("Soc Request Request Exception occurred " + soc_url) + exit(2) -if Debug >= 1: - socDebugLog("SOC Request: " + str(req_soc.status_code)) - socDebugLog("SOC Response: " + req_soc.text) +if debug >= 1: + socDebugLog("SOC Request: " + str(req_soc.status_code)) + socDebugLog("SOC Response: " + req_soc.text) -#write HTTP reponse code to file -try: - fd = open(ramdiskdir + 'soc_eq_lastresp','w') - fd.write(str(req_soc.status_code)) - fd.close() -except: - fd.close() +# write HTTP response code to file +with open(ramdisk_dir + '/' + 'soc_eq_lastresp', 'w') as fd: + fd.write(str(req_soc.status_code)) if req_soc.status_code == 200: - #valid Response - try: - res = json.loads(req_soc.text) - except JSONDecodeError: - socDebugLog("Soc Response NO VALID JSON " + req_soc.text) - exit(2) - - #Extract SoC value and write to file - for entry in res: - for values in entry: - if values == "soc": - soc = entry[values]['value'] - elif values == "rangeelectric": - range = entry[values]['value'] - else: - socDebugLog("unknown entry: " + entry) - if not soc: - socDebugLog("SoC Value not filled " + req_soc.text) - soc = "0" - if not range: - socDebugLog("RangeElectric Value not filled " + req_soc.text) - range = "0" - socDebugLog("SOC: " + soc + " RANGE: " + range) - fd = open(soc_file,'w') - fd.write(str(soc)) - fd.close() - + # valid Response + try: + res = json.loads(req_soc.text) + except JSONDecodeError: + socDebugLog("Soc Response NO VALID JSON " + req_soc.text) + exit(2) + + # Extract SoC value and write to file + for entry in res: + for values in entry: + if values == "soc": + soc = entry[values]['value'] + elif values == "rangeelectric": + range = entry[values]['value'] + else: + socDebugLog("unknown entry: " + entry) + if not soc: + socDebugLog("SoC Value not filled " + req_soc.text) + soc = "0" + if not range: + socDebugLog("RangeElectric Value not filled " + req_soc.text) + range = "0" + socDebugLog("SOC: " + soc + " RANGE: " + range) + with open(soc_file, 'w') as fd: + fd.write(str(soc)) + else: - handleResponse("SoC",req_soc.status_code,req_soc.text) + handleResponse("SoC", req_soc.status_code, req_soc.text) -if Debug >= 2: - socDebugLog("SoC EQ Ende ohne Fehler") -exit(0) +if debug >= 2: + socDebugLog("SoC EQ Ende ohne Fehler")