From: <lu...@us...> - 2008-04-29 09:42:53
|
Revision: 177 http://s3tools.svn.sourceforge.net/s3tools/?rev=177&view=rev Author: ludvigm Date: 2008-04-29 02:42:38 -0700 (Tue, 29 Apr 2008) Log Message: ----------- 2008-04-29 Michal Ludvig <mi...@lo...> * S3/Exceptions.py: Exceptions moved out of S3.S3 Modified Paths: -------------- s3cmd/trunk/ChangeLog s3cmd/trunk/S3/S3.py s3cmd/trunk/s3cmd Added Paths: ----------- s3cmd/trunk/S3/Exceptions.py Modified: s3cmd/trunk/ChangeLog =================================================================== --- s3cmd/trunk/ChangeLog 2008-04-29 09:40:52 UTC (rev 176) +++ s3cmd/trunk/ChangeLog 2008-04-29 09:42:38 UTC (rev 177) @@ -1,5 +1,6 @@ 2008-04-29 Michal Ludvig <mi...@lo...> + * S3/Exceptions.py: Exceptions moved out of S3.S3 * S3/SortedDict.py: rewritten from scratch to preserve case of keys while still sorting in case-ignore mode. Added: s3cmd/trunk/S3/Exceptions.py =================================================================== --- s3cmd/trunk/S3/Exceptions.py (rev 0) +++ s3cmd/trunk/S3/Exceptions.py 2008-04-29 09:42:38 UTC (rev 177) @@ -0,0 +1,43 @@ +## Amazon S3 manager - Exceptions library +## Author: Michal Ludvig <mi...@lo...> +## http://www.logix.cz/michal +## License: GPL Version 2 + +from logging import debug, info, warning, error + +try: + import xml.etree.ElementTree as ET +except ImportError: + import elementtree.ElementTree as ET + +class S3Error (Exception): + def __init__(self, response): + self.status = response["status"] + self.reason = response["reason"] + self.info = {} + debug("S3Error: %s (%s)" % (self.status, self.reason)) + if response.has_key("headers"): + for header in response["headers"]: + debug("HttpHeader: %s: %s" % (header, response["headers"][header])) + if response.has_key("data"): + tree = ET.fromstring(response["data"]) + for child in tree.getchildren(): + if child.text != "": + debug("ErrorXML: " + child.tag + ": " + repr(child.text)) + self.info[child.tag] = child.text + + def __str__(self): + retval = "%d (%s)" % (self.status, self.reason) + try: + retval += (": %s" % self.info["Code"]) + except (AttributeError, KeyError): + pass + return retval + +class S3UploadError(Exception): + pass + +class ParameterError(Exception): + pass + + Modified: s3cmd/trunk/S3/S3.py =================================================================== --- s3cmd/trunk/S3/S3.py 2008-04-29 09:40:52 UTC (rev 176) +++ s3cmd/trunk/S3/S3.py 2008-04-29 09:42:38 UTC (rev 177) @@ -19,37 +19,8 @@ from SortedDict import SortedDict from BidirMap import BidirMap from Config import Config +from Exceptions import * -class S3Error (Exception): - def __init__(self, response): - self.status = response["status"] - self.reason = response["reason"] - self.info = {} - debug("S3Error: %s (%s)" % (self.status, self.reason)) - if response.has_key("headers"): - for header in response["headers"]: - debug("HttpHeader: %s: %s" % (header, response["headers"][header])) - if response.has_key("data"): - tree = ET.fromstring(response["data"]) - for child in tree.getchildren(): - if child.text != "": - debug("ErrorXML: " + child.tag + ": " + repr(child.text)) - self.info[child.tag] = child.text - - def __str__(self): - retval = "%d (%s)" % (self.status, self.reason) - try: - retval += (": %s" % self.info["Code"]) - except (AttributeError, KeyError): - pass - return retval - -class S3UploadError(Exception): - pass - -class ParameterError(Exception): - pass - class S3(object): http_methods = BidirMap( GET = 0x01, Modified: s3cmd/trunk/s3cmd =================================================================== --- s3cmd/trunk/s3cmd 2008-04-29 09:40:52 UTC (rev 176) +++ s3cmd/trunk/s3cmd 2008-04-29 09:42:38 UTC (rev 177) @@ -24,8 +24,8 @@ from S3.Config import Config from S3.S3Uri import * from S3 import Utils +from S3.Exceptions import * - def output(message): print message This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |