New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOC-Modul Renault #638
SOC-Modul Renault #638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der Umstieg von der Urllib auf Requests bietet einige Vorteile:
Requests bietet ein Highlevel Client Interface. Dadurch ist es leichter zu lesen und anzuwenden. Außerdem benutzt Requests den Python-Logger. Über Session-Hooks werden die Http-Antworten automatisch geloggt.
Der Code wird dadurch um einiges kürzer und verständlicher.
payload = {'country': country} | ||
data = urllib.parse.urlencode(payload) | ||
data = data.encode('Big5') | ||
reg = urllib.request.Request(kamereonrooturl + '/commerce/v1/accounts/' + | ||
kamereonaccountid + '/vehicles?' + data.decode("utf-8")) | ||
reg.add_header('x-gigya-id_token', gigya_jwttoken) | ||
reg.add_header('apikey', kamereonapikey) | ||
dmp = {} | ||
dmp['payload'] = str(payload) | ||
dmp['data'] = data.decode("utf-8") | ||
dmp['reg'] = str(reg) | ||
dump_json(dmp, "soc_renault_7_request_vh" + str(vehicle)) | ||
response = urllib.request.urlopen(reg) | ||
responsetext = response.read() | ||
vehic = json.loads(responsetext) | ||
dmp = {} | ||
dmp['response'] = str(response) | ||
dmp['responsetext'] = str(responsetext) | ||
dmp['vehic'] = str(vehic) | ||
dump_json(dmp, "soc_renault_7_reply_vh" + str(vehicle)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payload = {'country': country} | |
data = urllib.parse.urlencode(payload) | |
data = data.encode('Big5') | |
reg = urllib.request.Request(kamereonrooturl + '/commerce/v1/accounts/' + | |
kamereonaccountid + '/vehicles?' + data.decode("utf-8")) | |
reg.add_header('x-gigya-id_token', gigya_jwttoken) | |
reg.add_header('apikey', kamereonapikey) | |
dmp = {} | |
dmp['payload'] = str(payload) | |
dmp['data'] = data.decode("utf-8") | |
dmp['reg'] = str(reg) | |
dump_json(dmp, "soc_renault_7_request_vh" + str(vehicle)) | |
response = urllib.request.urlopen(reg) | |
responsetext = response.read() | |
vehic = json.loads(responsetext) | |
dmp = {} | |
dmp['response'] = str(response) | |
dmp['responsetext'] = str(responsetext) | |
dmp['vehic'] = str(vehic) | |
dump_json(dmp, "soc_renault_7_reply_vh" + str(vehicle)) | |
payload = {'country': country} | |
vehic=req.get_http_session().post(f"{kamereonrooturl}/commerce/v1/accounts/{kamereonaccountid}/vehicles", headers={'x-gigya-id_token': gigya_jwttoken, | |
'apikey': kamereonapikey}, data=json.dumps(payload)).json() |
Der Request sieht dann so aus (ich kann es nicht testen, evtl muss zum Post noch ein verify=False
hinzu)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Die Änderung ist bestimmt sinnvoll. und ich würde es übernehmen, wenn ich könnte.
Ich kann es aber leider nicht mehr testen;
Jarry hatte mich gebeten den Renault-Modul zu migrieren und dazu seinen myRenault-Account nach Passwort-Änderung geteilt.
Nachdem es lief, ist das Passwort wieder geändert.
Solche substantiellen Änderungen sollte auch jemand machen, der dauerhaften Zugriff auf den entsprechende Fahrzeug-Account hat.
Also erst mal "as-is" mergen oder es bleibt hat ein PR bis sich jemand findet.
Bitte auch auf empfohlene Namenskonventionen achten. |
Jarry hat mir freundlicherweise seine Account-Daten zur Verfügung gestellt, ich arbeite aktuell an der Umstellung auf das requests-Modul. |
Vielen Dank, Lena. |
In PR #689 enthalten |
SOC Modul for Renault vehicles.
tested with Zoe account - SOC Update works.
Wakeup part not migrated - not sure what that exactly does.