|
84 | 84 | sys.exit(4)
|
85 | 85 |
|
86 | 86 | __author__ = 'Hari Sekhon'
|
87 |
| -__version__ = '0.3.3' |
| 87 | +__version__ = '0.4' |
88 | 88 |
|
89 | 89 |
|
90 | 90 | class FindActiveServer(CLI):
|
@@ -120,6 +120,8 @@ def add_options(self):
|
120 | 120 | 'use -n=1 for deterministic host preference order [slower])')
|
121 | 121 | self.add_opt('-R', '--random', action='store_true', help='Randomize order of hosts tested ' +
|
122 | 122 | '(for use with --num-threads=1)')
|
| 123 | + self.add_opt('-q', '--quiet', action='store_true', help='Returns no output instead of NO_AVAILABLE_SERVER '\ |
| 124 | + + '(convenience for scripting)') |
123 | 125 | self.add_opt('-T', '--request-timeout', metavar='secs', type='int',
|
124 | 126 | help='Timeout for each individual server request in seconds (default: 1 second)')
|
125 | 127 |
|
@@ -197,7 +199,7 @@ def run(self):
|
197 | 199 | # self.finish(host, port)
|
198 | 200 | self.launch_thread(self.check_socket, host, port)
|
199 | 201 | self.collect_results()
|
200 |
| - if self.verbose: |
| 202 | + if not self.get_opt('quiet'): |
201 | 203 | print('NO_AVAILABLE_SERVER')
|
202 | 204 | sys.exit(1)
|
203 | 205 |
|
@@ -289,9 +291,9 @@ def check_http(self, host, port, url_path=''):
|
289 | 291 | if not isStr(url_path):
|
290 | 292 | url_path = ''
|
291 | 293 | url = '{protocol}://{host}:{port}/{url_path}'.format(protocol=self.protocol,
|
292 |
| - host=host, |
293 |
| - port=port, |
294 |
| - url_path=url_path.lstrip('/')) |
| 294 | + host=host, |
| 295 | + port=port, |
| 296 | + url_path=url_path.lstrip('/')) |
295 | 297 | log.info('GET %s', url)
|
296 | 298 | try:
|
297 | 299 | # timeout here isn't total timeout, it's response time
|
|
0 commit comments