Fix name not defined error
Add the missing import packages and format the log messages Move i18n to package(cloudkittyclient) Change-Id: I77e7059e8eb91aef131713f0720f58d23ae7c11f Closes-Bug: #1524680
This commit is contained in:
parent
ea21f9761b
commit
5c188a2306
|
@ -23,6 +23,7 @@ import copy
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from cloudkittyclient import exc
|
from cloudkittyclient import exc
|
||||||
|
from cloudkittyclient.i18n import _
|
||||||
from cloudkittyclient.openstack.common.apiclient import base
|
from cloudkittyclient.openstack.common.apiclient import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ class CrudManager(base.CrudManager):
|
||||||
'name': self.resource_class.__name__,
|
'name': self.resource_class.__name__,
|
||||||
'args': kwargs
|
'args': kwargs
|
||||||
}
|
}
|
||||||
raise exc.NotFound(404, msg)
|
raise exc.HTTPNotFound(msg)
|
||||||
return rl
|
return rl
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import prettytable
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from cloudkittyclient import exc
|
from cloudkittyclient import exc
|
||||||
|
from cloudkittyclient.i18n import _
|
||||||
from cloudkittyclient.openstack.common import cliutils
|
from cloudkittyclient.openstack.common import cliutils
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,8 +143,10 @@ def find_resource(manager, name_or_id):
|
||||||
try:
|
try:
|
||||||
return manager.find(name=name_or_id)
|
return manager.find(name=name_or_id)
|
||||||
except exc.HTTPNotFound:
|
except exc.HTTPNotFound:
|
||||||
msg = ("No %s with a name or ID of '%s' exists." %
|
msg = _("No %(name)s with a name or ID of '%(id)s' exists.") % {
|
||||||
(manager.resource_class.__name__.lower(), name_or_id))
|
"name": manager.resource_class.__name__.lower(),
|
||||||
|
"id": name_or_id
|
||||||
|
}
|
||||||
raise exc.CommandError(msg)
|
raise exc.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,9 +157,12 @@ def args_array_to_dict(kwargs, key_to_convert):
|
||||||
kwargs[key_to_convert] = dict(v.split("=", 1)
|
kwargs[key_to_convert] = dict(v.split("=", 1)
|
||||||
for v in values_to_convert)
|
for v in values_to_convert)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exc.CommandError(
|
msg = _("%(key)s must be a list of key=value "
|
||||||
'%s must be a list of key=value not "%s"' % (
|
"not '%(value)s'") % {
|
||||||
key_to_convert, values_to_convert))
|
"key": key_to_convert,
|
||||||
|
"value": values_to_convert
|
||||||
|
}
|
||||||
|
raise exc.CommandError(msg)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,9 +180,12 @@ def args_array_to_list_of_dicts(kwargs, key_to_convert):
|
||||||
dct[kv[0]] = kv[1].strip(" \"'") # strip spaces and quotes
|
dct[kv[0]] = kv[1].strip(" \"'") # strip spaces and quotes
|
||||||
kwargs[key_to_convert].append(dct)
|
kwargs[key_to_convert].append(dct)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise exc.CommandError(
|
msg = _("%(key)s must be a list of "
|
||||||
'%s must be a list of key1=value1;key2=value2;... not "%s"' % (
|
"key1=value1;key2=value2;... not '%(value)s'") % {
|
||||||
key_to_convert, values_to_convert))
|
"key": key_to_convert,
|
||||||
|
"value": values_to_convert
|
||||||
|
}
|
||||||
|
raise exc.CommandError(msg)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
"""oslo.i18n integration module.
|
||||||
|
|
||||||
|
See http://docs.openstack.org/developer/oslo.i18n/usage.html
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import oslo_i18n as i18n
|
||||||
|
|
||||||
|
_translators = i18n.TranslatorFactory(domain='cloudkittyclient')
|
||||||
|
i18n.enable_lazy()
|
||||||
|
|
||||||
|
_ = _translators.primary
|
||||||
|
_LI = _translators.log_info
|
||||||
|
_LW = _translators.log_warning
|
||||||
|
_LE = _translators.log_error
|
||||||
|
_LC = _translators.log_critical
|
|
@ -1,45 +0,0 @@
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
"""oslo.i18n integration module.
|
|
||||||
|
|
||||||
See http://docs.openstack.org/developer/oslo.i18n/usage.html
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
import oslo_i18n
|
|
||||||
|
|
||||||
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
|
|
||||||
# application name when this module is synced into the separate
|
|
||||||
# repository. It is OK to have more than one translation function
|
|
||||||
# using the same domain, since there will still only be one message
|
|
||||||
# catalog.
|
|
||||||
_translators = oslo_i18n.TranslatorFactory(domain='cloudkittyclient')
|
|
||||||
|
|
||||||
# The primary translation function using the well-known name "_"
|
|
||||||
_ = _translators.primary
|
|
||||||
|
|
||||||
# Translators for log levels.
|
|
||||||
#
|
|
||||||
# The abbreviated names are meant to reflect the usual use of a short
|
|
||||||
# name like '_'. The "L" is for "log" and the other letter comes from
|
|
||||||
# the level.
|
|
||||||
_LI = _translators.log_info
|
|
||||||
_LW = _translators.log_warning
|
|
||||||
_LE = _translators.log_error
|
|
||||||
_LC = _translators.log_critical
|
|
||||||
except ImportError:
|
|
||||||
# NOTE(dims): Support for cases where a project wants to use
|
|
||||||
# code from oslo-incubator, but is not ready to be internationalized
|
|
||||||
# (like tempest)
|
|
||||||
_ = _LI = _LW = _LE = _LC = lambda x: x
|
|
|
@ -44,7 +44,7 @@ from oslo_utils import strutils
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from cloudkittyclient.openstack.common._i18n import _
|
from cloudkittyclient.i18n import _
|
||||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ from oslo_utils import encodeutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from cloudkittyclient.openstack.common._i18n import _
|
from cloudkittyclient.i18n import _
|
||||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -38,7 +38,7 @@ import sys
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from cloudkittyclient.openstack.common._i18n import _
|
from cloudkittyclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
class ClientException(Exception):
|
class ClientException(Exception):
|
||||||
|
|
|
@ -28,7 +28,7 @@ from oslo_utils import encodeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from cloudkittyclient.openstack.common._i18n import _
|
from cloudkittyclient.i18n import _
|
||||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import prettytable
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
|
|
||||||
from cloudkittyclient.openstack.common._i18n import _
|
from cloudkittyclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
class MissingArgs(Exception):
|
class MissingArgs(Exception):
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -32,3 +32,6 @@ show-source = True
|
||||||
ignore = E123,E125,H803
|
ignore = E123,E125,H803
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
|
||||||
|
[hacking]
|
||||||
|
import_exceptions = cloudkittyclient.i18n
|
||||||
|
|
Loading…
Reference in New Issue