Permalink
Browse files

* run-tests.py: Updated paths for the new sync

  semantics.
* s3cmd, S3/S3.py: Small fixes to make testsuite happy.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@349 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
1 parent d7251cc commit 3894a49ae0eda5b09682e042a88d656ecac4454b @mludvig mludvig committed Jan 21, 2009
Showing with 38 additions and 24 deletions.
  1. +6 −0 ChangeLog
  2. +1 −1 S3/S3.py
  3. +23 −15 run-tests.py
  4. +8 −8 s3cmd
View
6 ChangeLog
@@ -1,3 +1,9 @@
+2009-01-22 Michal Ludvig <michal@logix.cz>
+
+ * run-tests.py: Updated paths for the new sync
+ semantics.
+ * s3cmd, S3/S3.py: Small fixes to make testsuite happy.
+
2009-01-21 Michal Ludvig <michal@logix.cz>
* s3cmd: Migrated 'sync' local->remote to the new
View
2 S3/S3.py
@@ -207,7 +207,7 @@ def object_get(self, uri, stream, start_position = 0, extra_label = ""):
if uri.type != "s3":
raise ValueError("Expected URI type 's3', got '%s'" % uri.type)
request = self.create_request("OBJECT_GET", uri = uri)
- labels = { 'source' : uri, 'destination' : stream.name, 'extra' : extra_label }
+ labels = { 'source' : unicodise(uri.uri()), 'destination' : unicodise(stream.name), 'extra' : extra_label }
response = self.recv_file(request, stream, labels, start_position)
return response
View
38 run-tests.py
@@ -153,6 +153,9 @@ def test_rmdir(label, dir_name):
cmd.append(dir_name)
return test(label, cmd)
+def test_flushdir(label, dir_name):
+ test_rmdir(label + "(rm)", dir_name)
+ return test_mkdir(label + "(mk)", dir_name)
argv = sys.argv[1:]
while argv:
@@ -208,19 +211,18 @@ def test_rmdir(label, dir_name):
## ====== Sync to S3
-test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ])
+test_s3cmd("Sync to S3", ['sync', 'testsuite/', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
+ must_not_find_re = [ "\.svn/", "\.png$" ])
if have_encoding:
## ====== Sync UTF-8 / GBK / ... to S3
- test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, enc_base_remote, '--exclude', '.svn/*', '--no-encrypt' ])
+ test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, 's3://s3cmd-autotest-1/xyz/encodings/', '--exclude', '.svn/*', '--no-encrypt' ],
+ must_find = [ u"File 'testsuite/encodings/%(encoding)s/%(pattern)s' stored as 's3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s'" % { 'encoding' : encoding, 'pattern' : enc_pattern } ])
## ====== List bucket content
-must_find_re = [ u"D s3://s3cmd-autotest-1/xyz/binary/$", u"D s3://s3cmd-autotest-1/xyz/etc/$" ]
+must_find_re = [ u"DIR s3://s3cmd-autotest-1/xyz/binary/$", u"DIR s3://s3cmd-autotest-1/xyz/etc/$" ]
must_not_find = [ u"random-crap.md5", u".svn" ]
-if have_encoding:
- must_find_re.append(u"D %s$" % enc_base_remote)
- must_not_find.append(enc_pattern)
test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'],
must_find_re = must_find_re,
must_not_find = must_not_find)
@@ -229,7 +231,7 @@ def test_rmdir(label, dir_name):
## ====== List bucket recursive
must_find = [ u"s3://s3cmd-autotest-1/xyz/binary/random-crap.md5" ]
if have_encoding:
- must_find.append(enc_base_remote + enc_pattern)
+ must_find.append(u"s3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern })
test_s3cmd("List bucket recursive", ['ls', '--recursive', 's3://s3cmd-autotest-1'],
must_find = must_find,
must_not_find = [ "logo.png" ])
@@ -238,21 +240,25 @@ def test_rmdir(label, dir_name):
# test_s3cmd("Recursive put", ['put', '--recursive', 'testsuite/etc', 's3://s3cmd-autotest-1/xyz/'])
-## ====== rmdir local
-test_rmdir("Removing local target", 'testsuite-out')
+## ====== Clean up local destination dir
+test_flushdir("Clean testsuite-out/", "testsuite-out")
## ====== Sync from S3
-must_find = [ "stored as testsuite-out/binary/random-crap.md5 " ]
+must_find = [ "File 's3://s3cmd-autotest-1/xyz/binary/random-crap.md5' stored as 'testsuite-out/xyz/binary/random-crap.md5'" ]
if have_encoding:
- must_find.append("stored as testsuite-out/" + encoding + "/" + enc_pattern)
+ must_find.append(u"File 's3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s' stored as 'testsuite-out/xyz/encodings/%(encoding)s/%(pattern)s' " % { 'encoding' : encoding, 'pattern' : enc_pattern })
test_s3cmd("Sync from S3", ['sync', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
must_find = must_find)
+## ====== Clean up local destination dir
+test_flushdir("Clean testsuite-out/", "testsuite-out")
+
+
## ====== Put public, guess MIME
test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', 's3://s3cmd-autotest-1/xyz/etc/logo.png'],
- must_find = [ "stored as s3://s3cmd-autotest-1/xyz/etc/logo.png" ])
+ must_find = [ "stored as 's3://s3cmd-autotest-1/xyz/etc/logo.png'" ])
## ====== Retrieve from URL
@@ -285,7 +291,8 @@ def test_rmdir(label, dir_name):
## ====== Sync more to S3
-test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--no-encrypt' ])
+test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://s3cmd-autotest-1/xyz/', '--no-encrypt' ],
+ must_find = [ "File 'testsuite/.svn/format' stored as 's3://s3cmd-autotest-1/xyz/.svn/format' " ])
## ====== Rename within S3
@@ -302,8 +309,9 @@ def test_rmdir(label, dir_name):
## ====== Sync more from S3
test_s3cmd("Sync more from S3", ['sync', '--delete-removed', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
- must_find = [ "deleted 'testsuite-out/logo.png'", "stored as testsuite-out/etc2/Logo.PNG (22059 bytes",
- "stored as testsuite-out/.svn/format " ],
+ must_find = [ "deleted: testsuite-out/logo.png",
+ "File 's3://s3cmd-autotest-1/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes",
+ "File 's3://s3cmd-autotest-1/xyz/.svn/format' stored as 'testsuite-out/xyz/.svn/format' " ],
must_not_find_re = [ "not-deleted.*etc/logo.png" ])
View
16 s3cmd
@@ -118,8 +118,8 @@ def subcmd_bucket_list(s3, uri):
raise
for prefix in response['common_prefixes']:
- output(u"%s %s" % (
- "D".rjust(28),
+ output(u"%s %s" % (
+ "DIR".rjust(26),
uri.compose_uri(bucket, prefix["Prefix"])))
for object in response["list"]:
@@ -308,7 +308,7 @@ def cmd_object_put(args):
continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
if not Config().progress_meter:
- output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
+ output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
(unicodise(full_name_orig), uri_final, response["size"], response["elapsed"],
speed_fmt[0], speed_fmt[1], seq_label))
if Config().acl_public:
@@ -772,7 +772,7 @@ def cmd_sync_remote2local(args):
open_flags |= os.O_TRUNC
# open_flags |= os.O_EXCL
- debug(u"dst_file=%s" % dst_file)
+ debug(u"dst_file=%s" % unicodise(dst_file))
# This will have failed should the file exist
os.close(os.open(dst_file, open_flags))
# Yeah I know there is a race condition here. Sadly I don't know how to open() in exclusive mode.
@@ -818,8 +818,8 @@ def cmd_sync_remote2local(args):
continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
if not Config().progress_meter:
- output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
- (uri, dst_file, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
+ output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
+ (uri, unicodise(dst_file), response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
seq_label))
total_size += response["size"]
@@ -939,7 +939,7 @@ def cmd_sync_local2remote(args):
continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
if not cfg.progress_meter:
- output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
+ output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
(item['full_name_unicode'], uri, response["size"], response["elapsed"],
speed_fmt[0], speed_fmt[1], seq_label))
total_size += response["size"]
@@ -977,7 +977,7 @@ def cmd_setacl(args):
for key in remote_list:
seq += 1
seq_label = "[%d of %d]" % (seq, remote_count)
- uri = key['remote_uri']
+ uri = S3Uri(remote_list[key]['object_uri_str'])
acl = s3.get_acl(uri)
debug(u"acl: %s - %r" % (uri, acl.grantees))
if cfg.acl_public:

0 comments on commit 3894a49

Please sign in to comment.