exception added

This commit is contained in:
2020-06-06 11:18:56 +08:00
parent 7e83a2144c
commit 7e9d5d9c58
+5 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python
import httplib2
import socket, httplib, httplib2
import sys
URL = "http://"+sys.argv[1]+"/cgi-bin/reboot.cgi"
@@ -10,6 +10,7 @@ PASS = sys.argv[3]
h = httplib2.Http(cache=None, timeout=0.2)
h.add_credentials(USER, PASS)
try:
response, content = h.request(URL, "GET", headers={'cache-control':'no-cache'})
if response.status==401:
@@ -17,4 +18,6 @@ try:
elif response.status==404:
print "Wrong Request Address"
except httplib2.ServerNotFoundError:
print "HOST is Down"
print "HOST is Down"
except (socket.timeout, socket.error, httplib2.HttpLib2Error, httplib.ResponseNotReady):
print "ERROR"