Fixed flake8 errors
This commit is contained in:
parent
a45014b691
commit
d3c4b191db
@ -12,8 +12,8 @@
|
||||
|
||||
import six
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from openstack import exceptions as sdkexc
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from senlinclient.common.i18n import _
|
||||
|
||||
@ -64,7 +64,8 @@ class HTTPException(BaseException):
|
||||
{'message': message, 'traceback': traceback})
|
||||
else:
|
||||
code = self.error['error'].get('code', 'Unknown')
|
||||
return _('ERROR(%s): %s') % (code, message)
|
||||
return _('ERROR(%(code)s): %(message)s') % {'code': code,
|
||||
'message': message}
|
||||
|
||||
|
||||
class ClientError(HTTPException):
|
||||
@ -238,7 +239,7 @@ def parse_exception(exc):
|
||||
record['error']['code'] = code
|
||||
except KeyError as err:
|
||||
print(_('Malformed exception record, missing field "%s"') % err)
|
||||
print(_('Original error record: %s' % record))
|
||||
print(_('Original error record: %s') % record)
|
||||
return
|
||||
|
||||
if code in _EXCEPTION_MAP:
|
||||
|
@ -15,17 +15,16 @@ import os
|
||||
|
||||
from openstack import connection
|
||||
from openstack import exceptions
|
||||
from openstack import user_preference
|
||||
from openstack.identity import identity_service
|
||||
from openstack import resource as base
|
||||
from openstack import user_preference
|
||||
from senlinclient.common import exc
|
||||
|
||||
# Alias here for consistency
|
||||
prop = base.prop
|
||||
|
||||
|
||||
class UserPreferenceAction(argparse.Action):
|
||||
'''
|
||||
A custom action to parse user preferences as key=value pairs
|
||||
'''A custom action to parse user preferences as key=value pairs
|
||||
|
||||
Stores results in users preferences object.
|
||||
'''
|
||||
@ -77,16 +76,14 @@ class UserPreferenceAction(argparse.Action):
|
||||
|
||||
|
||||
class Resource(base.Resource):
|
||||
'''
|
||||
Senlin version of resource.
|
||||
'''Senlin version of resource.
|
||||
|
||||
These classes are here because the OpenStack SDK base version is making
|
||||
some assumptions about operations that cannot be satisfied in Senlin.
|
||||
'''
|
||||
@classmethod
|
||||
def list_short(cls, session, path_args=None, **params):
|
||||
'''
|
||||
Return a generator that will page through results of GET requests.
|
||||
'''Return a generator that will page through results of GET requests.
|
||||
|
||||
This method bypasses the DB session support and retrieves list that
|
||||
is directly exposed by server.
|
||||
@ -108,8 +105,8 @@ class Resource(base.Resource):
|
||||
yield value
|
||||
|
||||
def create(self, session):
|
||||
'''
|
||||
Overriden version of the create method.
|
||||
'''Overriden version of the create method.
|
||||
|
||||
We want to know more about the object being created, so the response
|
||||
should not be just thrown away
|
||||
'''
|
||||
|
@ -33,7 +33,7 @@ from senlinclient.common import sdk
|
||||
from senlinclient.common import utils
|
||||
|
||||
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
||||
USER_AGENT='python-senlinclient'
|
||||
USER_AGENT = 'python-senlinclient'
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -164,19 +164,19 @@ class SenlinShell(object):
|
||||
'user ID for authentication')
|
||||
print(_('WARNING: %s') % msg)
|
||||
|
||||
if (args.username and not args.user_id) and (not
|
||||
args.user_domain_id or args.user_domain_name):
|
||||
msg = _('Either user domain ID (--user-domain-id / '
|
||||
'env[OS_USER_DOMAIN_ID]) or user domain name '
|
||||
'(--user-domain-name / env[OS_USER_DOMAIN_NAME '
|
||||
'must be specified, because user name may not be '
|
||||
'unique.')
|
||||
raise exc.CommandError(msg)
|
||||
if (args.username and not args.user_id):
|
||||
if not (args.user_domain_id or args.user_domain_name):
|
||||
msg = _('Either user domain ID (--user-domain-id / '
|
||||
'env[OS_USER_DOMAIN_ID]) or user domain name '
|
||||
'(--user-domain-name / env[OS_USER_DOMAIN_NAME '
|
||||
'must be specified, because user name may not be '
|
||||
'unique.')
|
||||
raise exc.CommandError(msg)
|
||||
|
||||
# password is needed if username or user_id is present
|
||||
if (args.username or args.user_id) and not (args.password):
|
||||
msg = _('You must provide a password for user %s') % (
|
||||
args.username or args.user_id)
|
||||
args.username or args.user_id)
|
||||
raise exc.CommandError(msg)
|
||||
|
||||
# project name or ID is needed, or else sdk may find the wrong project
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
import inspect
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstack import exceptions as exc
|
||||
from openstack.identity import identity_service
|
||||
@ -20,6 +19,7 @@ from openstack.network.v2 import thin as thins
|
||||
from openstack import transport as trans
|
||||
from senlinclient.common import exc as client_exc
|
||||
|
||||
|
||||
class Client(object):
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
|
@ -16,7 +16,6 @@ from oslo_serialization import jsonutils
|
||||
|
||||
from senlinclient.common import exc
|
||||
from senlinclient.common.i18n import _
|
||||
from senlinclient.common import sdk
|
||||
from senlinclient.common import utils
|
||||
from senlinclient.v1 import models
|
||||
|
||||
@ -557,8 +556,10 @@ def do_node_create(sc, args):
|
||||
}
|
||||
|
||||
node, resp = sc.create(models.Node, params)
|
||||
print(_('Action NODE_CREATE(%s) scheduled for '
|
||||
'node %s') % (resp['action_id'], resp['id']))
|
||||
print(_('Action NODE_CREATE(%(action)s) scheduled for '
|
||||
'node %(node)s') % {
|
||||
'action': resp['action_id'],
|
||||
'node': resp['id']})
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NODE ID>',
|
||||
@ -590,7 +591,7 @@ def do_node_delete(sc, args):
|
||||
try:
|
||||
query = {'id': nid}
|
||||
sc.delete(models.Node, query)
|
||||
except exc.HTTPNotFound as ex:
|
||||
except exc.HTTPNotFound:
|
||||
failure_count += 1
|
||||
print('Node id "%s" not found' % nid)
|
||||
if failure_count == len(args.id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user