MCPcopy Create free account
hub / github.com/s3tools/s3cmd / __init__

Method __init__

S3/Exceptions.py:73–98  ·  view source on GitHub ↗
(self, response)

Source from the content-addressed store, hash-verified

71
72class S3Error(S3Exception):
73 def __init__(self, response):
74 self.status = response["status"]
75 self.reason = response["reason"]
76 self.info = {
77 "Code": "",
78 "Message": "",
79 "Resource": ""
80 }
81 debug("S3Error: %s (%s)" % (self.status, self.reason))
82 if "headers" in response:
83 for header in response["headers"]:
84 debug("HttpHeader: %s: %s" % (header, response["headers"][header]))
85 if "data" in response and response["data"]:
86 try:
87 tree = S3.BaseUtils.getTreeFromXml(response["data"])
88 except XmlParseError:
89 debug("Not an XML response")
90 else:
91 try:
92 self.info.update(self.parse_error_xml(tree))
93 except Exception as e:
94 error("Error parsing xml: %s. ErrorXML: %s" % (e, response["data"]))
95
96 self.code = self.info["Code"]
97 self.message = self.info["Message"]
98 self.resource = self.info["Resource"]
99
100 def __unicode__(self):
101 retval = u"%d " % (self.status)

Callers

nothing calls this directly

Calls 2

parse_error_xmlMethod · 0.95
updateMethod · 0.80

Tested by

no test coverage detected