Logo Search packages:      
Sourcecode: s3cmd version File versions  Download package

Exceptions.py

## Amazon S3 manager - Exceptions library
## Author: Michal Ludvig <michal@logix.cz>
##         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 S3DownloadError(Exception):
      pass

class ParameterError(Exception):
      pass



Generated by  Doxygen 1.6.0   Back to index