commit bcb518565df298f177417d9a681cf60f2b6bfb2a
Author: Stavros Sachtouris <saxtouri@admin.grnet.gr>
Date:   Tue Nov 6 16:49:41 2012 +0200

    Restore verbose and debug functionality in clients

diff --git a/kamaki/clients/__init__.py b/kamaki/clients/__init__.py
index 671b8b2..a16bfd3 100644
--- a/kamaki/clients/__init__.py
+++ b/kamaki/clients/__init__.py
@@ -31,7 +31,7 @@
 # interpreted as representing official policies, either expressed
 # or implied, of GRNET S.A.
 
-import json
+from json import dumps as json_dumps
 import logging
 from kamaki.clients.connection.kamakicon import KamakiHTTPConnection
 
@@ -40,8 +40,6 @@ recvlog = logging.getLogger('clients.recv')
 
 
 class ClientError(Exception):
-    """Error in clients
-    """
     def __init__(self, message, status=0, details=''):
         super(ClientError, self).__init__(message)
         self.status = status
@@ -49,7 +47,6 @@ class ClientError(Exception):
 
 
 class Client(object):
-
     def __init__(self, base_url, token, http_client=KamakiHTTPConnection()):
         self.base_url = base_url
         self.token = token
@@ -101,7 +98,7 @@ class Client(object):
             self.set_default_header('X-Auth-Token', self.token)
 
             if 'json' in kwargs:
-                data = json.dumps(kwargs.pop('json'))
+                data = json_dumps(kwargs.pop('json'))
                 self.set_default_header('Content-Type', 'application/json')
             if data:
                 self.set_default_header('Content-Length', unicode(len(data)))
@@ -127,8 +124,8 @@ class Client(object):
             recvlog.info('%d %s', r.status_code, r.status)
             for key, val in r.headers.items():
                 recvlog.info('%s: %s', key, val)
-            #if r.content:
-            #    recvlog.debug(r.content)
+            if r.content:
+                recvlog.debug(r.content)
 
             if success is not None:
                 # Success can either be an in or a collection
@@ -139,6 +136,8 @@ class Client(object):
         except ClientError:
             raise
         except Exception as err:
+            from traceback import print_stack
+            recvlog.debug(print_stack)
             self.http_client.reset_headers()
             self.http_client.reset_params()
             raise ClientError('%s' % err, status=getattr(err, 'status', 0))
diff --git a/kamaki/clients/connection/errors.py b/kamaki/clients/connection/errors.py
new file mode 100644
index 0000000..f3a87b0
--- /dev/null
+++ b/kamaki/clients/connection/errors.py
@@ -0,0 +1,49 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, self.list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, self.list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+
+class HTTPConnectionError(Exception):
+    """
+        700: Generic connection error
+        701: Cannot connect to server
+        702: Response format error
+    """
+    def __init__(self, message, status=700):
+        super(HTTPConnectionError, self).__init__(message)
+        self.status = status
+
+
+class HTTPResponseFormatError(HTTPConnectionError):
+
+    def __init__(self, message, details=''):
+        super(HTTPResponseFormatError, self).__init__(message, status=702)
