From 7e83a2144c4bfde4fb126d21297ff68f4995da07 Mon Sep 17 00:00:00 2001 From: 3err0 Date: Sat, 6 Jun 2020 10:58:08 +0800 Subject: [PATCH] added status codes --- rebootasic | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rebootasic b/rebootasic index 8f74851..54105e9 100755 --- a/rebootasic +++ b/rebootasic @@ -7,11 +7,14 @@ URL = "http://"+sys.argv[1]+"/cgi-bin/reboot.cgi" USER = sys.argv[2] PASS = sys.argv[3] -h = httplib2.Http(cache=None, timeout=0.1) +h = httplib2.Http(cache=None, timeout=0.2) h.add_credentials(USER, PASS) + try: - resp = h.request(URL, "GET", headers={'cache-control':'no-cache'}) - resp - print"OK" -except: - print"Asic not avalible" \ No newline at end of file + response, content = h.request(URL, "GET", headers={'cache-control':'no-cache'}) + if response.status==401: + print "Unauthorized, Wrong PASSWORD" + elif response.status==404: + print "Wrong Request Address" +except httplib2.ServerNotFoundError: + print "HOST is Down" \ No newline at end of file