summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Mueller <dirk@dmllr.de>2013-04-22 16:38:55 +0200
committerDirk Mueller <dirk@dmllr.de>2013-04-22 16:38:55 +0200
commit45feb672af7cab42898fc0f249c6fbe5a4a36e12 (patch)
tree779b46f21812eb9cc5f9f99ea5cc166845b2aea9
parent11c2c40d46ce5efaaa9ff388347ad82c72307bec (diff)
downloadpython-glanceclient-45feb672af7cab42898fc0f249c6fbe5a4a36e12.tar.gz
Improve Python 3.x compatibility
Some mechanical translation of the deprecated except x,y construct. Should work with Python >= 2.6 just fine Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
-rw-r--r--glanceclient/common/http.py8
-rw-r--r--glanceclient/shell.py2
-rw-r--r--glanceclient/v1/images.py2
-rw-r--r--glanceclient/v1/legacy_shell.py8
-rw-r--r--glanceclient/v1/shell.py2
-rw-r--r--tests/test_http.py4
-rw-r--r--tests/test_utils.py4
-rw-r--r--tests/v1/test_images.py4
-rw-r--r--tests/v2/test_images.py2
9 files changed, 18 insertions, 18 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py
index 7146ace..638ffbd 100644
--- a/glanceclient/common/http.py
+++ b/glanceclient/common/http.py
@@ -348,14 +348,14 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
if self.cert_file:
try:
self.context.use_certificate_file(self.cert_file)
- except Exception, e:
+ except Exception as e:
msg = 'Unable to load cert from "%s" %s' % (self.cert_file, e)
raise exc.SSLConfigurationError(msg)
if self.key_file is None:
# We support having key and cert in same file
try:
self.context.use_privatekey_file(self.cert_file)
- except Exception, e:
+ except Exception as e:
msg = ('No key file specified and unable to load key '
'from "%s" %s' % (self.cert_file, e))
raise exc.SSLConfigurationError(msg)
@@ -363,14 +363,14 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
if self.key_file:
try:
self.context.use_privatekey_file(self.key_file)
- except Exception, e:
+ except Exception as e:
msg = 'Unable to load key from "%s" %s' % (self.key_file, e)
raise exc.SSLConfigurationError(msg)
if self.cacert:
try:
self.context.load_verify_locations(self.cacert)
- except Exception, e:
+ except Exception as e:
msg = 'Unable to load CA from "%s"' % (self.cacert, e)
raise exc.SSLConfigurationError(msg)
else:
diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index 5dc3687..417c784 100644
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -470,6 +470,6 @@ def main():
except KeyboardInterrupt:
print >> sys.stderr, '... terminating glance client'
sys.exit(1)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, e
sys.exit(1)
diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py
index 99a2bd7..60e7bf0 100644
--- a/glanceclient/v1/images.py
+++ b/glanceclient/v1/images.py
@@ -207,7 +207,7 @@ class ImageManager(base.Manager):
obj_size = obj.tell()
obj.seek(0)
return obj_size
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ESPIPE:
# Illegal seek. This means the user is trying
# to pipe image data to the client, e.g.
diff --git a/glanceclient/v1/legacy_shell.py b/glanceclient/v1/legacy_shell.py
index 5c43a99..c9da52c 100644
--- a/glanceclient/v1/legacy_shell.py
+++ b/glanceclient/v1/legacy_shell.py
@@ -50,7 +50,7 @@ def get_image_filters_from_args(args):
"""Build a dictionary of query filters based on the supplied args."""
try:
fields = get_image_fields_from_args(args)
- except RuntimeError, e:
+ except RuntimeError as e:
print e
return FAILURE
@@ -108,7 +108,7 @@ def do_add(gc, args):
"""DEPRECATED! Use image-create instead."""
try:
fields = get_image_fields_from_args(args.fields)
- except RuntimeError, e:
+ except RuntimeError as e:
print e
return FAILURE
@@ -182,7 +182,7 @@ def do_update(gc, args):
"""DEPRECATED! Use image-update instead."""
try:
fields = get_image_fields_from_args(args.fields)
- except RuntimeError, e:
+ except RuntimeError as e:
print e
return FAILURE
@@ -333,7 +333,7 @@ def do_clear(gc, args):
image.delete()
if args.verbose:
print 'done'
- except Exception, e:
+ except Exception as e:
print 'Failed to delete image %s' % image.id
print e
return FAILURE
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py
index 5ef6cfa..5fb088f 100644
--- a/glanceclient/v1/shell.py
+++ b/glanceclient/v1/shell.py
@@ -309,7 +309,7 @@ def do_image_delete(gc, args):
if args.verbose:
print '[Done]'
- except exc.HTTPException, e:
+ except exc.HTTPException as e:
if args.verbose:
print '[Fail]'
print '%s: Unable to delete image %s' % (e, args_image)
diff --git a/tests/test_http.py b/tests/test_http.py
index 0043b4a..1f1f4e1 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -61,7 +61,7 @@ class TestClient(testtools.TestCase):
# rather than assertRaises() so that we can check the body of
# the exception.
self.fail('An exception should have bypassed this line.')
- except exc.CommunicationError, comm_err:
+ except exc.CommunicationError as comm_err:
fail_msg = ("Exception message '%s' should contain '%s'" %
(comm_err.message, self.endpoint))
self.assertTrue(self.endpoint in comm_err.message, fail_msg)
@@ -100,7 +100,7 @@ class TestClient(testtools.TestCase):
client.raw_request('GET', '/v1/images/detail?limit=20')
self.fail('An exception should have bypassed this line.')
- except exc.CommunicationError, comm_err:
+ except exc.CommunicationError as comm_err:
fail_msg = ("Exception message '%s' should contain '%s'" %
(comm_err.message, endpoint))
self.assertTrue(endpoint in comm_err.message, fail_msg)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 279f5d6..df16acf 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -27,7 +27,7 @@ class TestUtils(testtools.TestCase):
try:
data = ''.join([f for f in utils.integrity_iter('A', None)])
self.fail('integrity checked passed without checksum.')
- except IOError, e:
+ except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 7fc56270e7a70fa81a5935b72eacbe29 expected None'
self.assertTrue(msg in str(e))
@@ -36,7 +36,7 @@ class TestUtils(testtools.TestCase):
try:
data = ''.join([f for f in utils.integrity_iter('BB', 'wrong')])
self.fail('integrity checked passed with wrong checksum')
- except IOError, e:
+ except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 9d3d9048db16a7eee539e93e3618cbe7 expected wrong'
self.assertTrue('expected wrong' in str(e))
diff --git a/tests/v1/test_images.py b/tests/v1/test_images.py
index a0f4a4e..6090584 100644
--- a/tests/v1/test_images.py
+++ b/tests/v1/test_images.py
@@ -333,7 +333,7 @@ class ImageManagerTest(testtools.TestCase):
try:
data = ''.join([b for b in data])
self.fail('data did not raise an error.')
- except IOError, e:
+ except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
self.assertTrue(msg in str(e))
@@ -507,7 +507,7 @@ class ImageTest(testtools.TestCase):
try:
data = ''.join([b for b in image.data()])
self.fail('data did not raise an error.')
- except IOError, e:
+ except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
self.assertTrue(msg in str(e))
diff --git a/tests/v2/test_images.py b/tests/v2/test_images.py
index ea2a63e..7e96e06 100644
--- a/tests/v2/test_images.py
+++ b/tests/v2/test_images.py
@@ -289,7 +289,7 @@ class TestController(testtools.TestCase):
try:
body = ''.join([b for b in body])
self.fail('data did not raise an error.')
- except IOError, e:
+ except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 9d3d9048db16a7eee539e93e3618cbe7 expected wrong'
self.assertTrue(msg in str(e))