mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[FIX] bad response from the server
This commit is contained in:
parent
be3ffce003
commit
87a3ceb983
2 changed files with 24 additions and 16 deletions
|
@ -26,7 +26,9 @@ class PortsDiagnoser(Diagnoser):
|
||||||
ports[port] = service
|
ports[port] = service
|
||||||
|
|
||||||
try:
|
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:
|
||||||
|
r = r.json()
|
||||||
if "status" not in r.keys():
|
if "status" not in r.keys():
|
||||||
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
||||||
elif r["status"] == "error":
|
elif r["status"] == "error":
|
||||||
|
@ -36,6 +38,8 @@ class PortsDiagnoser(Diagnoser):
|
||||||
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
||||||
elif r["status"] != "ok" or "ports" not in r.keys() or not isinstance(r["ports"], dict):
|
elif r["status"] != "ok" or "ports" not in r.keys() or not isinstance(r["ports"], dict):
|
||||||
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
||||||
|
else:
|
||||||
|
raise Exception("Bad response from the server https://diagnosis.yunohost.org : %s" % str(r.status_code))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise YunohostError("diagnosis_ports_could_not_diagnose", error=e)
|
raise YunohostError("diagnosis_ports_could_not_diagnose", error=e)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@ class HttpDiagnoser(Diagnoser):
|
||||||
os.system("touch /tmp/.well-known/ynh-diagnosis/%s" % nonce)
|
os.system("touch /tmp/.well-known/ynh-diagnosis/%s" % nonce)
|
||||||
|
|
||||||
try:
|
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:
|
||||||
|
r = r.json()
|
||||||
if "status" not in r.keys():
|
if "status" not in r.keys():
|
||||||
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
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_")):
|
elif r["status"] == "error" and ("code" not in r.keys() or not r["code"].startswith("error_http_check_")):
|
||||||
|
@ -36,6 +38,8 @@ class HttpDiagnoser(Diagnoser):
|
||||||
raise Exception(r["content"])
|
raise Exception(r["content"])
|
||||||
else:
|
else:
|
||||||
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
|
||||||
|
else:
|
||||||
|
raise Exception("Bad response from the server https://diagnosis.yunohost.org : %s" % str(r.status_code))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise YunohostError("diagnosis_http_could_not_diagnose", error=e)
|
raise YunohostError("diagnosis_http_could_not_diagnose", error=e)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue