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 cloudkittyclient import exc
|
||||
from cloudkittyclient.i18n import _
|
||||
from cloudkittyclient.openstack.common.apiclient import base
|
||||
|
||||
|
||||
|
@ -138,7 +139,7 @@ class CrudManager(base.CrudManager):
|
|||
'name': self.resource_class.__name__,
|
||||
'args': kwargs
|
||||
}
|
||||
raise exc.NotFound(404, msg)
|
||||
raise exc.HTTPNotFound(msg)
|
||||
return rl
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import prettytable
|
|||
import six
|
||||
|
||||
from cloudkittyclient import exc
|
||||
from cloudkittyclient.i18n import _
|
||||
from cloudkittyclient.openstack.common import cliutils
|
||||
|
||||
|
||||
|
@ -142,8 +143,10 @@ def find_resource(manager, name_or_id):
|
|||
try:
|
||||
return manager.find(name=name_or_id)
|
||||
except exc.HTTPNotFound:
|
||||
msg = ("No %s with a name or ID of '%s' exists." %
|
||||
(manager.resource_class.__name__.lower(), name_or_id))
|
||||
msg = _("No %(name)s with a name or ID of '%(id)s' exists.") % {
|
||||
"name": manager.resource_class.__name__.lower(),
|
||||
"id": name_or_id
|
||||
}
|
||||
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)
|
||||
for v in values_to_convert)
|
||||
except ValueError:
|
||||
raise exc.CommandError(
|
||||
'%s must be a list of key=value not "%s"' % (
|
||||
key_to_convert, values_to_convert))
|
||||
msg = _("%(key)s must be a list of key=value "
|
||||
"not '%(value)s'") % {
|
||||
"key": key_to_convert,
|
||||
"value": values_to_convert
|
||||
}
|
||||
raise exc.CommandError(msg)
|
||||
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
|
||||
kwargs[key_to_convert].append(dct)
|
||||
except Exception:
|
||||
raise exc.CommandError(
|
||||
'%s must be a list of key1=value1;key2=value2;... not "%s"' % (
|
||||
key_to_convert, values_to_convert))
|
||||
msg = _("%(key)s must be a list of "
|
||||
"key1=value1;key2=value2;... not '%(value)s'") % {
|
||||
"key": key_to_convert,
|
||||
"value": values_to_convert
|
||||
}
|
||||
raise exc.CommandError(msg)
|
||||
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
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from cloudkittyclient.openstack.common._i18n import _
|
||||
from cloudkittyclient.i18n import _
|
||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ from oslo_utils import encodeutils
|
|||
from oslo_utils import importutils
|
||||
import requests
|
||||
|
||||
from cloudkittyclient.openstack.common._i18n import _
|
||||
from cloudkittyclient.i18n import _
|
||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -38,7 +38,7 @@ import sys
|
|||
|
||||
import six
|
||||
|
||||
from cloudkittyclient.openstack.common._i18n import _
|
||||
from cloudkittyclient.i18n import _
|
||||
|
||||
|
||||
class ClientException(Exception):
|
||||
|
|
|
@ -28,7 +28,7 @@ from oslo_utils import encodeutils
|
|||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from cloudkittyclient.openstack.common._i18n import _
|
||||
from cloudkittyclient.i18n import _
|
||||
from cloudkittyclient.openstack.common.apiclient import exceptions
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import prettytable
|
|||
import six
|
||||
from six import moves
|
||||
|
||||
from cloudkittyclient.openstack.common._i18n import _
|
||||
from cloudkittyclient.i18n import _
|
||||
|
||||
|
||||
class MissingArgs(Exception):
|
||||
|
|
Loading…
Reference in New Issue