diff --git a/bin/st b/bin/st index f7009daf21..79f331558f 100755 --- a/bin/st +++ b/bin/st @@ -44,8 +44,8 @@ except: try: from swift.common.bufferedhttp \ import BufferedHTTPConnection as HTTPConnection - import __builtin__ # bufferedhttp uses automagic gettext - setattr(__builtin__, '_', lambda x: x) + 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 fe611562d7..1f6aceb2c8 100755 --- a/bin/swift-account-audit +++ b/bin/swift-account-audit @@ -20,6 +20,7 @@ from urllib import quote from hashlib import md5 import getopt from itertools import chain +import gettext import simplejson from eventlet.greenpool import GreenPool @@ -324,6 +325,7 @@ 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 d502dc83a8..2d9819dfc8 100755 --- a/bin/swift-auth-add-user +++ b/bin/swift-auth-add-user @@ -18,11 +18,13 @@ 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 e17bf2da3b..a8ee20e0e8 100755 --- a/bin/swift-auth-recreate-accounts +++ b/bin/swift-auth-recreate-accounts @@ -17,10 +17,12 @@ 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 41a4bf6a76..cb09bd9872 100755 --- a/bin/swift-auth-update-reseller-prefixes +++ b/bin/swift-auth-update-reseller-prefixes @@ -16,11 +16,13 @@ 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 ab332482cd..2c3e08318b 100755 --- a/bin/swift-bench +++ b/bin/swift-bench @@ -20,6 +20,7 @@ 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 @@ -55,6 +56,7 @@ 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 cde28c1ed7..64c478e203 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -20,6 +20,7 @@ import re import subprocess import sys from ConfigParser import ConfigParser +import gettext from swift.common.utils import get_logger @@ -86,6 +87,7 @@ 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 f24dd48f96..69643f6a84 100755 --- a/bin/swift-get-nodes +++ b/bin/swift-get-nodes @@ -16,11 +16,14 @@ 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 e533cad824..972303f67b 100755 --- a/bin/swift-log-uploader +++ b/bin/swift-log-uploader @@ -15,12 +15,14 @@ # 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 57f2522071..268b991bee 100755 --- a/bin/swift-object-info +++ b/bin/swift-object-info @@ -18,12 +18,14 @@ 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 50353df256..1d53a30973 100755 --- a/bin/swift-ring-builder +++ b/bin/swift-ring-builder @@ -21,6 +21,7 @@ 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 @@ -174,6 +175,7 @@ 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 8ea210cb65..985fa50c82 100755 --- a/bin/swift-stats-populate +++ b/bin/swift-stats-populate @@ -21,6 +21,7 @@ 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 @@ -75,6 +76,7 @@ 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 3f735877cf..158ae37c75 100755 --- a/bin/swift-stats-report +++ b/bin/swift-stats-report @@ -23,6 +23,7 @@ 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 @@ -746,6 +747,7 @@ def object_delete_report(coropool, connpool, options): if __name__ == '__main__': + gettext.install('swift', unicode=1) patcher.monkey_patch() hubs.get_hub().debug_exceptions = False