Merge "Added undescore function to some strings"
This commit is contained in:
commit
8e5ca0efb2
@ -70,12 +70,13 @@ def validate_image_meta(req, values):
|
||||
|
||||
if 'disk_format' in values:
|
||||
if disk_format not in CONF.image_format.disk_formats:
|
||||
msg = "Invalid disk format '%s' for image." % disk_format
|
||||
msg = _("Invalid disk format '%s' for image.") % disk_format
|
||||
raise HTTPBadRequest(explanation=msg, request=req)
|
||||
|
||||
if 'container_format' in values:
|
||||
if container_format not in CONF.image_format.container_formats:
|
||||
msg = "Invalid container format '%s' for image." % container_format
|
||||
msg = _("Invalid container format '%s' "
|
||||
"for image.") % container_format
|
||||
raise HTTPBadRequest(explanation=msg, request=req)
|
||||
|
||||
if name and len(name) > 255:
|
||||
@ -376,9 +377,10 @@ class Controller(controller.BaseController):
|
||||
if param in SUPPORTED_FILTERS or param.startswith('property-'):
|
||||
query_filters[param] = req.params.get(param)
|
||||
if not filters.validate(param, query_filters[param]):
|
||||
raise HTTPBadRequest('Bad value passed to filter %s '
|
||||
'got %s' % (param,
|
||||
query_filters[param]))
|
||||
raise HTTPBadRequest(_('Bad value passed to filter '
|
||||
'%(filter)s got %(val)s')
|
||||
% {'filter': param,
|
||||
'val': query_filters[param]})
|
||||
return query_filters
|
||||
|
||||
def meta(self, req, id):
|
||||
@ -631,9 +633,9 @@ class Controller(controller.BaseController):
|
||||
except exception.Duplicate:
|
||||
# Delete image data since it has been supersceded by another
|
||||
# upload.
|
||||
LOG.debug("duplicate operation - deleting image data for %s "
|
||||
"(location:%s)" %
|
||||
(image_id, image_meta['location']))
|
||||
LOG.debug(_("duplicate operation - deleting image data for %(id)s "
|
||||
"(location:%(location)s)") %
|
||||
{'id': image_id, 'location': image_meta['location']})
|
||||
upload_utils.initiate_deletion(req, image_meta['location'],
|
||||
image_id, CONF.delayed_delete)
|
||||
# Then propagate the exception.
|
||||
|
@ -194,7 +194,7 @@ class ImagesController(object):
|
||||
except exception.Forbidden as e:
|
||||
raise webob.exc.HTTPForbidden(explanation=unicode(e))
|
||||
except exception.NotFound as e:
|
||||
msg = ("Failed to find image %(image_id)s to delete" %
|
||||
msg = (_("Failed to find image %(image_id)s to delete") %
|
||||
{'image_id': image_id})
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
@ -293,7 +293,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
||||
def _check_allowed(cls, image):
|
||||
for key in cls._disallowed_properties:
|
||||
if key in image:
|
||||
msg = "Attribute \'%s\' is read-only." % key
|
||||
msg = _("Attribute '%s' is read-only.") % key
|
||||
raise webob.exc.HTTPForbidden(explanation=unicode(msg))
|
||||
|
||||
def create(self, request):
|
||||
@ -392,10 +392,10 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
||||
def _validate_change(self, change):
|
||||
path_root = change['path'][0]
|
||||
if path_root in self._readonly_properties:
|
||||
msg = "Attribute \'%s\' is read-only." % path_root
|
||||
msg = _("Attribute '%s' is read-only.") % path_root
|
||||
raise webob.exc.HTTPForbidden(explanation=unicode(msg))
|
||||
if path_root in self._reserved_properties:
|
||||
msg = "Attribute \'%s\' is reserved." % path_root
|
||||
msg = _("Attribute '%s' is reserved.") % path_root
|
||||
raise webob.exc.HTTPForbidden(explanation=unicode(msg))
|
||||
|
||||
if change['op'] == 'delete':
|
||||
|
@ -99,11 +99,11 @@ def do_start(verb, pid_file, server, args):
|
||||
if verb != 'Respawn' and pid_file == CONF.pid_file:
|
||||
for pid_file, pid in pid_files(server, pid_file):
|
||||
if os.path.exists('/proc/%s' % pid):
|
||||
print("%s appears to already be running: %s" %
|
||||
(server, pid_file))
|
||||
print(_("%(serv)s appears to already be running: %(pid)s") %
|
||||
{'serv': server, 'pid': pid_file})
|
||||
return
|
||||
else:
|
||||
print("Removing stale pid file %s" % pid_file)
|
||||
print(_("Removing stale pid file %s") % pid_file)
|
||||
os.unlink(pid_file)
|
||||
|
||||
try:
|
||||
@ -112,8 +112,8 @@ def do_start(verb, pid_file, server, args):
|
||||
resource.setrlimit(resource.RLIMIT_DATA,
|
||||
(MAX_MEMORY, MAX_MEMORY))
|
||||
except ValueError:
|
||||
action = 'increase file descriptor limit'
|
||||
print('Unable to %s. Running as non-root?' % action)
|
||||
print(_('Unable to increase file descriptor limit. '
|
||||
'Running as non-root?'))
|
||||
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
|
||||
|
||||
def write_pid_file(pid_file, pid):
|
||||
@ -158,7 +158,7 @@ def do_start(verb, pid_file, server, args):
|
||||
|
||||
def launch(pid_file, conf_file=None, capture_output=False, await_time=0):
|
||||
args = [server]
|
||||
msg = '%sing %s' % (verb, server)
|
||||
msg = (_('%(verb)sing %(serv)s') % {'verb': verb, 'serv': server})
|
||||
if conf_file:
|
||||
args += ['--config-file', conf_file]
|
||||
msg += 'with %s' % conf_file
|
||||
@ -173,7 +173,8 @@ def do_start(verb, pid_file, server, args):
|
||||
try:
|
||||
os.execlp('%s' % server, *args)
|
||||
except OSError as e:
|
||||
msg = 'unable to launch %s. Got error: %s' % (server, e)
|
||||
msg = (_('unable to launch %(serv)s. Got error: %(e)s') %
|
||||
{'serv': server, 'e': e})
|
||||
sys.exit(msg)
|
||||
sys.exit(0)
|
||||
else:
|
||||
@ -202,9 +203,10 @@ def do_start(verb, pid_file, server, args):
|
||||
def do_check_status(pid_file, server):
|
||||
if os.path.exists(pid_file):
|
||||
pid = open(pid_file).read().strip()
|
||||
print("%s (pid %s) is running..." % (server, pid))
|
||||
print(_("%(serv)s (pid %(pid)s) is running...") %
|
||||
{'serv': server, 'pid': pid})
|
||||
else:
|
||||
print("%s is stopped" % server)
|
||||
print(_("%s is stopped") % server)
|
||||
|
||||
|
||||
def get_pid_file(server, pid_file):
|
||||
@ -220,10 +222,15 @@ def get_pid_file(server, pid_file):
|
||||
|
||||
if not os.access(dir, os.W_OK):
|
||||
fallback = os.path.join(tempfile.mkdtemp(), '%s.pid' % server)
|
||||
msg = ('Unable to create pid file %s. Running as non-root?\n'
|
||||
'Falling back to a temp file, you can stop %s service using:\n'
|
||||
' %s %s stop --pid-file %s'
|
||||
% (pid_file, server, __file__, server, fallback))
|
||||
msg = (_('Unable to create pid file %(pid)s. Running as non-root?\n'
|
||||
'Falling back to a temp file, you can stop %(service)s '
|
||||
'service using:\n'
|
||||
' %(file)s %(server)s stop --pid-file %(fb)s') %
|
||||
{'pid': pid_file,
|
||||
'service': server,
|
||||
'file': __file__,
|
||||
'server': server,
|
||||
'fb': fallback})
|
||||
print(msg)
|
||||
pid_file = fallback
|
||||
|
||||
@ -245,20 +252,21 @@ def do_stop(server, args, graceful=False):
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
print('Stopping %s (pid %s) with signal(%s)' % (server, pid, sig))
|
||||
print(_('Stopping %(serv)s (pid %(pid)s) with signal(%(sig)s)')
|
||||
% {'serv': server, 'pid': pid, 'sig': sig})
|
||||
os.kill(pid, sig)
|
||||
except OSError:
|
||||
print("Process %d not running" % pid)
|
||||
print(_("Process %d not running") % pid)
|
||||
for pid_file, pid in pfiles:
|
||||
for _junk in xrange(150): # 15 seconds
|
||||
if not os.path.exists('/proc/%s' % pid):
|
||||
break
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
print('Waited 15 seconds for pid %s (%s) to die; giving up' %
|
||||
(pid, pid_file))
|
||||
print(_('Waited 15 seconds for pid %(pid)s (%(file)s) to die;'
|
||||
' giving up') % {'pid': pid, 'file': pid_file})
|
||||
if not did_anything:
|
||||
print('%s is already stopped' % server)
|
||||
print(_('%s is already stopped') % server)
|
||||
|
||||
|
||||
def add_command_parsers(subparsers):
|
||||
@ -335,7 +343,8 @@ def main():
|
||||
children[new_pid] = args
|
||||
else:
|
||||
rsn = 'bouncing' if bouncing else 'deliberately stopped'
|
||||
print('Supressed respawn as %s was %s.' % (server, rsn))
|
||||
print(_('Supressed respawn as %(serv)s was %(rsn)s.')
|
||||
% {'serv': server, 'rsn': rsn})
|
||||
|
||||
if CONF.server.command == 'start':
|
||||
children = {}
|
||||
|
@ -172,7 +172,7 @@ def _get_deployment_config_file():
|
||||
if not path:
|
||||
path = _get_paste_config_path()
|
||||
if not path:
|
||||
msg = "Unable to locate paste config file for %s." % CONF.prog
|
||||
msg = _("Unable to locate paste config file for %s.") % CONF.prog
|
||||
raise RuntimeError(msg)
|
||||
return os.path.abspath(path)
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ImageFactory(object):
|
||||
|
||||
def _check_unexpected(self, kwargs):
|
||||
if kwargs:
|
||||
msg = 'new_image() got unexpected keywords %s'
|
||||
msg = _('new_image() got unexpected keywords %s')
|
||||
raise TypeError(msg % kwargs.keys())
|
||||
|
||||
def _check_reserved(self, properties):
|
||||
@ -126,7 +126,7 @@ class Image(object):
|
||||
self.extra_properties = ExtraProperties(extra_properties)
|
||||
self.tags = kwargs.pop('tags', None) or []
|
||||
if kwargs:
|
||||
message = "__init__() got unexpected keyword argument '%s'"
|
||||
message = _("__init__() got unexpected keyword argument '%s'")
|
||||
raise TypeError(message % kwargs.keys()[0])
|
||||
|
||||
@property
|
||||
@ -168,7 +168,8 @@ class Image(object):
|
||||
@visibility.setter
|
||||
def visibility(self, visibility):
|
||||
if visibility not in ('public', 'private'):
|
||||
raise ValueError('Visibility must be either "public" or "private"')
|
||||
raise ValueError(_('Visibility must be either "public" '
|
||||
'or "private"'))
|
||||
self._visibility = visibility
|
||||
|
||||
@property
|
||||
@ -210,7 +211,7 @@ class Image(object):
|
||||
@min_disk.setter
|
||||
def min_disk(self, value):
|
||||
if value and value < 0:
|
||||
extra_msg = 'Cannot be a negative value'
|
||||
extra_msg = _('Cannot be a negative value')
|
||||
raise exception.InvalidParameterValue(value=value,
|
||||
param='min_disk',
|
||||
extra_msg=extra_msg)
|
||||
@ -223,7 +224,7 @@ class Image(object):
|
||||
@min_ram.setter
|
||||
def min_ram(self, value):
|
||||
if value and value < 0:
|
||||
extra_msg = 'Cannot be a negative value'
|
||||
extra_msg = _('Cannot be a negative value')
|
||||
raise exception.InvalidParameterValue(value=value,
|
||||
param='min_ram',
|
||||
extra_msg=extra_msg)
|
||||
|
@ -114,8 +114,8 @@ def get_client(host, port=None, timeout=None, use_ssl=False, username=None,
|
||||
}
|
||||
|
||||
if creds['strategy'] == 'keystone' and not creds['auth_url']:
|
||||
msg = ("--os_auth_url option or OS_AUTH_URL environment variable "
|
||||
"required when keystone authentication strategy is enabled\n")
|
||||
msg = _("--os_auth_url option or OS_AUTH_URL environment variable "
|
||||
"required when keystone authentication strategy is enabled\n")
|
||||
raise exception.ClientConfigurationError(msg)
|
||||
|
||||
return CacheClient(
|
||||
|
Loading…
x
Reference in New Issue
Block a user