Merge "Changed several files to be Python3 friendly"
This commit is contained in:
commit
698919e67b
@ -13,6 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
@ -484,7 +486,7 @@ class TempAuth(object):
|
|||||||
req.headers['x-auth-token'] = req.headers['x-storage-token']
|
req.headers['x-auth-token'] = req.headers['x-storage-token']
|
||||||
return self.handle_request(req)(env, start_response)
|
return self.handle_request(req)(env, start_response)
|
||||||
except (Exception, Timeout):
|
except (Exception, Timeout):
|
||||||
print "EXCEPTION IN handle: %s: %s" % (format_exc(), env)
|
print("EXCEPTION IN handle: %s: %s" % (format_exc(), env))
|
||||||
self.logger.increment('errors')
|
self.logger.increment('errors')
|
||||||
start_response('500 Server Error',
|
start_response('500 Server Error',
|
||||||
[('Content-Type', 'text/plain')])
|
[('Content-Type', 'text/plain')])
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Miscellaneous utility functions for use with Swift."""
|
"""Miscellaneous utility functions for use with Swift."""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import fcntl
|
import fcntl
|
||||||
import grp
|
import grp
|
||||||
@ -1347,9 +1349,11 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
|
|||||||
logger_hook(conf, name, log_to_console, log_route, fmt,
|
logger_hook(conf, name, log_to_console, log_route, fmt,
|
||||||
logger, adapted_logger)
|
logger, adapted_logger)
|
||||||
except (AttributeError, ImportError):
|
except (AttributeError, ImportError):
|
||||||
print >>sys.stderr, 'Error calling custom handler [%s]' % hook
|
print(
|
||||||
|
'Error calling custom handler [%s]' % hook,
|
||||||
|
file=sys.stderr)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>sys.stderr, 'Invalid custom handler format [%s]' % hook
|
print('Invalid custom handler format [%s]' % hook, sys.stderr)
|
||||||
|
|
||||||
# Python 2.6 has the undesirable property of keeping references to all log
|
# Python 2.6 has the undesirable property of keeping references to all log
|
||||||
# handlers around forever in logging._handlers and logging._handlerList.
|
# handlers around forever in logging._handlers and logging._handlerList.
|
||||||
@ -1488,12 +1492,12 @@ def parse_options(parser=None, once=False, test_args=None):
|
|||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
print _("Error: missing config path argument")
|
print(_("Error: missing config path argument"))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
config = os.path.abspath(args.pop(0))
|
config = os.path.abspath(args.pop(0))
|
||||||
if not os.path.exists(config):
|
if not os.path.exists(config):
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
print _("Error: unable to locate %s") % config
|
print(_("Error: unable to locate %s") % config)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
extra_args = []
|
extra_args = []
|
||||||
@ -1783,14 +1787,14 @@ def readconf(conf_path, section_name=None, log_name=None, defaults=None,
|
|||||||
else:
|
else:
|
||||||
success = c.read(conf_path)
|
success = c.read(conf_path)
|
||||||
if not success:
|
if not success:
|
||||||
print _("Unable to read config from %s") % conf_path
|
print(_("Unable to read config from %s") % conf_path)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if section_name:
|
if section_name:
|
||||||
if c.has_section(section_name):
|
if c.has_section(section_name):
|
||||||
conf = dict(c.items(section_name))
|
conf = dict(c.items(section_name))
|
||||||
else:
|
else:
|
||||||
print _("Unable to find %s config section in %s") % \
|
print(_("Unable to find %s config section in %s") %
|
||||||
(section_name, conf_path)
|
(section_name, conf_path))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if "log_name" not in conf:
|
if "log_name" not in conf:
|
||||||
if log_name is not None:
|
if log_name is not None:
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""WSGI tools for use with swift."""
|
"""WSGI tools for use with swift."""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
@ -415,7 +417,7 @@ def run_wsgi(conf_path, app_section, *args, **kwargs):
|
|||||||
(conf, logger, log_name) = \
|
(conf, logger, log_name) = \
|
||||||
_initrp(conf_path, app_section, *args, **kwargs)
|
_initrp(conf_path, app_section, *args, **kwargs)
|
||||||
except ConfigFileError as e:
|
except ConfigFileError as e:
|
||||||
print e
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# bind to address and port
|
# bind to address and port
|
||||||
|
Loading…
x
Reference in New Issue
Block a user