Skip to content

Instantly share code, notes, and snippets.

@pcting
Created February 25, 2011 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcting/843293 to your computer and use it in GitHub Desktop.
Save pcting/843293 to your computer and use it in GitHub Desktop.
s3cmd 0.9.9.91 patch for eucalyptus
diff -cr -r /usr/share/s3cmd/S3/ACL.py ./S3/ACL.py
*** /usr/share/s3cmd/S3/ACL.py 2009-01-07 04:16:32.000000000 -0800
--- ./S3/ACL.py 2011-02-24 17:57:20.583095822 -0800
***************
*** 31,37 ****
return self.tag == "URI" and self.name == Grantee.ALL_USERS_URI
def isAnonRead(self):
! return self.isAllUsers and self.permission == "READ"
def getElement(self):
el = ET.Element("Grant")
--- 31,37 ----
return self.tag == "URI" and self.name == Grantee.ALL_USERS_URI
def isAnonRead(self):
! return self.isAllUsers() and self.permission == "READ"
def getElement(self):
el = ET.Element("Grant")
Binary files /usr/share/s3cmd/S3/ACL.pyc and ./S3/ACL.pyc differ
diff -cr -r /usr/share/s3cmd/S3/Config.py ./S3/Config.py
*** /usr/share/s3cmd/S3/Config.py 2009-06-02 03:18:12.000000000 -0700
--- ./S3/Config.py 2011-02-24 17:57:20.773073905 -0800
***************
*** 17,22 ****
--- 17,23 ----
secret_key = ""
host_base = "s3.amazonaws.com"
host_bucket = "%(bucket)s.s3.amazonaws.com"
+ service_path = ""
simpledb_host = "sdb.amazonaws.com"
cloudfront_host = "cloudfront.amazonaws.com"
cloudfront_resource = "/2008-06-30/distribution"
Binary files /usr/share/s3cmd/S3/Config.pyc and ./S3/Config.pyc differ
diff -cr -r /usr/share/s3cmd/S3/S3.py ./S3/S3.py
*** /usr/share/s3cmd/S3/S3.py 2009-10-07 14:40:21.000000000 -0700
--- ./S3/S3.py 2011-02-24 17:57:20.573068694 -0800
***************
*** 63,70 ****
for header in self.headers.keys():
if header.startswith("x-amz-"):
h += header+":"+str(self.headers[header])+"\n"
! if self.resource['bucket']:
! h += "/" + self.resource['bucket']
h += self.resource['uri']
debug("SignHeaders: " + repr(h))
signature = sign_string(h)
--- 63,71 ----
for header in self.headers.keys():
if header.startswith("x-amz-"):
h += header+":"+str(self.headers[header])+"\n"
! # if self.resource['bucket']:
! # h += "/" + self.resource['bucket']
!
h += self.resource['uri']
debug("SignHeaders: " + repr(h))
signature = sign_string(h)
***************
*** 385,396 ****
object = uri.has_object() and uri.object() or None
if bucket:
! resource['bucket'] = str(bucket)
if object:
! resource['uri'] = "/" + self.urlencode_string(object)
if extra:
resource['uri'] += extra
method_string = S3.http_methods.getkey(S3.operations[operation] & S3.http_methods["MASK"])
request = S3Request(self, method_string, resource, headers, params)
--- 386,404 ----
object = uri.has_object() and uri.object() or None
if bucket:
! # resource['bucket'] = str(bucket)
! resource['uri'] = "/" + self.urlencode_string(bucket)
if object:
! # resource['uri'] = "/" + self.urlencode_string(object)
! resource['uri'] = resource['uri'] + "/" + self.urlencode_string(object)
!
if extra:
resource['uri'] += extra
+ # hopefully this is the right place
+ if self.config.service_path:
+ resource['uri'] = self.config.service_path + resource['uri']
+
method_string = S3.http_methods.getkey(S3.operations[operation] & S3.http_methods["MASK"])
request = S3Request(self, method_string, resource, headers, params)
Binary files /usr/share/s3cmd/S3/S3.pyc and ./S3/S3.pyc differ
diff -cr -r /usr/share/s3cmd/S3/Utils.py ./S3/Utils.py
*** /usr/share/s3cmd/S3/Utils.py 2009-06-02 04:01:36.000000000 -0700
--- ./S3/Utils.py 2011-02-24 17:57:20.665569671 -0800
***************
*** 49,60 ****
"""
removeNameSpace(xml) -- remove top-level AWS namespace
"""
r = re.compile('^(<?[^>]+?>\s?)(<\w+) xmlns=[\'"](http://[^\'"]+)[\'"](.*)', re.MULTILINE)
if r.match(xml):
xmlns = r.match(xml).groups()[2]
xml = r.sub("\\1\\2\\4", xml)
else:
! xmlns = None
return xml, xmlns
def getTreeFromXml(xml):
--- 49,67 ----
"""
removeNameSpace(xml) -- remove top-level AWS namespace
"""
+ # S3 returns doctype, xmlns
r = re.compile('^(<?[^>]+?>\s?)(<\w+) xmlns=[\'"](http://[^\'"]+)[\'"](.*)', re.MULTILINE)
if r.match(xml):
xmlns = r.match(xml).groups()[2]
xml = r.sub("\\1\\2\\4", xml)
else:
! # Eucalyptus returns xmlns, xmlns:xsi
! r = re.compile('^(<\w+) xmlns=[\'"](http://[^\'"]+)[\'"] xmlns:xsi=[\'"]http://[^\'"]+[\'"](.*)', re.MULTILINE)
! if r.match(xml):
! xmlns = r.sub("\\2", xml)
! xml = r.sub("\\1\\3", xml)
! else:
! xmlns = None
return xml, xmlns
def getTreeFromXml(xml):
Binary files /usr/share/s3cmd/S3/Utils.pyc and ./S3/Utils.pyc differ
diff -cr -r /usr/share/s3cmd/s3cmd ./s3cmd
*** /usr/share/s3cmd/s3cmd 2009-11-07 12:02:37.000000000 -0800
--- ./s3cmd 2011-02-24 17:57:20.863091004 -0800
***************
*** 130,141 ****
format_string = u"%(timestamp)16s %(size)9s%(coeff)1s %(uri)s"
for prefix in response['common_prefixes']:
output(format_string % {
"timestamp": "",
"size": "DIR",
"coeff": "",
"md5": "",
! "uri": uri.compose_uri(bucket, prefix["Prefix"])})
for object in response["list"]:
size, size_coeff = formatSize(object["Size"], Config().human_readable_sizes)
--- 130,148 ----
format_string = u"%(timestamp)16s %(size)9s%(coeff)1s %(uri)s"
for prefix in response['common_prefixes']:
+ try:
+ # S3 often has / as prefix at minimum
+ prefixprefix = prefix["Prefix"]
+ except KeyError:
+ # Eucalyptus often has an empty prefix which doesn't
+ # parse, it puts thins in "Directory" instead
+ prefixprefix = ""
output(format_string % {
"timestamp": "",
"size": "DIR",
"coeff": "",
"md5": "",
! "uri": uri.compose_uri(bucket, prefixprefix)})
for object in response["list"]:
size, size_coeff = formatSize(object["Size"], Config().human_readable_sizes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment