[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:31:02 UTC 2013


The following commit has been merged in the master branch:
commit e7486b1699223a9fb779f1d29869b8b918aaa12d
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Sun Apr 14 00:32:52 2013 -0700

    Standardize AWSErrors a little more

diff --git a/euca2ools/exceptions.py b/euca2ools/exceptions.py
index 4341c4b..d56bf57 100644
--- a/euca2ools/exceptions.py
+++ b/euca2ools/exceptions.py
@@ -140,9 +140,9 @@ import six
 class AWSError(requestbuilder.exceptions.ServerError):
     def __init__(self, response, *args):
         requestbuilder.exceptions.ServerError.__init__(self, response, *args)
-        self.code     = None # API error code
-        self.message  = None # Error message
-        self.elements = {}   # Elements in the error response's body
+        self.code = None  # API error code
+        self.message = None  # Error message
+        self.elements = {}  # Elements in the error response's body
 
         if self.body:
             try:
@@ -154,8 +154,10 @@ class AWSError(requestbuilder.exceptions.ServerError):
                     parsed = parsed['Errors']
                 if 'Error' in parsed:
                     parsed = parsed['Error']
-                self.code     = parsed.get('Code') or response.status_code
-                self.message  = parsed.get('Message') or response.reason
+                if parsed.get('Code'):
+                    self.code = parsed['Code']
+                    self.args += (parsed['Code'],)
+                self.message = parsed.get('Message')
                 self.elements = parsed
             except ValueError:
                 # Dump the unparseable message body so we don't include
@@ -163,14 +165,8 @@ class AWSError(requestbuilder.exceptions.ServerError):
                 # frequently returns plain text and/or broken XML, store it
                 # in case we need it later.
                 self.message = self.body
-                self.body    = None
-                self.code    = response.status_code
-        else:
-            self.code    = response.status_code
-            self.message = response.reason
-
-    def __str__(self):
-        s_bits = [self.__class__.__name__ + ':', self.code or self.status_code]
-        if self.message:
-            s_bits.append(self.message)
-        return ' '.join(s_bits)
+            self.args += (self.message,)
+
+    def format_for_cli(self):
+        return 'error ({0}): {1}'.format(self.code or self.status_code,
+                                         self.message or self.reason)

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list