From 7e9d5d9c58847bcd43417f7e0e1e37b607ddfd3d Mon Sep 17 00:00:00 2001 From: 3err0 Date: Sat, 6 Jun 2020 11:18:56 +0800 Subject: [PATCH] exception added --- rebootasic | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rebootasic b/rebootasic index 54105e9..17c9d6d 100755 --- a/rebootasic +++ b/rebootasic @@ -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" \ No newline at end of file + print "HOST is Down" +except (socket.timeout, socket.error, httplib2.HttpLib2Error, httplib.ResponseNotReady): + print "ERROR" \ No newline at end of file