|
32 | 32 | import types |
33 | 33 | import urllib |
34 | 34 | import urllib2 |
35 | | - from urllib2 import urlopen, HTTPError |
| 35 | + from urllib2 import urlopen, HTTPError, URLError |
36 | 36 |
|
37 | 37 | except ImportError, e: |
38 | 38 | print "Import error in %s : %s" % (__name__, e) |
@@ -80,18 +80,19 @@ def make_request(command, args, logger, host, port, |
80 | 80 | response = connection.read() |
81 | 81 | except HTTPError, e: |
82 | 82 | error = "%s: %s" % (e.msg, e.info().getheader('X-Description')) |
| 83 | + except URLError, e: |
| 84 | + error = e.reason |
83 | 85 |
|
84 | 86 | logger_debug(logger, "Response received: %s" % response) |
85 | 87 | if error is not None: |
86 | | - logger_debug(logger, "Error: error is not None, %s" % (error)) |
| 88 | + logger_debug(logger, "Error: %s" % (error)) |
87 | 89 | return response, error |
88 | 90 |
|
89 | 91 | return response, error |
90 | 92 |
|
91 | 93 |
|
92 | 94 | def monkeyrequest(command, args, isasync, asyncblock, logger, host, port, |
93 | 95 | apikey, secretkey, timeout, protocol, path): |
94 | | - fcommand = command |
95 | 96 | response = None |
96 | 97 | error = None |
97 | 98 | logger_debug(logger, "======== START Request ========") |
@@ -133,9 +134,7 @@ def process_json(response): |
133 | 134 | timeout = timeout - pollperiod |
134 | 135 | logger_debug(logger, "Job %s to timeout in %ds" % (jobid, timeout)) |
135 | 136 | sys.stdout.flush() |
136 | | - if re.match("queryAsyncJobResult", fcommand): |
137 | | - # logger_debug(logger, "%d loop: Job %s" % (progress, jobid)) |
138 | | - # sys.stdout.flush() |
| 137 | + if re.match("queryAsyncJobResult", command): |
139 | 138 | time.sleep(pollperiod) |
140 | 139 | else: |
141 | 140 | response, error = monkeyrequest(command, request, isasync, |
|
0 commit comments