Skip to content

Commit

Permalink
error handling for gzip errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Jan 28, 2015
1 parent 08dd92e commit 73e5528
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions scripts/logfetch/logfetch_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 73e5528

Please sign in to comment.