From 867a6ab0c381e7ca955ec0ee4a5a2ddb15a95b0a Mon Sep 17 00:00:00 2001 From: Michael Barton Date: Fri, 14 Jan 2011 08:45:39 +0000 Subject: [PATCH 1/3] i18n stuff --- swift/auth/server.py | 16 +++--- swift/common/middleware/cname_lookup.py | 12 +++-- swift/common/utils.py | 2 +- swift/proxy/server.py | 70 +++++++++++++------------ swift/stats/access_processor.py | 16 +++--- swift/stats/account_stats.py | 8 +-- swift/stats/log_processor.py | 26 +++++---- swift/stats/log_uploader.py | 20 +++---- swift/stats/stats_processor.py | 2 +- 9 files changed, 91 insertions(+), 81 deletions(-) diff --git a/swift/auth/server.py b/swift/auth/server.py index 1903035507..afd2164207 100644 --- a/swift/auth/server.py +++ b/swift/auth/server.py @@ -90,7 +90,7 @@ class AuthController(object): self.logger = get_logger(conf) self.super_admin_key = conf.get('super_admin_key') if not self.super_admin_key: - msg = 'No super_admin_key set in conf file! Exiting.' + msg = _('No super_admin_key set in conf file! Exiting.') try: self.logger.critical(msg) except: @@ -206,8 +206,9 @@ YOU HAVE A FEW OPTIONS: resp = conn.getresponse() resp.read() if resp.status // 100 != 2: - self.logger.error('ERROR attempting to create account %s: %s %s' % - (url, resp.status, resp.reason)) + self.logger.error(_('ERROR attempting to create account %(url)s:' \ + ' %(status)s %(reason)s') % + {'url': url, 'status': resp.status, 'reason': resp.reason}) return False return account_name @@ -320,7 +321,7 @@ YOU HAVE A FEW OPTIONS: (account, user)).fetchone() if row: self.logger.info( - 'ALREADY EXISTS create_user(%s, %s, _, %s, %s) [%.02f]' % + _('ALREADY EXISTS create_user(%s, %s, _, %s, %s) [%.02f]') % (repr(account), repr(user), repr(admin), repr(reseller_admin), time() - begin)) return 'already exists' @@ -334,7 +335,7 @@ YOU HAVE A FEW OPTIONS: account_hash = self.add_storage_account() if not account_hash: self.logger.info( - 'FAILED create_user(%s, %s, _, %s, %s) [%.02f]' % + _('FAILED create_user(%s, %s, _, %s, %s) [%.02f]') % (repr(account), repr(user), repr(admin), repr(reseller_admin), time() - begin)) return False @@ -347,7 +348,7 @@ YOU HAVE A FEW OPTIONS: admin and 't' or '', reseller_admin and 't' or '')) conn.commit() self.logger.info( - 'SUCCESS create_user(%s, %s, _, %s, %s) = %s [%.02f]' % + _('SUCCESS create_user(%s, %s, _, %s, %s) = %s [%.02f]') % (repr(account), repr(user), repr(admin), repr(reseller_admin), repr(url), time() - begin)) return url @@ -611,7 +612,8 @@ YOU HAVE A FEW OPTIONS: return HTTPBadRequest(request=env)(env, start_response) response = handler(req) except: - self.logger.exception('ERROR Unhandled exception in ReST request') + self.logger.exception( + _('ERROR Unhandled exception in ReST request')) return HTTPServiceUnavailable(request=req)(env, start_response) trans_time = '%.4f' % (time() - start_time) if not response.content_length and response.app_iter and \ diff --git a/swift/common/middleware/cname_lookup.py b/swift/common/middleware/cname_lookup.py index 4690bf6c79..e48d209e54 100644 --- a/swift/common/middleware/cname_lookup.py +++ b/swift/common/middleware/cname_lookup.py @@ -86,8 +86,10 @@ class CNAMELookupMiddleware(object): break elif found_domain.endswith(self.storage_domain): # Found it! - self.logger.info('Mapped %s to %s' % (given_domain, - found_domain)) + self.logger.info( + _('Mapped %(given_domain)s to %(found_domain)s') % + {'given_domain': given_domain, + 'found_domain': found_domain}) if port: env['HTTP_HOST'] = ':'.join([found_domain, port]) else: @@ -96,8 +98,10 @@ class CNAMELookupMiddleware(object): break else: # try one more deep in the chain - self.logger.debug('Following CNAME chain for %s to %s' % - (given_domain, found_domain)) + self.logger.debug(_('Following CNAME chain for ' \ + '%(given_domain)s to %(found_domain)s') % + {'given_domain': given_domain, + 'found_domain': found_domain}) a_domain = found_domain if error: if found_domain: diff --git a/swift/common/utils.py b/swift/common/utils.py index ce174e4cf5..299980493a 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -453,7 +453,7 @@ def capture_stdio(logger, **kwargs): """ # log uncaught exceptions sys.excepthook = lambda * exc_info: \ - logger.critical('UNCAUGHT EXCEPTION', exc_info=exc_info) + logger.critical(_('UNCAUGHT EXCEPTION'), exc_info=exc_info) # collect stdio file desc not in use for logging stdio_fds = [0, 1, 2] diff --git a/swift/proxy/server.py b/swift/proxy/server.py index e1d5824b4e..3dd76ccdee 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -384,8 +384,8 @@ class Controller(object): if attempts_left <= 0: break except: - self.exception_occurred(node, 'Account', - 'Trying to get account info for %s' % path) + self.exception_occurred(node, _('Account'), + _('Trying to get account info for %s') % path) if self.app.memcache and result_code in (200, 404): if result_code == 200: cache_timeout = self.app.recheck_account_existence @@ -462,8 +462,8 @@ class Controller(object): if attempts_left <= 0: break except: - self.exception_occurred(node, 'Container', - 'Trying to get container info for %s' % path) + self.exception_occurred(node, _('Container'), + _('Trying to get container info for %s') % path) if self.app.memcache and result_code in (200, 404): if result_code == 200: cache_timeout = self.app.recheck_container_existence @@ -594,7 +594,8 @@ class Controller(object): source = conn.getresponse() except: self.exception_occurred(node, server_type, - 'Trying to %s %s' % (req.method, req.path)) + _('Trying to %(method)s %(path)s') % + {'method': req.method, 'path': req.path}) continue if source.status == 507: self.error_limit(node) @@ -624,8 +625,8 @@ class Controller(object): res.client_disconnect = True self.app.logger.info(_('Client disconnected on read')) except: - self.exception_occurred(node, 'Object', - 'Trying to read during GET of %s' % req.path) + self.exception_occurred(node, _('Object'), + _('Trying to read during GET of %s') % req.path) raise res.app_iter = file_iter() update_headers(res, source.getheaders()) @@ -648,8 +649,9 @@ class Controller(object): reasons.append(source.reason) bodies.append(source.read()) if source.status >= 500: - self.error_occurred(node, 'ERROR %d %s From %s Server' % - (source.status, bodies[-1][:1024], server_type)) + self.error_occurred(node, _('ERROR %(status)d %(body)s ' \ + 'From %(type)s Server') % {'status': source.status, + 'body': bodies[-1][:1024], 'type': server_type}) return self.best_response(req, statuses, reasons, bodies, '%s %s' % (server_type, req.method)) @@ -686,12 +688,13 @@ class ObjectController(Controller): self.error_limit(node) elif response.status >= 500: self.error_occurred(node, - 'ERROR %d %s From Object Server' % - (response.status, body[:1024])) + _('ERROR %(status)d %(body)s From Object Server') % + {'status': response.status, 'body': body[:1024]}) return response.status, response.reason, body except: - self.exception_occurred(node, 'Object', - 'Trying to %s %s' % (req.method, req.path)) + self.exception_occurred(node, _('Object'), + _('Trying to %(method)s %(path)s') % + {'method': req.method, 'path': req.path}) return 500, '', '' def GETorHEAD(self, req): @@ -990,8 +993,8 @@ class ObjectController(Controller): with Timeout(self.app.node_timeout): resp = conn.getexpect() except: - self.exception_occurred(node, 'Object', - 'Expect: 100-continue on %s' % req.path) + self.exception_occurred(node, _('Object'), + _('Expect: 100-continue on %s') % req.path) if conn and resp: if resp.status == 100: conns.append(conn) @@ -1030,8 +1033,8 @@ class ObjectController(Controller): else: conn.send(chunk) except: - self.exception_occurred(conn.node, 'Object', - 'Trying to write to %s' % req.path) + self.exception_occurred(conn.node, _('Object'), + _('Trying to write to %s') % req.path) conns.remove(conn) if len(conns) <= len(nodes) / 2: self.app.logger.error( @@ -1069,13 +1072,14 @@ class ObjectController(Controller): bodies.append(response.read()) if response.status >= 500: self.error_occurred(conn.node, - 'ERROR %d %s From Object Server re: %s' % - (response.status, bodies[-1][:1024], req.path)) + _('ERROR %(status)d %(body)s From Object Server ' \ + 're: %(path)s') % {'status': response.status, + 'body': bodies[-1][:1024], 'path': req.path}) elif 200 <= response.status < 300: etags.add(response.getheader('etag').strip('"')) except: - self.exception_occurred(conn.node, 'Object', - 'Trying to get final status of PUT to %s' % req.path) + self.exception_occurred(conn.node, _('Object'), + _('Trying to get final status of PUT to %s') % req.path) if len(etags) > 1: self.app.logger.error( _('Object servers returned %s mismatched etags'), len(etags)) @@ -1286,8 +1290,8 @@ class ContainerController(Controller): accounts.insert(0, account) except: accounts.insert(0, account) - self.exception_occurred(node, 'Container', - 'Trying to PUT to %s' % req.path) + self.exception_occurred(node, _('Container'), + _('Trying to PUT to %s') % req.path) if not accounts: break while len(statuses) < len(containers): @@ -1341,8 +1345,8 @@ class ContainerController(Controller): elif source.status == 507: self.error_limit(node) except: - self.exception_occurred(node, 'Container', - 'Trying to POST %s' % req.path) + self.exception_occurred(node, _('Container'), + _('Trying to POST %s') % req.path) if len(statuses) >= len(containers): break while len(statuses) < len(containers): @@ -1398,8 +1402,8 @@ class ContainerController(Controller): accounts.insert(0, account) except: accounts.insert(0, account) - self.exception_occurred(node, 'Container', - 'Trying to DELETE %s' % req.path) + self.exception_occurred(node, _('Container'), + _('Trying to DELETE %s') % req.path) if not accounts: break while len(statuses) < len(containers): @@ -1482,8 +1486,8 @@ class AccountController(Controller): if source.status == 507: self.error_limit(node) except: - self.exception_occurred(node, 'Account', - 'Trying to PUT to %s' % req.path) + self.exception_occurred(node, _('Account'), + _('Trying to PUT to %s') % req.path) if len(statuses) >= len(accounts): break while len(statuses) < len(accounts): @@ -1530,8 +1534,8 @@ class AccountController(Controller): elif source.status == 507: self.error_limit(node) except: - self.exception_occurred(node, 'Account', - 'Trying to POST %s' % req.path) + self.exception_occurred(node, _('Account'), + _('Trying to POST %s') % req.path) if len(statuses) >= len(accounts): break while len(statuses) < len(accounts): @@ -1575,8 +1579,8 @@ class AccountController(Controller): elif source.status == 507: self.error_limit(node) except: - self.exception_occurred(node, 'Account', - 'Trying to DELETE %s' % req.path) + self.exception_occurred(node, _('Account'), + _('Trying to DELETE %s') % req.path) if len(statuses) >= len(accounts): break while len(statuses) < len(accounts): diff --git a/swift/stats/access_processor.py b/swift/stats/access_processor.py index 558709dccf..08c3971a84 100644 --- a/swift/stats/access_processor.py +++ b/swift/stats/access_processor.py @@ -59,19 +59,20 @@ class AccessLogProcessor(object): headers, processing_time) = (unquote(x) for x in raw_log[16:].split(' ')) except ValueError: - self.logger.debug('Bad line data: %s' % repr(raw_log)) + self.logger.debug(_('Bad line data: %s') % repr(raw_log)) return {} if server != self.server_name: # incorrect server name in log line - self.logger.debug('Bad server name: found "%s" expected "%s"' \ - % (server, self.server_name)) + self.logger.debug(_('Bad server name: found "%(found)s" ' \ + 'expected "%(expected)s"') % + {'found': server, 'expected': self.server_name}) return {} try: (version, account, container_name, object_name) = \ split_path(request, 2, 4, True) except ValueError, e: - self.logger.debug( - 'Invalid path: %s from data: %s' % (e, repr(raw_log))) + self.logger.debug(_('Invalid path: %(error)s from data: %(log)s') % + {'error': e, 'log': repr(raw_log)}) return {} if container_name is not None: container_name = container_name.split('?', 1)[0] @@ -194,8 +195,9 @@ class AccessLogProcessor(object): if bad_lines > (total_lines * self.warn_percent): name = '/'.join([data_object_account, data_object_container, data_object_name]) - self.logger.warning('I found a bunch of bad lines in %s '\ - '(%d bad, %d total)' % (name, bad_lines, total_lines)) + self.logger.warning(_('I found a bunch of bad lines in %(name)s '\ + '(%(bad)d bad, %(total)d total)') % + {'name': name, 'bad': bad_lines, 'total': total_lines}) return hourly_aggr_info def keylist_mapping(self): diff --git a/swift/stats/account_stats.py b/swift/stats/account_stats.py index e402bd0bc8..91d31f39ad 100644 --- a/swift/stats/account_stats.py +++ b/swift/stats/account_stats.py @@ -52,10 +52,10 @@ class AccountStat(Daemon): self.logger = get_logger(stats_conf, 'swift-account-stats-logger') def run_once(self): - self.logger.info("Gathering account stats") + self.logger.info(_("Gathering account stats")) start = time.time() self.find_and_process() - self.logger.info("Gathering account stats complete (%0.2f minutes)" % + self.logger.info(_("Gathering account stats complete (%0.2f minutes)") % ((time.time() - start) / 60)) def find_and_process(self): @@ -70,14 +70,14 @@ class AccountStat(Daemon): # Account Name, Container Count, Object Count, Bytes Used for device in os.listdir(self.devices): if self.mount_check and not check_mount(self.devices, device): - self.logger.error("Device %s is not mounted, skipping." % + self.logger.error(_("Device %s is not mounted, skipping.") % device) continue accounts = os.path.join(self.devices, device, account_server_data_dir) if not os.path.exists(accounts): - self.logger.debug("Path %s does not exist, skipping." % + self.logger.debug(_("Path %s does not exist, skipping.") % accounts) continue for root, dirs, files in os.walk(accounts, topdown=False): diff --git a/swift/stats/log_processor.py b/swift/stats/log_processor.py index 60101b7ca2..f8938ddbc2 100644 --- a/swift/stats/log_processor.py +++ b/swift/stats/log_processor.py @@ -59,7 +59,7 @@ class LogProcessor(object): module = __import__(import_target, fromlist=[import_target]) klass = getattr(module, class_name) self.plugins[plugin_name]['instance'] = klass(plugin_conf) - self.logger.debug('Loaded plugin "%s"' % plugin_name) + self.logger.debug(_('Loaded plugin "%s"') % plugin_name) @property def internal_proxy(self): @@ -76,10 +76,9 @@ class LogProcessor(object): return self._internal_proxy def process_one_file(self, plugin_name, account, container, object_name): - self.logger.info('Processing %s/%s/%s with plugin "%s"' % (account, - container, - object_name, - plugin_name)) + self.logger.info(_('Processing %(obj)s with plugin "%(plugin)s"') % + {'obj': '/'.join((account, container, object_name)), + 'plugin': plugin_name}) # get an iter of the object data compressed = object_name.endswith('.gz') stream = self.get_object_data(account, container, object_name, @@ -177,10 +176,9 @@ class LogProcessor(object): try: chunk = d.decompress(chunk) except zlib.error: - self.logger.debug('Bad compressed data for %s/%s/%s' % - (swift_account, - container_name, - object_name)) + self.logger.debug(_('Bad compressed data for %s') + % '/'.join((swift_account, container_name, + object_name))) raise BadFileDownload() # bad compressed data parts = chunk.split('\n') parts[0] = last_part + parts[0] @@ -239,7 +237,7 @@ class LogProcessorDaemon(Daemon): self.worker_count = int(c.get('worker_count', '1')) def run_once(self): - self.logger.info("Beginning log processing") + self.logger.info(_("Beginning log processing")) start = time.time() if self.lookback_hours == 0: lookback_start = None @@ -277,14 +275,14 @@ class LogProcessorDaemon(Daemon): already_processed_files = set() except: already_processed_files = set() - self.logger.debug('found %d processed files' % \ + self.logger.debug(_('found %d processed files') % \ len(already_processed_files)) logs_to_process = self.log_processor.get_data_list(lookback_start, lookback_end, already_processed_files) - self.logger.info('loaded %d files to process' % len(logs_to_process)) + self.logger.info(_('loaded %d files to process') % len(logs_to_process)) if not logs_to_process: - self.logger.info("Log processing done (%0.2f minutes)" % + self.logger.info(_("Log processing done (%0.2f minutes)") % ((time.time() - start) / 60)) return @@ -358,7 +356,7 @@ class LogProcessorDaemon(Daemon): self.log_processor_container, 'processed_files.pickle.gz') - self.logger.info("Log processing done (%0.2f minutes)" % + self.logger.info(_("Log processing done (%0.2f minutes)") % ((time.time() - start) / 60)) diff --git a/swift/stats/log_uploader.py b/swift/stats/log_uploader.py index 160c948f7f..b425738938 100644 --- a/swift/stats/log_uploader.py +++ b/swift/stats/log_uploader.py @@ -68,10 +68,10 @@ class LogUploader(Daemon): self.logger = utils.get_logger(uploader_conf, plugin_name) def run_once(self): - self.logger.info("Uploading logs") + self.logger.info(_("Uploading logs")) start = time.time() self.upload_all_logs() - self.logger.info("Uploading logs complete (%0.2f minutes)" % + self.logger.info(_("Uploading logs complete (%0.2f minutes)") % ((time.time() - start) / 60)) def upload_all_logs(self): @@ -126,22 +126,22 @@ class LogUploader(Daemon): hour = filename[slice(*hour_offset)] except IndexError: # unexpected filename format, move on - self.logger.error("Unexpected log: %s" % filename) + self.logger.error(_("Unexpected log: %s") % filename) continue if ((time.time() - os.stat(filename).st_mtime) < self.new_log_cutoff): # don't process very new logs self.logger.debug( - "Skipping log: %s (< %d seconds old)" % (filename, - self.new_log_cutoff)) + _("Skipping log: %(file)s (< %(cutoff)d seconds old)") % + {'file': filename, 'cutoff': self.new_log_cutoff}) continue self.upload_one_log(filename, year, month, day, hour) def upload_one_log(self, filename, year, month, day, hour): if os.path.getsize(filename) == 0: - self.logger.debug("Log %s is 0 length, skipping" % filename) + self.logger.debug(_("Log %s is 0 length, skipping") % filename) return - self.logger.debug("Processing log: %s" % filename) + self.logger.debug(_("Processing log: %s") % filename) filehash = hashlib.md5() already_compressed = True if filename.endswith('.gz') else False opener = gzip.open if already_compressed else open @@ -162,9 +162,9 @@ class LogUploader(Daemon): self.container_name, target_filename, compress=(not already_compressed)): - self.logger.debug("Uploaded log %s to %s" % - (filename, target_filename)) + self.logger.debug(_("Uploaded log %(file)s to %(target)s") % + {'file': filename, 'target': target_filename}) if self.unlink_log: os.unlink(filename) else: - self.logger.error("ERROR: Upload of log %s failed!" % filename) + self.logger.error(_("ERROR: Upload of log %s failed!") % filename) diff --git a/swift/stats/stats_processor.py b/swift/stats/stats_processor.py index 7854c83572..dc07d85199 100644 --- a/swift/stats/stats_processor.py +++ b/swift/stats/stats_processor.py @@ -37,7 +37,7 @@ class StatsLogProcessor(object): bytes_used) = line.split(',') except (IndexError, ValueError): # bad line data - self.logger.debug('Bad line data: %s' % repr(line)) + self.logger.debug(_('Bad line data: %s') % repr(line)) continue account = account.strip('"') container_count = int(container_count.strip('"')) From fbb0241df493849b3d6fb148a664aa147724f9fd Mon Sep 17 00:00:00 2001 From: Michael Barton Date: Fri, 14 Jan 2011 11:17:33 +0000 Subject: [PATCH 2/3] few more from proxy --- swift/proxy/server.py | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 3dd76ccdee..f426bea16c 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -161,13 +161,13 @@ class SegmentedIterable(object): if self.segment > 10: sleep(max(self.next_get_time - time.time(), 0)) self.next_get_time = time.time() + 1 - resp = self.controller.GETorHEAD_base(req, 'Object', partition, + resp = self.controller.GETorHEAD_base(req, _('Object'), partition, self.controller.iter_nodes(partition, nodes, self.controller.app.object_ring), path, self.controller.app.object_ring.replica_count) if resp.status_int // 100 != 2: - raise Exception('Could not load object segment %s: %s' % (path, - resp.status_int)) + raise Exception(_('Could not load object segment %(path)s:' \ + ' %(status)s') % {'path': path, 'status': resp.status_int}) self.segment_iter = resp.app_iter except StopIteration: raise @@ -707,7 +707,7 @@ class ObjectController(Controller): return aresp partition, nodes = self.app.object_ring.get_nodes( self.account_name, self.container_name, self.object_name) - resp = self.GETorHEAD_base(req, 'Object', partition, + resp = self.GETorHEAD_base(req, _('Object'), partition, self.iter_nodes(partition, nodes, self.app.object_ring), req.path_info, self.app.object_ring.replica_count) # If we get a 416 Requested Range Not Satisfiable we have to check if @@ -716,7 +716,7 @@ class ObjectController(Controller): if resp.status_int == 416: req_range = req.range req.range = None - resp2 = self.GETorHEAD_base(req, 'Object', partition, + resp2 = self.GETorHEAD_base(req, _('Object'), partition, self.iter_nodes(partition, nodes, self.app.object_ring), req.path_info, self.app.object_ring.replica_count) if 'x-object-manifest' not in resp2.headers: @@ -735,7 +735,7 @@ class ObjectController(Controller): lreq = Request.blank('/%s/%s?prefix=%s&format=json&marker=%s' % (quote(self.account_name), quote(lcontainer), quote(lprefix), quote(marker))) - lresp = self.GETorHEAD_base(lreq, 'Container', lpartition, + lresp = self.GETorHEAD_base(lreq, _('Container'), lpartition, lnodes, lreq.path_info, self.app.container_ring.replica_count) if lresp.status_int // 100 != 2: @@ -767,19 +767,19 @@ class ObjectController(Controller): '/%s/%s?prefix=%s&format=json&marker=%s' % (quote(self.account_name), quote(lcontainer), quote(lprefix), quote(marker))) - lresp = self.GETorHEAD_base(lreq, 'Container', + lresp = self.GETorHEAD_base(lreq, _('Container'), lpartition, lnodes, lreq.path_info, self.app.container_ring.replica_count) if lresp.status_int // 100 != 2: - raise Exception('Object manifest GET could not ' - 'continue listing: %s %s' % + raise Exception(_('Object manifest GET could not ' + 'continue listing: %s %s') % (req.path, lreq.path)) if 'swift.authorize' in req.environ: req.acl = lresp.headers.get('x-container-read') aresp = req.environ['swift.authorize'](req) if aresp: - raise Exception('Object manifest GET could ' - 'not continue listing: %s %s' % + raise Exception(_('Object manifest GET could ' + 'not continue listing: %s %s') % (req.path, aresp)) sublisting = json.loads(lresp.body) if not sublisting: @@ -894,7 +894,7 @@ class ObjectController(Controller): reasons.append('') bodies.append('') return self.best_response(req, statuses, reasons, - bodies, 'Object POST') + bodies, _('Object POST')) @public @delay_denial @@ -1089,8 +1089,8 @@ class ObjectController(Controller): statuses.append(503) reasons.append('') bodies.append('') - resp = self.best_response(req, statuses, reasons, bodies, 'Object PUT', - etag=etag) + resp = self.best_response(req, statuses, reasons, bodies, + _('Object PUT'), etag=etag) if source_header: resp.headers['X-Copied-From'] = quote( source_header.split('/', 2)[2]) @@ -1142,7 +1142,7 @@ class ObjectController(Controller): reasons.append('') bodies.append('') return self.best_response(req, statuses, reasons, bodies, - 'Object DELETE') + _('Object DELETE')) @public @delay_denial @@ -1203,7 +1203,7 @@ class ContainerController(Controller): return HTTPNotFound(request=req) part, nodes = self.app.container_ring.get_nodes( self.account_name, self.container_name) - resp = self.GETorHEAD_base(req, 'Container', part, nodes, + resp = self.GETorHEAD_base(req, _('Container'), part, nodes, req.path_info, self.app.container_ring.replica_count) if self.app.memcache: @@ -1303,7 +1303,7 @@ class ContainerController(Controller): self.container_name) self.app.memcache.delete(cache_key) return self.best_response(req, statuses, reasons, bodies, - 'Container PUT') + _('Container PUT')) @public def POST(self, req): @@ -1358,7 +1358,7 @@ class ContainerController(Controller): self.container_name) self.app.memcache.delete(cache_key) return self.best_response(req, statuses, reasons, bodies, - 'Container POST') + _('Container POST')) @public def DELETE(self, req): @@ -1415,7 +1415,7 @@ class ContainerController(Controller): self.container_name) self.app.memcache.delete(cache_key) resp = self.best_response(req, statuses, reasons, bodies, - 'Container DELETE') + _('Container DELETE')) if 200 <= resp.status_int <= 299: for status in statuses: if status < 200 or status > 299: @@ -1440,7 +1440,7 @@ class AccountController(Controller): def GETorHEAD(self, req): """Handler for HTTP GET/HEAD requests.""" partition, nodes = self.app.account_ring.get_nodes(self.account_name) - return self.GETorHEAD_base(req, 'Account', partition, nodes, + return self.GETorHEAD_base(req, _('Account'), partition, nodes, req.path_info.rstrip('/'), self.app.account_ring.replica_count) @public @@ -1497,7 +1497,7 @@ class AccountController(Controller): if self.app.memcache: self.app.memcache.delete('account%s' % req.path_info.rstrip('/')) return self.best_response(req, statuses, reasons, bodies, - 'Account PUT') + _('Account PUT')) @public def POST(self, req): @@ -1545,7 +1545,7 @@ class AccountController(Controller): if self.app.memcache: self.app.memcache.delete('account%s' % req.path_info.rstrip('/')) return self.best_response(req, statuses, reasons, bodies, - 'Account POST') + _('Account POST')) @public def DELETE(self, req): @@ -1590,7 +1590,7 @@ class AccountController(Controller): if self.app.memcache: self.app.memcache.delete('account%s' % req.path_info.rstrip('/')) return self.best_response(req, statuses, reasons, bodies, - 'Account DELETE') + _('Account DELETE')) class BaseApplication(object): From 4cf7ec25d752cac2bb21cc87fc5cf206a63face7 Mon Sep 17 00:00:00 2001 From: Michael Barton Date: Fri, 14 Jan 2011 11:30:17 +0000 Subject: [PATCH 3/3] missed things --- swift/account/reaper.py | 18 +++++++++--------- swift/auth/server.py | 10 +++++----- swift/container/updater.py | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/swift/account/reaper.py b/swift/account/reaper.py index 02e32506f0..d31558b9c6 100644 --- a/swift/account/reaper.py +++ b/swift/account/reaper.py @@ -241,28 +241,28 @@ class AccountReaper(Daemon): except Exception: self.logger.exception( _('Exception with account %s'), account) - log = 'Incomplete pass on account %s' % account + log = _('Incomplete pass on account %s') % account if self.stats_containers_deleted: - log += ', %s containers deleted' % self.stats_containers_deleted + log += _(', %s containers deleted') % self.stats_containers_deleted if self.stats_objects_deleted: - log += ', %s objects deleted' % self.stats_objects_deleted + log += _(', %s objects deleted') % self.stats_objects_deleted if self.stats_containers_remaining: - log += ', %s containers remaining' % \ + log += _(', %s containers remaining') % \ self.stats_containers_remaining if self.stats_objects_remaining: - log += ', %s objects remaining' % self.stats_objects_remaining + log += _(', %s objects remaining') % self.stats_objects_remaining if self.stats_containers_possibly_remaining: - log += ', %s containers possibly remaining' % \ + log += _(', %s containers possibly remaining') % \ self.stats_containers_possibly_remaining if self.stats_objects_possibly_remaining: - log += ', %s objects possibly remaining' % \ + log += _(', %s objects possibly remaining') % \ self.stats_objects_possibly_remaining if self.stats_return_codes: - log += ', return codes: ' + log += _(', return codes: ') for code in sorted(self.stats_return_codes.keys()): log += '%s %sxxs, ' % (self.stats_return_codes[code], code) log = log[:-2] - log += ', elapsed: %.02fs' % (time() - begin) + log += _(', elapsed: %.02fs') % (time() - begin) self.logger.info(log) def reap_container(self, account, account_partition, account_nodes, diff --git a/swift/auth/server.py b/swift/auth/server.py index afd2164207..0582d9cfda 100644 --- a/swift/auth/server.py +++ b/swift/auth/server.py @@ -146,7 +146,7 @@ class AuthController(object): previous_prefix = '' if '_' in row[0]: previous_prefix = row[0].split('_', 1)[0] - msg = (''' + msg = _((''' THERE ARE ACCOUNTS IN YOUR auth.db THAT DO NOT BEGIN WITH YOUR NEW RESELLER PREFIX OF "%s". YOU HAVE A FEW OPTIONS: @@ -164,14 +164,14 @@ YOU HAVE A FEW OPTIONS: TO REVERT BACK TO YOUR PREVIOUS RESELLER PREFIX. %s - ''' % (self.reseller_prefix.rstrip('_'), self.db_file, + ''') % (self.reseller_prefix.rstrip('_'), self.db_file, self.reseller_prefix.rstrip('_'), self.db_file, - previous_prefix, previous_prefix and ' ' or ''' + previous_prefix, previous_prefix and ' ' or _(''' SINCE YOUR PREVIOUS RESELLER PREFIX WAS AN EMPTY STRING, IT IS NOT RECOMMENDED TO PERFORM OPTION 3 AS THAT WOULD MAKE SUPPORTING MULTIPLE RESELLERS MORE DIFFICULT. - '''.strip())).strip() - self.logger.critical('CRITICAL: ' + ' '.join(msg.split())) + ''').strip())).strip() + self.logger.critical(_('CRITICAL: ') + ' '.join(msg.split())) raise Exception('\n' + msg) def add_storage_account(self, account_name=''): diff --git a/swift/container/updater.py b/swift/container/updater.py index 9dacea32d1..d6b1beb2b1 100644 --- a/swift/container/updater.py +++ b/swift/container/updater.py @@ -127,7 +127,7 @@ class ContainerUpdater(Daemon): Run the updater once. """ patcher.monkey_patch(all=False, socket=True) - self.logger.info('Begin container update single threaded sweep') + self.logger.info(_('Begin container update single threaded sweep')) begin = time.time() self.no_changes = 0 self.successes = 0