i18n finishup

This commit is contained in:
Michael Barton 2010-12-22 16:36:31 +00:00
parent 0b3fac8992
commit 24590669d8
23 changed files with 22 additions and 30 deletions

View File

@ -16,7 +16,6 @@
import os
import time
from random import random
from gettext import gettext as _
from swift.account import server as account_server
from swift.common.db import AccountBroker

View File

@ -18,7 +18,6 @@ import random
from logging import DEBUG
from math import sqrt
from time import time
from gettext import gettext as _
from eventlet import GreenPool, sleep

View File

@ -20,7 +20,6 @@ import time
import traceback
from urllib import unquote
from xml.sax import saxutils
from gettext import gettext as _
from webob import Request, Response
from webob.exc import HTTPAccepted, HTTPBadRequest, \

View File

@ -18,7 +18,6 @@ import time
import random
from urlparse import urlparse
from contextlib import contextmanager
from gettext import gettext as _
import eventlet.pools
from eventlet.green.httplib import CannotSendRequest

View File

@ -29,7 +29,6 @@ BufferedHTTPResponse.
from urllib import quote
import logging
import time
from gettext import gettext as _
from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \
HTTPResponse, HTTPSConnection, _UNKNOWN

View File

@ -16,7 +16,9 @@
import os
import sys
import signal
import gettext
from re import sub
from swift.common import utils
@ -40,6 +42,7 @@ 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)

View File

@ -27,7 +27,6 @@ import cPickle as pickle
import errno
from random import randint
from tempfile import mkstemp
from gettext import gettext as _
from eventlet import sleep
import simplejson as json

View File

@ -20,7 +20,6 @@ import random
import math
import time
import shutil
from gettext import gettext as _
from eventlet import GreenPool, sleep, Timeout
from eventlet.green import subprocess

View File

@ -26,7 +26,6 @@ import socket
import time
from bisect import bisect
from hashlib import md5
from gettext import gettext as _
CONN_TIMEOUT = 0.3
IO_TIMEOUT = 2.0

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from gettext import gettext as _
from webob import Request
from webob.exc import HTTPServerError

View File

@ -15,7 +15,6 @@ import time
import eventlet
from webob import Request, Response
from webob.exc import HTTPNotFound
from gettext import gettext as _
from swift.common.utils import split_path, cache_from_env, get_logger
from swift.proxy.server import get_container_memcache_key

View File

@ -34,7 +34,6 @@ from ConfigParser import ConfigParser, NoSectionError, NoOptionError
from optparse import OptionParser
from tempfile import mkstemp
import cPickle as pickle
from gettext import gettext as _
import eventlet
from eventlet import greenio, GreenPool, sleep, Timeout, listen

View File

@ -21,6 +21,7 @@ import signal
import sys
import time
import mimetools
import gettext
import eventlet
from eventlet import greenio, GreenPool, sleep, wsgi, listen
@ -120,6 +121,7 @@ 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})

View File

@ -16,7 +16,6 @@
import os
import time
from random import random
from gettext import gettext as _
from swift.container import server as container_server
from swift.common.db import ContainerBroker

View File

@ -21,7 +21,6 @@ import traceback
from urllib import unquote
from xml.sax import saxutils
from datetime import datetime
from gettext import gettext as _
import simplejson
from eventlet.timeout import Timeout

View File

@ -19,7 +19,6 @@ import signal
import sys
import time
from random import random, shuffle
from gettext import gettext as _
from eventlet import spawn, patcher, Timeout

View File

@ -17,7 +17,6 @@ import os
import time
from hashlib import md5
from random import random
from gettext import gettext as _
from swift.obj import server as object_server
from swift.obj.replicator import invalidate_hash

View File

@ -22,7 +22,6 @@ import logging
import hashlib
import itertools
import cPickle as pickle
from gettext import gettext as _
import eventlet
from eventlet import GreenPool, tpool, Timeout, sleep, hubs

View File

@ -26,7 +26,6 @@ from hashlib import md5
from tempfile import mkstemp
from urllib import unquote
from contextlib import contextmanager
from gettext import gettext as _
from webob import Request, Response, UTC
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \

View File

@ -19,7 +19,6 @@ import signal
import sys
import time
from random import random
from gettext import gettext as _
from eventlet import patcher, Timeout

View File

@ -28,7 +28,6 @@ from datetime import datetime
from urllib import unquote, quote
import uuid
import functools
from gettext import gettext as _
from hashlib import md5
from eventlet import sleep

View File

@ -0,0 +1,7 @@
# See http://code.google.com/p/python-nose/issues/detail?id=373
# The code below enables nosetests to work with i18n _() blocks
import __builtin__
setattr(__builtin__, '_', lambda x: x)

View File

@ -3019,8 +3019,8 @@ class TestSegmentedIterable(unittest.TestCase):
self.assertRaises(Exception,
proxy_server.SegmentedIterable(self.controller, None,
[None])._load_next_segment)
self.assertEquals(self.controller.exception_args[0],
'ERROR: While processing manifest /a/c/o tx1')
self.assert_(self.controller.exception_args[0].startswith(
'ERROR: While processing manifest'))
def test_load_next_segment_with_no_segments(self):
self.assertRaises(StopIteration,
@ -3079,8 +3079,8 @@ class TestSegmentedIterable(unittest.TestCase):
self.assertRaises(Exception,
proxy_server.SegmentedIterable(self.controller, 'lc', [{'name':
'o1'}])._load_next_segment)
self.assertEquals(self.controller.exception_args[0],
'ERROR: While processing manifest /a/c/o tx1')
self.assert_(self.controller.exception_args[0].startswith(
'ERROR: While processing manifest'))
self.assertEquals(str(self.controller.exception_info[1]),
'Could not load object segment /a/lc/o1: 404')
@ -3088,8 +3088,8 @@ class TestSegmentedIterable(unittest.TestCase):
# Iterator value isn't a dict
self.assertRaises(Exception, ''.join,
proxy_server.SegmentedIterable(self.controller, None, [None]))
self.assertEquals(self.controller.exception_args[0],
'ERROR: While processing manifest /a/c/o tx1')
self.assert_(self.controller.exception_args[0].startswith(
'ERROR: While processing manifest'))
def test_iter_with_no_segments(self):
segit = proxy_server.SegmentedIterable(self.controller, 'lc', [])
@ -3118,8 +3118,8 @@ class TestSegmentedIterable(unittest.TestCase):
self.assertRaises(Exception, ''.join,
proxy_server.SegmentedIterable(self.controller, 'lc', [{'name':
'o1'}]))
self.assertEquals(self.controller.exception_args[0],
'ERROR: While processing manifest /a/c/o tx1')
self.assert_(self.controller.exception_args[0].startswith(
'ERROR: While processing manifest'))
self.assertEquals(str(self.controller.exception_info[1]),
'Could not load object segment /a/lc/o1: 404')
@ -3128,8 +3128,8 @@ class TestSegmentedIterable(unittest.TestCase):
self.assertRaises(Exception,
proxy_server.SegmentedIterable(self.controller, None,
[None]).app_iter_range(None, None).next)
self.assertEquals(self.controller.exception_args[0],
'ERROR: While processing manifest /a/c/o tx1')
self.assert_(self.controller.exception_args[0].startswith(
'ERROR: While processing manifest'))
def test_app_iter_range_with_no_segments(self):
self.assertEquals(''.join(proxy_server.SegmentedIterable(