Skip to content

Commit

Permalink
When writing s3 files, attempt to print out the key and other informa…
Browse files Browse the repository at this point in the history
…tion

if boto throws an exception.
  • Loading branch information
jpieper committed Mar 4, 2015
1 parent 815a2a9 commit bc81871
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions s3bdbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
reconstructed with a shell script if need be.
'''

# Copyright 2011-2013 Josh Pieper, jjp@pobox.com
# Copyright 2011-2015 Josh Pieper, jjp@pobox.com

# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
Expand Down Expand Up @@ -101,6 +101,10 @@ def __init__(self, args):
import boto.s3.connection
import ConfigParser

# Enable this if you need help debugging boto.
#
# boto.set_stream_logger('boto')

if args.access is None or args.secret is None:
# Try to get these from a config file.
parser = ConfigParser.SafeConfigParser()
Expand All @@ -125,7 +129,13 @@ def exists(self, arg):

def store(self, name, data, progress_function=None):
key = self._bucket.new_key(name)
key.set_contents_from_string(data, cb=progress_function)
try:
key.set_contents_from_string(data, cb=progress_function)
except:
sys.stderr.write(
'\nError when writing name=%s len(data)=%d key=%s\n' % (
name, len(data), repr(key)))
raise

def load(self, name, progress_function=None):
key = self._bucket.get_key(name)
Expand Down Expand Up @@ -382,7 +392,7 @@ def do_list(args):

def do_version(args):
print 's3bdbk.py version %s' % _S3BDBK_VERSION
print 'Copyright 2011 Josh Pieper'
print 'Copyright 2011-2015 Josh Pieper'
print
return 0

Expand Down

0 comments on commit bc81871

Please # to comment.