added status codes
This commit is contained in:
+9
-6
@@ -7,11 +7,14 @@ URL = "http://"+sys.argv[1]+"/cgi-bin/reboot.cgi"
|
|||||||
USER = sys.argv[2]
|
USER = sys.argv[2]
|
||||||
PASS = sys.argv[3]
|
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)
|
h.add_credentials(USER, PASS)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = h.request(URL, "GET", headers={'cache-control':'no-cache'})
|
response, content = h.request(URL, "GET", headers={'cache-control':'no-cache'})
|
||||||
resp
|
if response.status==401:
|
||||||
print"OK"
|
print "Unauthorized, Wrong PASSWORD"
|
||||||
except:
|
elif response.status==404:
|
||||||
print"Asic not avalible"
|
print "Wrong Request Address"
|
||||||
|
except httplib2.ServerNotFoundError:
|
||||||
|
print "HOST is Down"
|
||||||
Reference in New Issue
Block a user