Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge from 0.9.8.x branch, rel 246:
* s3cmd, S3/S3.py, S3/Exceptions.py: Don't abort 'sync' or 'put' on files
  that can't be open (e.g. Permision denied). Print a warning and skip over
  instead.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@255 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
ludvigm committed Nov 16, 2008
1 parent ec8ab9b commit f111ffe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,5 +1,9 @@
2008-11-16 Michal Ludvig <michal@logix.cz>

Merge from 0.9.8.x branch, rel 246:
* s3cmd, S3/S3.py, S3/Exceptions.py: Don't abort 'sync' or 'put' on files
that can't be open (e.g. Permision denied). Print a warning and skip over
instead.
Merge from 0.9.8.x branch, rel 245:
* S3/S3.py: Escape parameters in strings. Fixes sync to and
ls of directories with spaces. (Thx Lubomir Rintel from Fedora Project)
Expand Down
3 changes: 3 additions & 0 deletions S3/Exceptions.py
Expand Up @@ -48,5 +48,8 @@ class S3UploadError(S3Exception):
class S3DownloadError(S3Exception):
pass

class InvalidFileError(S3Exception):
pass

class ParameterError(S3Exception):
pass
4 changes: 2 additions & 2 deletions S3/S3.py
Expand Up @@ -162,12 +162,12 @@ def object_put(self, filename, uri, extra_headers = None):
raise ValueError("Expected URI type 's3', got '%s'" % uri.type)

if not os.path.isfile(filename):
raise ParameterError("%s is not a regular file" % filename)
raise InvalidFileError("%s is not a regular file" % filename)
try:
file = open(filename, "rb")
size = os.stat(filename)[ST_SIZE]
except IOError, e:
raise ParameterError("%s: %s" % (filename, e.strerror))
raise InvalidFileError("%s: %s" % (filename, e.strerror))
headers = SortedDict()
if extra_headers:
headers.update(extra_headers)
Expand Down
6 changes: 6 additions & 0 deletions s3cmd
Expand Up @@ -209,6 +209,9 @@ def cmd_object_put(args):
except S3UploadError, e:
error("Upload of '%s' failed too many times. Skipping that file." % real_filename)
continue
except InvalidFileError, e:
warning("File can not be uploaded: %s" % e)
continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
output("File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) [%d of %d]" %
(file, uri_final, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
Expand Down Expand Up @@ -648,6 +651,9 @@ def cmd_sync_local2remote(src, dst):
except S3UploadError, e:
error("%s: upload failed too many times. Skipping that file." % src)
continue
except InvalidFileError, e:
warning("File can not be uploaded: %s" % e)
continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
output("File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) [%d of %d]" %
(src, uri, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
Expand Down

0 comments on commit f111ffe

Please sign in to comment.