From 52b5f428285677614c164e5a2e59b6b483ebcdad Mon Sep 17 00:00:00 2001 From: Kurt Martin Date: Tue, 7 Jan 2014 13:27:12 -0800 Subject: [PATCH] Modify to support Python 3.0 Update the code to change issue found by running 2to3 utility. --- hplefthandclient/__init__.py | 4 ++-- hplefthandclient/http.py | 11 +++++------ setup.py | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hplefthandclient/__init__.py b/hplefthandclient/__init__.py index 9648d50..96565d6 100644 --- a/hplefthandclient/__init__.py +++ b/hplefthandclient/__init__.py @@ -24,11 +24,11 @@ HP LeftHand REST Client """ -version_tuple = (1, 0, 0) +version_tuple = (1, 0, 1) def get_version_string(): - if isinstance(version_tuple[-1], basestring): + if isinstance(version_tuple[-1], str): return '.'.join(map(str, version_tuple[:-1])) + version_tuple[-1] return '.'.join(map(str, version_tuple)) diff --git a/hplefthandclient/http.py b/hplefthandclient/http.py index 79d5f14..f7e8619 100644 --- a/hplefthandclient/http.py +++ b/hplefthandclient/http.py @@ -74,7 +74,6 @@ class HTTPJSONRESTClient(httplib2.Http): def set_url(self, api_url): #should be http:///lhos self.api_url = api_url.rstrip('/') - self.api_url = self.api_url def set_debug_flag(self, flag): """ @@ -211,7 +210,7 @@ class HTTPJSONRESTClient(httplib2.Http): return resp, body def _do_reauth(self, url, method, ex, **kwargs): - print "_do_reauth called" + print("_do_reauth called") try: if self.auth_try != 1: self._reauth() @@ -231,12 +230,12 @@ class HTTPJSONRESTClient(httplib2.Http): resp, body = self._time_request(self.api_url + url, method, **kwargs) return resp, body - except exceptions.HTTPUnauthorized, ex: - print "_CS_REQUEST HTTPUnauthorized" + except exceptions.HTTPUnauthorized as ex: + print("_CS_REQUEST HTTPUnauthorized") resp, body = self._do_reauth(url, method, ex, **kwargs) return resp, body - except exceptions.HTTPForbidden, ex: - print "_CS_REQUEST HTTPForbidden" + except exceptions.HTTPForbidden as ex: + print("_CS_REQUEST HTTPForbidden") resp, body = self._do_reauth(url, method, ex, **kwargs) return resp, body diff --git a/setup.py b/setup.py index be32cea..a6e2e88 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ setup( 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.0', 'Topic :: Internet :: WWW/HTTP', ]