Permalink
Browse files

Versioning support, and a fix to remote2remote that corrects remote p…

…ath (used to be remote file)
  • Loading branch information...
1 parent eb9330f commit 389b58208b0939851b27e8a7afbb858e2e39a829 Sundar Raman committed Jan 1, 2011
Showing with 21 additions and 2 deletions.
  1. +13 −0 S3/S3.py
  2. +8 −2 s3cmd
View
@@ -26,6 +26,7 @@
from ACL import ACL, GranteeLogDelivery
from AccessLog import AccessLog
from S3Uri import S3Uri
+from Versioning import Versioning
__all__ = []
class S3Request(object):
@@ -380,6 +381,18 @@ def set_accesslog(self, uri, enable, log_target_prefix_uri = None, acl_public =
raise
return accesslog, response
+ # Implement versioning support - get and set
+ def get_versioning(self, uri):
+ request = self.create_request("BUCKET_LIST", bucket = uri.bucket(), extra = "?versioning")
+ response = self.send_request(request)
+ print "Response: %s" % response
+ versioning = Versioning(response['data'])
+ return versioning
+
+ def set_versioning(self, uri):
+ pass
+
+
## Low level methods
def urlencode_string(self, string, urlencoding_mode = None):
if type(string) == unicode:
View
10 s3cmd
@@ -22,6 +22,7 @@ import codecs
import locale
import subprocess
import htmlentitydefs
+import pprint
from copy import copy
from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
@@ -648,7 +649,10 @@ def cmd_info(args):
for grant in acl_grant_list:
output(u" ACL: %s: %s" % (grant['grantee'], grant['permission']))
if acl.isAnonRead():
- output(u" URL: %s" % uri.public_url())
+ output(u" URL: %s" % uri.public_url())
+ ver = s3.get_versioning(uri)
+ print "Versioning info:"
+ pprint.pprint(ver)
except S3Error, e:
if S3.codes.has_key(e.info["Code"]):
error(S3.codes[e.info["Code"]] % uri.bucket())
@@ -897,11 +901,13 @@ def cmd_sync_remote2remote(args):
item = src_list[file]
uri = S3Uri(item['object_uri_str'])
dst_file = item['target_uri']
+ dst_path = '/'.join((dst_file.split('/'))[:-1])
seq_label = "[%d of %d]" % (seq, src_count)
extra_headers = copy(cfg.extra_headers)
try:
# Copy source to destination
- cmd_cp([u"%s"%uri, u"%s"%dst_file])
+ # cmd_cp([u"%s"%uri, u"%s"%dst_file])
+ cmd_cp([u"%s"%uri, u"%s"%dst_path])
except Exception, e:
error(u"Something went wrong: %s" % e)
continue

0 comments on commit 389b582

Please sign in to comment.