Merge "Resolve compatability for troveclient/compat"

This commit is contained in:
Jenkins
2013-10-23 15:40:10 +00:00
committed by Gerrit Code Review
4 changed files with 18 additions and 22 deletions

View File

@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
from troveclient.compat import exceptions
@@ -77,13 +78,13 @@ class Authenticator(object):
service_url=self.service_url,
root_key=root_key)
except exceptions.AmbiguousEndpoints:
print "Found more than one valid endpoint. Use a more " \
"restrictive filter"
print("Found more than one valid endpoint. Use a more "
"restrictive filter")
raise
except KeyError:
raise exceptions.AuthorizationFailure()
except exceptions.EndpointNotFound:
print "Could not find any suitable endpoint. Correct region?"
print("Could not find any suitable endpoint. Correct region?")
raise
elif resp.status == 305:

View File

@@ -104,7 +104,7 @@ class Manager(utils.HookableMixin):
cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))
try:
os.makedirs(cache_dir, 0755)
os.makedirs(cache_dir, 0o755)
except OSError:
# NOTE(kiall): This is typicaly either permission denied while
# attempting to create the directory, or the directory

View File

@@ -17,7 +17,6 @@ import httplib2
import logging
import os
import time
import urlparse
import sys
try:
@@ -25,10 +24,6 @@ try:
except ImportError:
import simplejson as json
# Python 2.5 compat fix
if not hasattr(urlparse, 'parse_qsl'):
import cgi
urlparse.parse_qsl = cgi.parse_qsl
from troveclient.compat import auth
from troveclient.compat import exceptions
@@ -234,7 +229,7 @@ class TroveHTTPClient(httplib2.Http):
# re-authenticate and try again. If it still fails, bail.
try:
return request()
except exceptions.Unauthorized, ex:
except exceptions.Unauthorized as ex:
self.authenticate()
return request()

View File

@@ -23,7 +23,7 @@ from troveclient.compat import client
from troveclient.compat.xml import TroveXmlClient
from troveclient.compat import exceptions
from urllib import quote
from troveclient.openstack.common.py3kcompat import urlutils
def methods_of(obj):
@@ -43,18 +43,18 @@ def check_for_exceptions(resp, body):
def print_actions(cmd, actions):
"""Print help for the command with list of options and description"""
print ("Available actions for '%s' cmd:") % cmd
print(("Available actions for '%s' cmd:") % cmd)
for k, v in actions.iteritems():
print "\t%-20s%s" % (k, v.__doc__)
print("\t%-20s%s" % (k, v.__doc__))
sys.exit(2)
def print_commands(commands):
"""Print the list of available commands and description"""
print "Available commands"
print("Available commands")
for k, v in commands.iteritems():
print "\t%-20s%s" % (k, v.__doc__)
print("\t%-20s%s" % (k, v.__doc__))
sys.exit(2)
@@ -73,9 +73,9 @@ def limit_url(url, limit=None, marker=None):
def quote_user_host(user, host):
quoted = ''
if host:
quoted = quote("%s@%s" % (user, host))
quoted = urlutils.quote("%s@%s" % (user, host))
else:
quoted = quote("%s" % user)
quoted = urlutils.quote("%s" % user)
return quoted.replace('.', '%2e')
@@ -234,7 +234,7 @@ class CommandsBase(object):
except:
if self.debug:
raise
print sys.exc_info()[1]
print(sys.exc_info()[1])
def _safe_exec(self, func, *args, **kwargs):
if not self.debug:
@@ -320,17 +320,17 @@ class CommandsBase(object):
return # Verbose already shows the output, so skip this.
if result and len(result) > 0:
for item in result:
print self._dumps(item._info)
print(self._dumps(item._info))
if result.links:
print("Links:")
for link in result.links:
print self._dumps((link))
print(self._dumps((link)))
else:
print("OK")
except:
if self.debug:
raise
print sys.exc_info()[1]
print(sys.exc_info()[1])
class Auth(CommandsBase):
@@ -368,7 +368,7 @@ class Auth(CommandsBase):
except:
if self.debug:
raise
print sys.exc_info()[1]
print(sys.exc_info()[1])
class AuthedCommandsBase(CommandsBase):