133
133
sys .exit (4 )
134
134
135
135
__author__ = 'Hari Sekhon'
136
- __version__ = '0.7.0 '
136
+ __version__ = '0.7.1 '
137
137
138
138
139
139
class FindActiveServer (CLI ):
@@ -190,7 +190,6 @@ def add_common_opts(self):
190
190
'(for use with --num-threads=1)' )
191
191
192
192
def process_options (self ):
193
- self .validate_common_opts ()
194
193
self .url_path = self .get_opt ('url' )
195
194
self .regex = self .get_opt ('regex' )
196
195
if self .get_opt ('https' ):
@@ -215,6 +214,7 @@ def process_options(self):
215
214
self .protocol = 'http'
216
215
elif self .protocol == 'ping' :
217
216
self .usage ('cannot specify --url-path with --ping, mutually exclusive options!' )
217
+ self .validate_common_opts ()
218
218
219
219
def validate_common_opts (self ):
220
220
hosts = self .get_opt ('host' )
@@ -237,6 +237,7 @@ def validate_common_opts(self):
237
237
238
238
self .num_threads = self .get_opt ('num_threads' )
239
239
validate_int (self .num_threads , 'num threads' , 1 , 100 )
240
+ self .num_threads = int (self .num_threads )
240
241
241
242
self .request_timeout = self .get_opt ('request_timeout' )
242
243
validate_int (self .request_timeout , 'request timeout' , 1 , 60 )
@@ -388,13 +389,16 @@ def check_http(self, host, port, url_path=''):
388
389
try :
389
390
# timeout here isn't total timeout, it's response time
390
391
req = requests .get (url , timeout = self .request_timeout )
391
- except requests .exceptions .RequestException :
392
+ except requests .exceptions .RequestException as _ :
393
+ log .info ('%s - returned exception: %s' , url , _ )
392
394
return False
393
- except IOError :
395
+ except IOError as _ :
396
+ log .info ('%s - returned IOError: %s' , url , _ )
394
397
return False
395
398
log .debug ("%s - response: %s %s" , url , req .status_code , req .reason )
396
399
log .debug ("%s - content:\n %s\n %s\n %s" , url , '=' * 80 , req .content .strip (), '=' * 80 )
397
400
if req .status_code != 200 :
401
+ log .info ('%s - status code %s != 200' , url , req .status_code )
398
402
return None
399
403
if self .regex :
400
404
log .info ('%s - checking regex against content' , url )
0 commit comments