Merge branch 'fix-diagnosis-server-bad-response' into stretch-unstable

This commit is contained in:
Alexandre Aubin 2020-03-22 01:46:06 +01:00
commit de879e1d30
2 changed files with 8 additions and 2 deletions

View file

@ -27,7 +27,10 @@ class PortsDiagnoser(Diagnoser):
ports[port] = service
try:
r = requests.post('https://diagnosis.yunohost.org/check-ports', json={'ports': ports.keys()}, timeout=30).json()
r = requests.post('https://diagnosis.yunohost.org/check-ports', json={'ports': ports.keys()}, timeout=30)
if r.status_code != 200:
raise Exception("Bad response from the server https://diagnosis.yunohost.org/check-ports : %s - %s" % (str(r.status_code), r.content))
r = r.json()
if "status" not in r.keys():
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
elif r["status"] == "error":

View file

@ -28,7 +28,10 @@ class WebDiagnoser(Diagnoser):
os.system("touch /tmp/.well-known/ynh-diagnosis/%s" % nonce)
try:
r = requests.post('https://diagnosis.yunohost.org/check-http', json={'domain': domain, "nonce": nonce}, timeout=30).json()
r = requests.post('https://diagnosis.yunohost.org/check-http', json={'domain': domain, "nonce": nonce}, timeout=30)
if r.status_code != 200:
raise Exception("Bad response from the server https://diagnosis.yunohost.org/check-http : %s - %s" % (str(r.status_code), r.content))
r = r.json()
if "status" not in r.keys():
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
elif r["status"] == "error" and ("code" not in r.keys() or not r["code"].startswith("error_http_check_")):