From 73e552815a106863eedd2701a24adc6b7a018134 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Wed, 28 Jan 2015 17:24:56 -0500 Subject: [PATCH] error handling for gzip errors --- scripts/logfetch/logfetch_base.py | 22 +++++++++++++--------- scripts/setup.py | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/logfetch/logfetch_base.py b/scripts/logfetch/logfetch_base.py index 4aef537689..d4af0e9da4 100644 --- a/scripts/logfetch/logfetch_base.py +++ b/scripts/logfetch/logfetch_base.py @@ -11,15 +11,19 @@ def unpack_logs(logs): for zipped_file in logs: - if os.path.isfile(zipped_file): - file_in = gzip.open(zipped_file, 'rb') - unzipped = zipped_file.replace('.gz', '.log') - file_out = open(unzipped, 'wb') - file_out.write(file_in.read()) - file_out.close() - file_in.close - os.remove(zipped_file) - sys.stderr.write(colored('Unpacked {0}'.format(zipped_file), 'green') + '\n') + try: + if os.path.isfile(zipped_file): + file_in = gzip.open(zipped_file, 'rb') + unzipped = zipped_file.replace('.gz', '.log') + file_out = open(unzipped, 'wb') + file_out.write(file_in.read()) + file_out.close() + file_in.close + os.remove(zipped_file) + sys.stderr.write(colored('Unpacked {0}'.format(zipped_file), 'green') + '\n') + except: + sys.stderr.write(colored('Could not unpack {0}'.format(zipped_file), 'red') + '\n') + continue def base_uri(args): if not args.singularity_uri_base: diff --git a/scripts/setup.py b/scripts/setup.py index 94f74e37a0..4c886da43e 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -10,7 +10,7 @@ setup( name='singularity-logfetch', - version='0.0.7', + version='0.0.8', description='Singularity log fetching and searching', author="HubSpot", author_email='singularity-users@googlegroups.com',