From e54846d850b66869811b84a71ecd93e66badaba5 Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Wed, 29 Dec 2010 13:14:43 -0600 Subject: [PATCH 1/2] made this i18n importing sane --- swift/__init__.py | 2 ++ swift/common/daemon.py | 2 -- swift/common/wsgi.py | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/swift/__init__.py b/swift/__init__.py index 1a72d32e57..65989fb130 100644 --- a/swift/__init__.py +++ b/swift/__init__.py @@ -1 +1,3 @@ __version__ = '1.1.0' +import gettext +gettext.install('swift') diff --git a/swift/common/daemon.py b/swift/common/daemon.py index e5ed3f7caa..0f7df064c7 100644 --- a/swift/common/daemon.py +++ b/swift/common/daemon.py @@ -16,7 +16,6 @@ import os import sys import signal -import gettext from re import sub from swift.common import utils @@ -42,7 +41,6 @@ class Daemon(object): utils.validate_configuration() utils.capture_stdio(self.logger, **kwargs) utils.drop_privileges(self.conf.get('user', 'swift')) - gettext.install('swift', unicode=1) def kill_children(*args): signal.signal(signal.SIGTERM, signal.SIG_IGN) diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 079e4277e1..a93c21aa8a 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -21,7 +21,6 @@ import signal import sys import time import mimetools -import gettext import eventlet from eventlet import greenio, GreenPool, sleep, wsgi, listen @@ -121,7 +120,6 @@ def run_wsgi(conf_file, app_section, *args, **kwargs): sock = get_socket(conf, default_port=kwargs.get('default_port', 8080)) # remaining tasks should not require elevated privileges drop_privileges(conf.get('user', 'swift')) - gettext.install('swift', unicode=1) # finally after binding to ports and privilege drop, run app __init__ code app = loadapp('config:%s' % conf_file, global_conf={'log_name': log_name}) From 57970bdeb59ac17d17a59fa2d2dcefac729eaf0d Mon Sep 17 00:00:00 2001 From: gholt Date: Wed, 29 Dec 2010 12:00:08 -0800 Subject: [PATCH 2/2] Cleaned up the bins; patched the broken test (when run standalone) --- bin/st | 2 -- bin/swift-account-audit | 2 -- bin/swift-auth-add-user | 2 -- bin/swift-auth-recreate-accounts | 2 -- bin/swift-auth-update-reseller-prefixes | 2 -- bin/swift-bench | 2 -- bin/swift-drive-audit | 2 -- bin/swift-get-nodes | 3 --- bin/swift-log-uploader | 2 -- bin/swift-object-info | 2 -- bin/swift-ring-builder | 2 -- bin/swift-stats-populate | 2 -- bin/swift-stats-report | 2 -- swift/__init__.py | 4 +++- test/unit/container/test_updater.py | 2 ++ 15 files changed, 5 insertions(+), 28 deletions(-) diff --git a/bin/st b/bin/st index 79f331558f..b41aca67ec 100755 --- a/bin/st +++ b/bin/st @@ -44,8 +44,6 @@ except: try: from swift.common.bufferedhttp \ import BufferedHTTPConnection as HTTPConnection - import gettext - gettext.install('swift', unicode=1) except: from httplib import HTTPConnection diff --git a/bin/swift-account-audit b/bin/swift-account-audit index 1f6aceb2c8..fe611562d7 100755 --- a/bin/swift-account-audit +++ b/bin/swift-account-audit @@ -20,7 +20,6 @@ from urllib import quote from hashlib import md5 import getopt from itertools import chain -import gettext import simplejson from eventlet.greenpool import GreenPool @@ -325,7 +324,6 @@ class Auditor(object): if __name__ == '__main__': - gettext.install('swift', unicode=1) try: optlist, args = getopt.getopt(sys.argv[1:], 'c:r:e:d') except getopt.GetoptError, err: diff --git a/bin/swift-auth-add-user b/bin/swift-auth-add-user index 2d9819dfc8..d502dc83a8 100755 --- a/bin/swift-auth-add-user +++ b/bin/swift-auth-add-user @@ -18,13 +18,11 @@ from ConfigParser import ConfigParser from optparse import OptionParser from os.path import basename from sys import argv, exit -import gettext from swift.common.bufferedhttp import http_connect_raw as http_connect if __name__ == '__main__': - gettext.install('swift', unicode=1) default_conf = '/etc/swift/auth-server.conf' parser = OptionParser( usage='Usage: %prog [options] ') diff --git a/bin/swift-auth-recreate-accounts b/bin/swift-auth-recreate-accounts index a8ee20e0e8..e17bf2da3b 100755 --- a/bin/swift-auth-recreate-accounts +++ b/bin/swift-auth-recreate-accounts @@ -17,12 +17,10 @@ from ConfigParser import ConfigParser from optparse import OptionParser from sys import argv, exit -import gettext from swift.common.bufferedhttp import http_connect_raw as http_connect if __name__ == '__main__': - gettext.install('swift', unicode=1) default_conf = '/etc/swift/auth-server.conf' parser = OptionParser(usage='Usage: %prog [options]') parser.add_option('-c', '--conf', dest='conf', default=default_conf, diff --git a/bin/swift-auth-update-reseller-prefixes b/bin/swift-auth-update-reseller-prefixes index cb09bd9872..41a4bf6a76 100755 --- a/bin/swift-auth-update-reseller-prefixes +++ b/bin/swift-auth-update-reseller-prefixes @@ -16,13 +16,11 @@ from os.path import basename from sys import argv, exit -import gettext from swift.common.db import get_db_connection if __name__ == '__main__': - gettext.install('swift', unicode=1) app = basename(argv[0]) if len(argv) != 3: exit(''' diff --git a/bin/swift-bench b/bin/swift-bench index 2c3e08318b..ab332482cd 100755 --- a/bin/swift-bench +++ b/bin/swift-bench @@ -20,7 +20,6 @@ import sys import signal import uuid from optparse import OptionParser -import gettext from swift.common.bench import BenchController from swift.common.utils import readconf, NamedLogger @@ -56,7 +55,6 @@ SAIO_DEFAULTS = { } if __name__ == '__main__': - gettext.install('swift', unicode=1) usage = "usage: %prog [OPTIONS] [CONF_FILE]" usage += """\n\nConf file with SAIO defaults: diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index 64c478e203..cde28c1ed7 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -20,7 +20,6 @@ import re import subprocess import sys from ConfigParser import ConfigParser -import gettext from swift.common.utils import get_logger @@ -87,7 +86,6 @@ def comment_fstab(mount_point): os.rename('/etc/fstab.new', '/etc/fstab') if __name__ == '__main__': - gettext.install('swift', unicode=1) c = ConfigParser() try: conf_path = sys.argv[1] diff --git a/bin/swift-get-nodes b/bin/swift-get-nodes index 69643f6a84..f24dd48f96 100755 --- a/bin/swift-get-nodes +++ b/bin/swift-get-nodes @@ -16,14 +16,11 @@ import sys import urllib -import gettext from swift.common.ring import Ring from swift.common.utils import hash_path -gettext.install('swift', unicode=1) - if len(sys.argv) < 3 or len(sys.argv) > 5: print 'Usage: %s [] []' \ % sys.argv[0] diff --git a/bin/swift-log-uploader b/bin/swift-log-uploader index 972303f67b..e533cad824 100755 --- a/bin/swift-log-uploader +++ b/bin/swift-log-uploader @@ -15,14 +15,12 @@ # limitations under the License. import sys -import gettext from swift.stats.log_uploader import LogUploader from swift.common.utils import parse_options from swift.common import utils if __name__ == '__main__': - gettext.install('swift', unicode=1) conf_file, options = parse_options(usage="Usage: %prog CONFIG_FILE PLUGIN") try: plugin = options['extra_args'][0] diff --git a/bin/swift-object-info b/bin/swift-object-info index 268b991bee..57f2522071 100755 --- a/bin/swift-object-info +++ b/bin/swift-object-info @@ -18,14 +18,12 @@ import sys import cPickle as pickle from datetime import datetime from hashlib import md5 -import gettext from swift.common.ring import Ring from swift.obj.server import read_metadata from swift.common.utils import hash_path if __name__ == '__main__': - gettext.install('swift', unicode=1) if len(sys.argv) <= 1: print "Usage: %s OBJECT_FILE" % sys.argv[0] sys.exit(1) diff --git a/bin/swift-ring-builder b/bin/swift-ring-builder index 1d53a30973..50353df256 100755 --- a/bin/swift-ring-builder +++ b/bin/swift-ring-builder @@ -21,7 +21,6 @@ from os import mkdir from os.path import basename, dirname, exists, join as pathjoin from sys import argv, exit from time import time -import gettext from swift.common.ring import RingBuilder @@ -175,7 +174,6 @@ swift-ring-builder set_min_part_hours if __name__ == '__main__': - gettext.install('swift', unicode=1) if len(argv) < 2: print ''' swift-ring-builder %(MAJOR_VERSION)s.%(MINOR_VERSION)s diff --git a/bin/swift-stats-populate b/bin/swift-stats-populate index 985fa50c82..8ea210cb65 100755 --- a/bin/swift-stats-populate +++ b/bin/swift-stats-populate @@ -21,7 +21,6 @@ from optparse import OptionParser from sys import exit, argv from time import time from uuid import uuid4 -import gettext from eventlet import GreenPool, patcher, sleep from eventlet.pools import Pool @@ -76,7 +75,6 @@ def report(success): if __name__ == '__main__': global begun, created, item_type, next_report, need_to_create, retries_done - gettext.install('swift', unicode=1) patcher.monkey_patch() parser = OptionParser() diff --git a/bin/swift-stats-report b/bin/swift-stats-report index 158ae37c75..3f735877cf 100755 --- a/bin/swift-stats-report +++ b/bin/swift-stats-report @@ -23,7 +23,6 @@ from optparse import OptionParser from sys import argv, exit, stderr from time import time from uuid import uuid4 -import gettext from eventlet import GreenPool, hubs, patcher, sleep, Timeout from eventlet.pools import Pool @@ -747,7 +746,6 @@ def object_delete_report(coropool, connpool, options): if __name__ == '__main__': - gettext.install('swift', unicode=1) patcher.monkey_patch() hubs.get_hub().debug_exceptions = False diff --git a/swift/__init__.py b/swift/__init__.py index 65989fb130..0bd0062056 100644 --- a/swift/__init__.py +++ b/swift/__init__.py @@ -1,3 +1,5 @@ -__version__ = '1.1.0' import gettext + + +__version__ = '1.1.0' gettext.install('swift') diff --git a/test/unit/container/test_updater.py b/test/unit/container/test_updater.py index 35e7629162..a4c638c2ec 100644 --- a/test/unit/container/test_updater.py +++ b/test/unit/container/test_updater.py @@ -23,6 +23,7 @@ from shutil import rmtree from eventlet import spawn, TimeoutError, listen from eventlet.timeout import Timeout +from swift.common import utils from swift.container import updater as container_updater from swift.container import server as container_server from swift.common.db import ContainerBroker @@ -33,6 +34,7 @@ from swift.common.utils import normalize_timestamp class TestContainerUpdater(unittest.TestCase): def setUp(self): + utils.HASH_PATH_SUFFIX = 'endcap' self.path_to_test_xfs = os.environ.get('PATH_TO_TEST_XFS') if not self.path_to_test_xfs or \ not os.path.exists(self.path_to_test_xfs):