From f347e504105fc9e2e88adc9e2d4d8df27996e686 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Tue, 19 Jan 2016 13:35:19 -0500 Subject: [PATCH 1/2] don't print 404 errors for slaves where directory isn't available --- scripts/logfetch/live_logs.py | 4 ++-- scripts/logfetch/singularity_request.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/logfetch/live_logs.py b/scripts/logfetch/live_logs.py index bc65cf4b7b..e8338036a2 100644 --- a/scripts/logfetch/live_logs.py +++ b/scripts/logfetch/live_logs.py @@ -97,11 +97,11 @@ def task_still_running(args, task, history): def files_json(args, task): uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task) - return get_json_response(uri, args) + return get_json_response(uri, args, {}, True) def logs_folder_files(args, task): uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task) - files_json = get_json_response(uri, args, {'path' : '{0}/logs'.format(task)}) + files_json = get_json_response(uri, args, {'path' : '{0}/logs'.format(task)}, True) if 'files' in files_json: files = files_json['files'] return [f['name'] for f in files if logfetch_base.is_in_date_range(args, f['mtime'])] diff --git a/scripts/logfetch/singularity_request.py b/scripts/logfetch/singularity_request.py index 5d26cae71a..a3d1fc1d98 100644 --- a/scripts/logfetch/singularity_request.py +++ b/scripts/logfetch/singularity_request.py @@ -4,13 +4,14 @@ ERROR_STATUS_FORMAT = 'Singularity responded with an invalid status code ({0})' -def get_json_response(uri, args, params={}): +def get_json_response(uri, args, params={}, skip404ErrMessage=False): singularity_response = requests.get(uri, params=params, headers=args.headers) if singularity_response.status_code < 199 or singularity_response.status_code > 299: - if not args.silent: + if not args.silent and not (skip404ErrMessage and singularity_response.status_code == 404): sys.stderr.write('{0} params:{1}\n'.format(uri, str(params))) - sys.stderr.write(colored(ERROR_STATUS_FORMAT.format(singularity_response.status_code), 'red') + '\n') - if not args.silent: + if not (skip404ErrMessage and singularity_response.status_code == 404): + sys.stderr.write(colored(ERROR_STATUS_FORMAT.format(singularity_response.status_code), 'red') + '\n') + if not args.silent and not (skip404ErrMessage and singularity_response.status_code == 404): sys.stderr.write(colored(singularity_response.text, 'red') + '\n') return {} return singularity_response.json() From 907213dfb51f558677db3cc0fa497b5eddb4c8f0 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Tue, 19 Jan 2016 13:42:55 -0500 Subject: [PATCH 2/2] bump version --- scripts/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup.py b/scripts/setup.py index 8dac215c8d..8480eb89b3 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -11,7 +11,7 @@ setup( name='singularity-logfetch', - version='0.22.0', + version='0.22.1', description='Singularity log fetching and searching', author="HubSpot", author_email='singularity-users@googlegroups.com',