removing blank excepts
This commit is contained in:
parent
50f3c9379b
commit
86cb12036b
10
bin/st
10
bin/st
@ -38,13 +38,13 @@ from urlparse import urlparse, urlunparse
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from eventlet import sleep
|
from eventlet import sleep
|
||||||
except:
|
except Exception:
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from swift.common.bufferedhttp \
|
from swift.common.bufferedhttp \
|
||||||
import BufferedHTTPConnection as HTTPConnection
|
import BufferedHTTPConnection as HTTPConnection
|
||||||
except:
|
except Exception:
|
||||||
from httplib import HTTPConnection
|
from httplib import HTTPConnection
|
||||||
|
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ except ImportError:
|
|||||||
else:
|
else:
|
||||||
res.append(val)
|
res.append(val)
|
||||||
return eval(''.join(res), {}, consts)
|
return eval(''.join(res), {}, consts)
|
||||||
except:
|
except Exception:
|
||||||
raise AttributeError()
|
raise AttributeError()
|
||||||
|
|
||||||
|
|
||||||
@ -1615,7 +1615,7 @@ def st_upload(options, args, print_queue, error_queue):
|
|||||||
conn.put_container(args[0])
|
conn.put_container(args[0])
|
||||||
if options.segment_size is not None:
|
if options.segment_size is not None:
|
||||||
conn.put_container(args[0] + '_segments')
|
conn.put_container(args[0] + '_segments')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
for arg in args[1:]:
|
for arg in args[1:]:
|
||||||
@ -1722,7 +1722,7 @@ Example:
|
|||||||
error_thread.abort = True
|
error_thread.abort = True
|
||||||
while error_thread.isAlive():
|
while error_thread.isAlive():
|
||||||
error_thread.join(0.01)
|
error_thread.join(0.01)
|
||||||
except:
|
except Exception:
|
||||||
for thread in threading_enumerate():
|
for thread in threading_enumerate():
|
||||||
thread.abort = True
|
thread.abort = True
|
||||||
raise
|
raise
|
||||||
|
@ -89,7 +89,7 @@ if __name__ == '__main__':
|
|||||||
c = ConfigParser()
|
c = ConfigParser()
|
||||||
try:
|
try:
|
||||||
conf_path = sys.argv[1]
|
conf_path = sys.argv[1]
|
||||||
except:
|
except Exception:
|
||||||
print "Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1]
|
print "Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1]
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if not c.read(conf_path):
|
if not c.read(conf_path):
|
||||||
|
@ -29,7 +29,7 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
ring = Ring('/etc/swift/object.ring.gz')
|
ring = Ring('/etc/swift/object.ring.gz')
|
||||||
except:
|
except Exception:
|
||||||
ring = None
|
ring = None
|
||||||
datafile = sys.argv[1]
|
datafile = sys.argv[1]
|
||||||
fp = open(datafile, 'rb')
|
fp = open(datafile, 'rb')
|
||||||
|
@ -38,7 +38,7 @@ def put_container(connpool, container, report):
|
|||||||
retries_done += conn.attempts - 1
|
retries_done += conn.attempts - 1
|
||||||
if report:
|
if report:
|
||||||
report(True)
|
report(True)
|
||||||
except:
|
except Exception:
|
||||||
if report:
|
if report:
|
||||||
report(False)
|
report(False)
|
||||||
raise
|
raise
|
||||||
@ -53,7 +53,7 @@ def put_object(connpool, container, obj, report):
|
|||||||
retries_done += conn.attempts - 1
|
retries_done += conn.attempts - 1
|
||||||
if report:
|
if report:
|
||||||
report(True)
|
report(True)
|
||||||
except:
|
except Exception:
|
||||||
if report:
|
if report:
|
||||||
report(False)
|
report(False)
|
||||||
raise
|
raise
|
||||||
|
@ -305,7 +305,7 @@ class AccountController(object):
|
|||||||
res = getattr(self, req.method)(req)
|
res = getattr(self, req.method)(req)
|
||||||
else:
|
else:
|
||||||
res = HTTPMethodNotAllowed()
|
res = HTTPMethodNotAllowed()
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
||||||
' %(path)s '), {'method': req.method, 'path': req.path})
|
' %(path)s '), {'method': req.method, 'path': req.path})
|
||||||
res = HTTPInternalServerError(body=traceback.format_exc())
|
res = HTTPInternalServerError(body=traceback.format_exc())
|
||||||
|
@ -96,7 +96,7 @@ class AuthController(object):
|
|||||||
msg = _('No super_admin_key set in conf file! Exiting.')
|
msg = _('No super_admin_key set in conf file! Exiting.')
|
||||||
try:
|
try:
|
||||||
self.logger.critical(msg)
|
self.logger.critical(msg)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
self.swift_dir = conf.get('swift_dir', '/etc/swift')
|
self.swift_dir = conf.get('swift_dir', '/etc/swift')
|
||||||
@ -237,7 +237,7 @@ YOU HAVE A FEW OPTIONS:
|
|||||||
except Exception, err:
|
except Exception, err:
|
||||||
try:
|
try:
|
||||||
conn.close()
|
conn.close()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.conn = get_db_connection(self.db_file)
|
self.conn = get_db_connection(self.db_file)
|
||||||
raise err
|
raise err
|
||||||
@ -637,7 +637,7 @@ YOU HAVE A FEW OPTIONS:
|
|||||||
else:
|
else:
|
||||||
return HTTPBadRequest(request=env)(env, start_response)
|
return HTTPBadRequest(request=env)(env, start_response)
|
||||||
response = handler(req)
|
response = handler(req)
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(
|
self.logger.exception(
|
||||||
_('ERROR Unhandled exception in ReST request'))
|
_('ERROR Unhandled exception in ReST request'))
|
||||||
return HTTPServiceUnavailable(request=req)(env, start_response)
|
return HTTPServiceUnavailable(request=req)(env, start_response)
|
||||||
|
@ -97,7 +97,7 @@ class Bench(object):
|
|||||||
self.logger.info(_("CannotSendRequest. Skipping..."))
|
self.logger.info(_("CannotSendRequest. Skipping..."))
|
||||||
try:
|
try:
|
||||||
hc.close()
|
hc.close()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.failures += 1
|
self.failures += 1
|
||||||
hc = self.conn_pool.create()
|
hc = self.conn_pool.create()
|
||||||
|
@ -87,7 +87,7 @@ except ImportError:
|
|||||||
else:
|
else:
|
||||||
res.append(val)
|
res.append(val)
|
||||||
return eval(''.join(res), {}, consts)
|
return eval(''.join(res), {}, consts)
|
||||||
except:
|
except Exception:
|
||||||
raise AttributeError()
|
raise AttributeError()
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class DatabaseBroker(object):
|
|||||||
yield conn
|
yield conn
|
||||||
conn.rollback()
|
conn.rollback()
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
except:
|
except Exception:
|
||||||
conn.close()
|
conn.close()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -288,13 +288,13 @@ class DatabaseBroker(object):
|
|||||||
conn.execute('BEGIN IMMEDIATE')
|
conn.execute('BEGIN IMMEDIATE')
|
||||||
try:
|
try:
|
||||||
yield True
|
yield True
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
conn.execute('ROLLBACK')
|
conn.execute('ROLLBACK')
|
||||||
conn.isolation_level = orig_isolation_level
|
conn.isolation_level = orig_isolation_level
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
except: # pragma: no cover
|
except Exception:
|
||||||
logging.exception(
|
logging.exception(
|
||||||
_('Broker error trying to rollback locked connection'))
|
_('Broker error trying to rollback locked connection'))
|
||||||
conn.close()
|
conn.close()
|
||||||
@ -749,7 +749,7 @@ class ContainerBroker(DatabaseBroker):
|
|||||||
timestamp, 'size': size, 'content_type':
|
timestamp, 'size': size, 'content_type':
|
||||||
content_type, 'etag': etag,
|
content_type, 'etag': etag,
|
||||||
'deleted': deleted})
|
'deleted': deleted})
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(
|
self.logger.exception(
|
||||||
_('Invalid pending entry %(file)s: %(entry)s'),
|
_('Invalid pending entry %(file)s: %(entry)s'),
|
||||||
{'file': self.pending_file, 'entry': entry})
|
{'file': self.pending_file, 'entry': entry})
|
||||||
@ -1216,7 +1216,7 @@ class AccountBroker(DatabaseBroker):
|
|||||||
'object_count': object_count,
|
'object_count': object_count,
|
||||||
'bytes_used': bytes_used,
|
'bytes_used': bytes_used,
|
||||||
'deleted': deleted})
|
'deleted': deleted})
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(
|
self.logger.exception(
|
||||||
_('Invalid pending entry %(file)s: %(entry)s'),
|
_('Invalid pending entry %(file)s: %(entry)s'),
|
||||||
{'file': self.pending_file, 'entry': entry})
|
{'file': self.pending_file, 'entry': entry})
|
||||||
|
@ -21,7 +21,7 @@ import math
|
|||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from eventlet import GreenPool, sleep, Timeout
|
from eventlet import GreenPool, sleep, Timeout, TimeoutError
|
||||||
from eventlet.green import subprocess
|
from eventlet.green import subprocess
|
||||||
import simplejson
|
import simplejson
|
||||||
from webob import Response
|
from webob import Response
|
||||||
@ -79,7 +79,7 @@ class ReplConnection(BufferedHTTPConnection):
|
|||||||
response = self.getresponse()
|
response = self.getresponse()
|
||||||
response.data = response.read()
|
response.data = response.read()
|
||||||
return response
|
return response
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(
|
self.logger.exception(
|
||||||
_('ERROR reading HTTP response from %s'), self.node)
|
_('ERROR reading HTTP response from %s'), self.node)
|
||||||
return None
|
return None
|
||||||
@ -359,7 +359,7 @@ class Replicator(Daemon):
|
|||||||
except DriveNotMounted:
|
except DriveNotMounted:
|
||||||
repl_nodes.append(more_nodes.next())
|
repl_nodes.append(more_nodes.next())
|
||||||
self.logger.error(_('ERROR Remote drive not mounted %s'), node)
|
self.logger.error(_('ERROR Remote drive not mounted %s'), node)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR syncing %(file)s with node'
|
self.logger.exception(_('ERROR syncing %(file)s with node'
|
||||||
' %(node)s'), {'file': object_file, 'node': node})
|
' %(node)s'), {'file': object_file, 'node': node})
|
||||||
self.stats['success' if success else 'failure'] += 1
|
self.stats['success' if success else 'failure'] += 1
|
||||||
@ -432,7 +432,7 @@ class Replicator(Daemon):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.run_once()
|
self.run_once()
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR trying to replicate'))
|
self.logger.exception(_('ERROR trying to replicate'))
|
||||||
sleep(self.run_pause)
|
sleep(self.run_pause)
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ from urlparse import urlparse
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from eventlet.timeout import Timeout
|
from eventlet.timeout import Timeout
|
||||||
|
from eventlet import TimeoutError
|
||||||
from webob import Response, Request
|
from webob import Response, Request
|
||||||
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
|
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
|
||||||
HTTPCreated, HTTPForbidden, HTTPNoContent, HTTPNotFound, \
|
HTTPCreated, HTTPForbidden, HTTPNoContent, HTTPNotFound, \
|
||||||
@ -283,7 +284,7 @@ class Swauth(object):
|
|||||||
response = self.handle_request(req)(env, start_response)
|
response = self.handle_request(req)(env, start_response)
|
||||||
self.posthooklogger(env, req)
|
self.posthooklogger(env, req)
|
||||||
return response
|
return response
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
print "EXCEPTION IN handle: %s: %s" % (format_exc(), env)
|
print "EXCEPTION IN handle: %s: %s" % (format_exc(), env)
|
||||||
start_response('500 Server Error',
|
start_response('500 Server Error',
|
||||||
[('Content-Type', 'text/plain')])
|
[('Content-Type', 'text/plain')])
|
||||||
@ -589,7 +590,7 @@ class Swauth(object):
|
|||||||
if resp.status // 100 != 2:
|
if resp.status // 100 != 2:
|
||||||
raise Exception('Could not create account on the Swift '
|
raise Exception('Could not create account on the Swift '
|
||||||
'cluster: %s %s %s' % (path, resp.status, resp.reason))
|
'cluster: %s %s %s' % (path, resp.status, resp.reason))
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.error(_('ERROR: Exception while trying to communicate '
|
self.logger.error(_('ERROR: Exception while trying to communicate '
|
||||||
'with %(scheme)s://%(host)s:%(port)s/%(path)s'),
|
'with %(scheme)s://%(host)s:%(port)s/%(path)s'),
|
||||||
{'scheme': self.dsc_parsed2.scheme,
|
{'scheme': self.dsc_parsed2.scheme,
|
||||||
|
@ -24,6 +24,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
from eventlet.timeout import Timeout
|
from eventlet.timeout import Timeout
|
||||||
|
from eventlet import TimeoutError
|
||||||
from webob import Request, Response
|
from webob import Request, Response
|
||||||
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
|
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
|
||||||
HTTPCreated, HTTPInternalServerError, HTTPNoContent, \
|
HTTPCreated, HTTPInternalServerError, HTTPNoContent, \
|
||||||
@ -118,7 +119,7 @@ class ContainerController(object):
|
|||||||
'device': account_device,
|
'device': account_device,
|
||||||
'status': account_response.status,
|
'status': account_response.status,
|
||||||
'reason': account_response.reason})
|
'reason': account_response.reason})
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR account update failed with '
|
self.logger.exception(_('ERROR account update failed with '
|
||||||
'%(ip)s:%(port)s/%(device)s (will retry later)'),
|
'%(ip)s:%(port)s/%(device)s (will retry later)'),
|
||||||
{'ip': account_ip, 'port': account_port,
|
{'ip': account_ip, 'port': account_port,
|
||||||
@ -393,7 +394,7 @@ class ContainerController(object):
|
|||||||
res = getattr(self, req.method)(req)
|
res = getattr(self, req.method)(req)
|
||||||
else:
|
else:
|
||||||
res = HTTPMethodNotAllowed()
|
res = HTTPMethodNotAllowed()
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
||||||
' %(path)s '), {'method': req.method, 'path': req.path})
|
' %(path)s '), {'method': req.method, 'path': req.path})
|
||||||
res = HTTPInternalServerError(body=traceback.format_exc())
|
res = HTTPInternalServerError(body=traceback.format_exc())
|
||||||
|
@ -20,7 +20,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from random import random, shuffle
|
from random import random, shuffle
|
||||||
|
|
||||||
from eventlet import spawn, patcher, Timeout
|
from eventlet import spawn, patcher, Timeout, TimeoutError
|
||||||
|
|
||||||
from swift.container.server import DATADIR
|
from swift.container.server import DATADIR
|
||||||
from swift.common.bufferedhttp import http_connect
|
from swift.common.bufferedhttp import http_connect
|
||||||
@ -221,7 +221,7 @@ class ContainerUpdater(Daemon):
|
|||||||
'X-Object-Count': count,
|
'X-Object-Count': count,
|
||||||
'X-Bytes-Used': bytes,
|
'X-Bytes-Used': bytes,
|
||||||
'X-Account-Override-Deleted': 'yes'})
|
'X-Account-Override-Deleted': 'yes'})
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR account update failed with '
|
self.logger.exception(_('ERROR account update failed with '
|
||||||
'%(ip)s:%(port)s/%(device)s (will retry later): '), node)
|
'%(ip)s:%(port)s/%(device)s (will retry later): '), node)
|
||||||
return 500
|
return 500
|
||||||
@ -230,7 +230,7 @@ class ContainerUpdater(Daemon):
|
|||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
resp.read()
|
resp.read()
|
||||||
return resp.status
|
return resp.status
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
if self.logger.getEffectiveLevel() <= logging.DEBUG:
|
if self.logger.getEffectiveLevel() <= logging.DEBUG:
|
||||||
self.logger.exception(
|
self.logger.exception(
|
||||||
_('Exception with %(ip)s:%(port)s/%(device)s'), node)
|
_('Exception with %(ip)s:%(port)s/%(device)s'), node)
|
||||||
|
@ -33,7 +33,7 @@ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
|
|||||||
HTTPNotModified, HTTPPreconditionFailed, \
|
HTTPNotModified, HTTPPreconditionFailed, \
|
||||||
HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed
|
HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed
|
||||||
from xattr import getxattr, setxattr
|
from xattr import getxattr, setxattr
|
||||||
from eventlet import sleep, Timeout, tpool
|
from eventlet import sleep, Timeout, TimeoutError, tpool
|
||||||
|
|
||||||
from swift.common.utils import mkdirs, normalize_timestamp, \
|
from swift.common.utils import mkdirs, normalize_timestamp, \
|
||||||
storage_directory, hash_path, renamer, fallocate, \
|
storage_directory, hash_path, renamer, fallocate, \
|
||||||
@ -308,7 +308,7 @@ class ObjectController(object):
|
|||||||
'response from %(ip)s:%(port)s/%(dev)s'),
|
'response from %(ip)s:%(port)s/%(dev)s'),
|
||||||
{'status': response.status, 'ip': ip, 'port': port,
|
{'status': response.status, 'ip': ip, 'port': port,
|
||||||
'dev': contdevice})
|
'dev': contdevice})
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR container update failed with '
|
self.logger.exception(_('ERROR container update failed with '
|
||||||
'%(ip)s:%(port)s/%(dev)s (saving for async update later)'),
|
'%(ip)s:%(port)s/%(dev)s (saving for async update later)'),
|
||||||
{'ip': ip, 'port': port, 'dev': contdevice})
|
{'ip': ip, 'port': port, 'dev': contdevice})
|
||||||
@ -582,7 +582,7 @@ class ObjectController(object):
|
|||||||
res = getattr(self, req.method)(req)
|
res = getattr(self, req.method)(req)
|
||||||
else:
|
else:
|
||||||
res = HTTPMethodNotAllowed()
|
res = HTTPMethodNotAllowed()
|
||||||
except:
|
except Exception:
|
||||||
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
self.logger.exception(_('ERROR __call__ error with %(method)s'
|
||||||
' %(path)s '), {'method': req.method, 'path': req.path})
|
' %(path)s '), {'method': req.method, 'path': req.path})
|
||||||
res = HTTPInternalServerError(body=traceback.format_exc())
|
res = HTTPInternalServerError(body=traceback.format_exc())
|
||||||
|
@ -20,7 +20,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from random import random
|
from random import random
|
||||||
|
|
||||||
from eventlet import patcher, Timeout
|
from eventlet import patcher, Timeout, TimeoutError
|
||||||
|
|
||||||
from swift.common.bufferedhttp import http_connect
|
from swift.common.bufferedhttp import http_connect
|
||||||
from swift.common.exceptions import ConnectionTimeout
|
from swift.common.exceptions import ConnectionTimeout
|
||||||
@ -202,7 +202,7 @@ class ObjectUpdater(Daemon):
|
|||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
resp.read()
|
resp.read()
|
||||||
return resp.status
|
return resp.status
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.logger.exception(_('ERROR with remote server '
|
self.logger.exception(_('ERROR with remote server '
|
||||||
'%(ip)s:%(port)s/%(device)s'), node)
|
'%(ip)s:%(port)s/%(device)s'), node)
|
||||||
return 500
|
return 500
|
||||||
|
@ -30,7 +30,7 @@ import uuid
|
|||||||
import functools
|
import functools
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
|
||||||
from eventlet import sleep
|
from eventlet import sleep, TimeoutError
|
||||||
from eventlet.timeout import Timeout
|
from eventlet.timeout import Timeout
|
||||||
from webob.exc import HTTPBadRequest, HTTPMethodNotAllowed, \
|
from webob.exc import HTTPBadRequest, HTTPMethodNotAllowed, \
|
||||||
HTTPNotFound, HTTPPreconditionFailed, \
|
HTTPNotFound, HTTPPreconditionFailed, \
|
||||||
@ -383,7 +383,7 @@ class Controller(object):
|
|||||||
attempts_left -= 1
|
attempts_left -= 1
|
||||||
if attempts_left <= 0:
|
if attempts_left <= 0:
|
||||||
break
|
break
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Account'),
|
self.exception_occurred(node, _('Account'),
|
||||||
_('Trying to get account info for %s') % path)
|
_('Trying to get account info for %s') % path)
|
||||||
if self.app.memcache and result_code in (200, 404):
|
if self.app.memcache and result_code in (200, 404):
|
||||||
@ -461,7 +461,7 @@ class Controller(object):
|
|||||||
attempts_left -= 1
|
attempts_left -= 1
|
||||||
if attempts_left <= 0:
|
if attempts_left <= 0:
|
||||||
break
|
break
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Container'),
|
self.exception_occurred(node, _('Container'),
|
||||||
_('Trying to get container info for %s') % path)
|
_('Trying to get container info for %s') % path)
|
||||||
if self.app.memcache and result_code in (200, 404):
|
if self.app.memcache and result_code in (200, 404):
|
||||||
@ -592,7 +592,7 @@ class Controller(object):
|
|||||||
query_string=req.query_string)
|
query_string=req.query_string)
|
||||||
with Timeout(self.app.node_timeout):
|
with Timeout(self.app.node_timeout):
|
||||||
source = conn.getresponse()
|
source = conn.getresponse()
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, server_type,
|
self.exception_occurred(node, server_type,
|
||||||
_('Trying to %(method)s %(path)s') %
|
_('Trying to %(method)s %(path)s') %
|
||||||
{'method': req.method, 'path': req.path})
|
{'method': req.method, 'path': req.path})
|
||||||
@ -624,7 +624,7 @@ class Controller(object):
|
|||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
res.client_disconnect = True
|
res.client_disconnect = True
|
||||||
self.app.logger.info(_('Client disconnected on read'))
|
self.app.logger.info(_('Client disconnected on read'))
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Object'),
|
self.exception_occurred(node, _('Object'),
|
||||||
_('Trying to read during GET of %s') % req.path)
|
_('Trying to read during GET of %s') % req.path)
|
||||||
raise
|
raise
|
||||||
@ -691,7 +691,7 @@ class ObjectController(Controller):
|
|||||||
_('ERROR %(status)d %(body)s From Object Server') %
|
_('ERROR %(status)d %(body)s From Object Server') %
|
||||||
{'status': response.status, 'body': body[:1024]})
|
{'status': response.status, 'body': body[:1024]})
|
||||||
return response.status, response.reason, body
|
return response.status, response.reason, body
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Object'),
|
self.exception_occurred(node, _('Object'),
|
||||||
_('Trying to %(method)s %(path)s') %
|
_('Trying to %(method)s %(path)s') %
|
||||||
{'method': req.method, 'path': req.path})
|
{'method': req.method, 'path': req.path})
|
||||||
@ -998,7 +998,7 @@ class ObjectController(Controller):
|
|||||||
conn.node = node
|
conn.node = node
|
||||||
with Timeout(self.app.node_timeout):
|
with Timeout(self.app.node_timeout):
|
||||||
resp = conn.getexpect()
|
resp = conn.getexpect()
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Object'),
|
self.exception_occurred(node, _('Object'),
|
||||||
_('Expect: 100-continue on %s') % req.path)
|
_('Expect: 100-continue on %s') % req.path)
|
||||||
if conn and resp:
|
if conn and resp:
|
||||||
@ -1038,7 +1038,7 @@ class ObjectController(Controller):
|
|||||||
conn.send('%x\r\n%s\r\n' % (len_chunk, chunk))
|
conn.send('%x\r\n%s\r\n' % (len_chunk, chunk))
|
||||||
else:
|
else:
|
||||||
conn.send(chunk)
|
conn.send(chunk)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(conn.node, _('Object'),
|
self.exception_occurred(conn.node, _('Object'),
|
||||||
_('Trying to write to %s') % req.path)
|
_('Trying to write to %s') % req.path)
|
||||||
conns.remove(conn)
|
conns.remove(conn)
|
||||||
@ -1055,7 +1055,7 @@ class ObjectController(Controller):
|
|||||||
self.app.logger.info(
|
self.app.logger.info(
|
||||||
_('ERROR Client read timeout (%ss)'), err.seconds)
|
_('ERROR Client read timeout (%ss)'), err.seconds)
|
||||||
return HTTPRequestTimeout(request=req)
|
return HTTPRequestTimeout(request=req)
|
||||||
except:
|
except Exception:
|
||||||
req.client_disconnect = True
|
req.client_disconnect = True
|
||||||
self.app.logger.exception(
|
self.app.logger.exception(
|
||||||
_('ERROR Exception causing client disconnect'))
|
_('ERROR Exception causing client disconnect'))
|
||||||
@ -1083,7 +1083,7 @@ class ObjectController(Controller):
|
|||||||
'body': bodies[-1][:1024], 'path': req.path})
|
'body': bodies[-1][:1024], 'path': req.path})
|
||||||
elif 200 <= response.status < 300:
|
elif 200 <= response.status < 300:
|
||||||
etags.add(response.getheader('etag').strip('"'))
|
etags.add(response.getheader('etag').strip('"'))
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(conn.node, _('Object'),
|
self.exception_occurred(conn.node, _('Object'),
|
||||||
_('Trying to get final status of PUT to %s') % req.path)
|
_('Trying to get final status of PUT to %s') % req.path)
|
||||||
if len(etags) > 1:
|
if len(etags) > 1:
|
||||||
@ -1294,7 +1294,7 @@ class ContainerController(Controller):
|
|||||||
if source.status == 507:
|
if source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
accounts.insert(0, account)
|
accounts.insert(0, account)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
accounts.insert(0, account)
|
accounts.insert(0, account)
|
||||||
self.exception_occurred(node, _('Container'),
|
self.exception_occurred(node, _('Container'),
|
||||||
_('Trying to PUT to %s') % req.path)
|
_('Trying to PUT to %s') % req.path)
|
||||||
@ -1350,7 +1350,7 @@ class ContainerController(Controller):
|
|||||||
bodies.append(body)
|
bodies.append(body)
|
||||||
elif source.status == 507:
|
elif source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Container'),
|
self.exception_occurred(node, _('Container'),
|
||||||
_('Trying to POST %s') % req.path)
|
_('Trying to POST %s') % req.path)
|
||||||
if len(statuses) >= len(containers):
|
if len(statuses) >= len(containers):
|
||||||
@ -1406,7 +1406,7 @@ class ContainerController(Controller):
|
|||||||
if source.status == 507:
|
if source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
accounts.insert(0, account)
|
accounts.insert(0, account)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
accounts.insert(0, account)
|
accounts.insert(0, account)
|
||||||
self.exception_occurred(node, _('Container'),
|
self.exception_occurred(node, _('Container'),
|
||||||
_('Trying to DELETE %s') % req.path)
|
_('Trying to DELETE %s') % req.path)
|
||||||
@ -1491,7 +1491,7 @@ class AccountController(Controller):
|
|||||||
else:
|
else:
|
||||||
if source.status == 507:
|
if source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Account'),
|
self.exception_occurred(node, _('Account'),
|
||||||
_('Trying to PUT to %s') % req.path)
|
_('Trying to PUT to %s') % req.path)
|
||||||
if len(statuses) >= len(accounts):
|
if len(statuses) >= len(accounts):
|
||||||
@ -1539,7 +1539,7 @@ class AccountController(Controller):
|
|||||||
bodies.append(body)
|
bodies.append(body)
|
||||||
elif source.status == 507:
|
elif source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Account'),
|
self.exception_occurred(node, _('Account'),
|
||||||
_('Trying to POST %s') % req.path)
|
_('Trying to POST %s') % req.path)
|
||||||
if len(statuses) >= len(accounts):
|
if len(statuses) >= len(accounts):
|
||||||
@ -1584,7 +1584,7 @@ class AccountController(Controller):
|
|||||||
bodies.append(body)
|
bodies.append(body)
|
||||||
elif source.status == 507:
|
elif source.status == 507:
|
||||||
self.error_limit(node)
|
self.error_limit(node)
|
||||||
except:
|
except (Exception, TimeoutError):
|
||||||
self.exception_occurred(node, _('Account'),
|
self.exception_occurred(node, _('Account'),
|
||||||
_('Trying to DELETE %s') % req.path)
|
_('Trying to DELETE %s') % req.path)
|
||||||
if len(statuses) >= len(accounts):
|
if len(statuses) >= len(accounts):
|
||||||
@ -1685,7 +1685,7 @@ class BaseApplication(object):
|
|||||||
response = self.handle_request(req)(env, start_response)
|
response = self.handle_request(req)(env, start_response)
|
||||||
self.posthooklogger(env, req)
|
self.posthooklogger(env, req)
|
||||||
return response
|
return response
|
||||||
except:
|
except Exception:
|
||||||
print "EXCEPTION IN __call__: %s: %s" % \
|
print "EXCEPTION IN __call__: %s: %s" % \
|
||||||
(traceback.format_exc(), env)
|
(traceback.format_exc(), env)
|
||||||
start_response('500 Server Error',
|
start_response('500 Server Error',
|
||||||
|
@ -273,7 +273,7 @@ class LogProcessorDaemon(Daemon):
|
|||||||
already_processed_files = cPickle.loads(buf)
|
already_processed_files = cPickle.loads(buf)
|
||||||
else:
|
else:
|
||||||
already_processed_files = set()
|
already_processed_files = set()
|
||||||
except:
|
except Exception:
|
||||||
already_processed_files = set()
|
already_processed_files = set()
|
||||||
self.logger.debug(_('found %d processed files') % \
|
self.logger.debug(_('found %d processed files') % \
|
||||||
len(already_processed_files))
|
len(already_processed_files))
|
||||||
|
@ -49,7 +49,7 @@ def kill_pids(pids):
|
|||||||
for pid in pids.values():
|
for pid in pids.values():
|
||||||
try:
|
try:
|
||||||
kill(pid, SIGTERM)
|
kill(pid, SIGTERM)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class TestObjectHandoff(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
direct_client.direct_get_object(onode, opart, self.account,
|
direct_client.direct_get_object(onode, opart, self.account,
|
||||||
container, obj)
|
container, obj)
|
||||||
except:
|
except Exception:
|
||||||
exc = True
|
exc = True
|
||||||
if not exc:
|
if not exc:
|
||||||
raise Exception('Previously downed object server had test object')
|
raise Exception('Previously downed object server had test object')
|
||||||
@ -119,7 +119,7 @@ class TestObjectHandoff(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
direct_client.direct_get_object(another_onode, opart, self.account,
|
direct_client.direct_get_object(another_onode, opart, self.account,
|
||||||
container, obj)
|
container, obj)
|
||||||
except:
|
except Exception:
|
||||||
exc = True
|
exc = True
|
||||||
if not exc:
|
if not exc:
|
||||||
raise Exception('Handoff object server still had test object')
|
raise Exception('Handoff object server still had test object')
|
||||||
@ -134,7 +134,7 @@ class TestObjectHandoff(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
direct_client.direct_get_object(another_onode, opart, self.account,
|
direct_client.direct_get_object(another_onode, opart, self.account,
|
||||||
container, obj)
|
container, obj)
|
||||||
except:
|
except Exception:
|
||||||
exc = True
|
exc = True
|
||||||
if not exc:
|
if not exc:
|
||||||
raise Exception('Handoff server claimed it had the object when '
|
raise Exception('Handoff server claimed it had the object when '
|
||||||
@ -171,7 +171,7 @@ class TestObjectHandoff(unittest.TestCase):
|
|||||||
exc = False
|
exc = False
|
||||||
try:
|
try:
|
||||||
client.head_object(self.url, self.token, container, obj)
|
client.head_object(self.url, self.token, container, obj)
|
||||||
except:
|
except Exception:
|
||||||
exc = True
|
exc = True
|
||||||
if not exc:
|
if not exc:
|
||||||
raise Exception('Regular object HEAD was still successful')
|
raise Exception('Regular object HEAD was still successful')
|
||||||
@ -209,7 +209,7 @@ class TestObjectHandoff(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
direct_client.direct_get_object(another_onode, opart, self.account,
|
direct_client.direct_get_object(another_onode, opart, self.account,
|
||||||
container, obj)
|
container, obj)
|
||||||
except:
|
except Exception:
|
||||||
exc = True
|
exc = True
|
||||||
if not exc:
|
if not exc:
|
||||||
raise Exception('Handoff object server still had the object')
|
raise Exception('Handoff object server still had the object')
|
||||||
|
@ -51,7 +51,7 @@ class FakeMemcache(object):
|
|||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
try:
|
try:
|
||||||
del self.store[key]
|
del self.store[key]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class FakeMemcache(object):
|
|||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
try:
|
try:
|
||||||
del self.store[key]
|
del self.store[key]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class FakeMemcache(object):
|
|||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
try:
|
try:
|
||||||
del self.store[key]
|
del self.store[key]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ class TestDatabaseBroker(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
conn.execute('SELECT 1')
|
conn.execute('SELECT 1')
|
||||||
except:
|
except Exception:
|
||||||
got_exc = True
|
got_exc = True
|
||||||
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
|
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
|
||||||
got_exc = False
|
got_exc = False
|
||||||
try:
|
try:
|
||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
conn.execute('SELECT 1')
|
conn.execute('SELECT 1')
|
||||||
except:
|
except Exception:
|
||||||
got_exc = True
|
got_exc = True
|
||||||
self.assert_(got_exc)
|
self.assert_(got_exc)
|
||||||
def stub(*args, **kwargs):
|
def stub(*args, **kwargs):
|
||||||
@ -186,7 +186,7 @@ class TestDatabaseBroker(unittest.TestCase):
|
|||||||
conn.execute('INSERT INTO test (one) VALUES ("1")')
|
conn.execute('INSERT INTO test (one) VALUES ("1")')
|
||||||
raise Exception('test')
|
raise Exception('test')
|
||||||
conn.commit()
|
conn.commit()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
|
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
|
||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
@ -230,7 +230,7 @@ class TestDatabaseBroker(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
with broker.lock():
|
with broker.lock():
|
||||||
raise Exception('test')
|
raise Exception('test')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
with broker.lock():
|
with broker.lock():
|
||||||
pass
|
pass
|
||||||
@ -548,7 +548,7 @@ class TestContainerBroker(unittest.TestCase):
|
|||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
self.assertEquals(first_conn, conn)
|
self.assertEquals(first_conn, conn)
|
||||||
raise Exception('OMG')
|
raise Exception('OMG')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.assert_(broker.conn == None)
|
self.assert_(broker.conn == None)
|
||||||
|
|
||||||
@ -1363,7 +1363,7 @@ class TestAccountBroker(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
pass
|
pass
|
||||||
except:
|
except Exception:
|
||||||
got_exc = True
|
got_exc = True
|
||||||
self.assert_(got_exc)
|
self.assert_(got_exc)
|
||||||
broker.initialize(normalize_timestamp('1'))
|
broker.initialize(normalize_timestamp('1'))
|
||||||
@ -1384,7 +1384,7 @@ class TestAccountBroker(unittest.TestCase):
|
|||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
self.assertEquals(first_conn, conn)
|
self.assertEquals(first_conn, conn)
|
||||||
raise Exception('OMG')
|
raise Exception('OMG')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.assert_(broker.conn == None)
|
self.assert_(broker.conn == None)
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
testroot = os.path.join(os.path.dirname(__file__), 'mkdirs')
|
testroot = os.path.join(os.path.dirname(__file__), 'mkdirs')
|
||||||
try:
|
try:
|
||||||
os.unlink(testroot)
|
os.unlink(testroot)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
rmtree(testroot, ignore_errors=1)
|
rmtree(testroot, ignore_errors=1)
|
||||||
self.assert_(not os.path.exists(testroot))
|
self.assert_(not os.path.exists(testroot))
|
||||||
@ -211,14 +211,14 @@ class TestUtils(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
for line in lfo:
|
for line in lfo:
|
||||||
pass
|
pass
|
||||||
except:
|
except Exception:
|
||||||
got_exc = True
|
got_exc = True
|
||||||
self.assert_(got_exc)
|
self.assert_(got_exc)
|
||||||
got_exc = False
|
got_exc = False
|
||||||
try:
|
try:
|
||||||
for line in lfo.xreadlines():
|
for line in lfo.xreadlines():
|
||||||
pass
|
pass
|
||||||
except:
|
except Exception:
|
||||||
got_exc = True
|
got_exc = True
|
||||||
self.assert_(got_exc)
|
self.assert_(got_exc)
|
||||||
self.assertRaises(IOError, lfo.read)
|
self.assertRaises(IOError, lfo.read)
|
||||||
|
@ -47,7 +47,7 @@ from swift.common import ring
|
|||||||
from swift.common.constraints import MAX_META_NAME_LENGTH, \
|
from swift.common.constraints import MAX_META_NAME_LENGTH, \
|
||||||
MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, MAX_FILE_SIZE
|
MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, MAX_FILE_SIZE
|
||||||
from swift.common.utils import mkdirs, normalize_timestamp, NullLogger
|
from swift.common.utils import mkdirs, normalize_timestamp, NullLogger
|
||||||
|
from swift.common.wsgi import monkey_patch_mimetools
|
||||||
# mocks
|
# mocks
|
||||||
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
|
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
|
||||||
|
|
||||||
@ -426,6 +426,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.app = proxy_server.Application(None, FakeMemcache(),
|
self.app = proxy_server.Application(None, FakeMemcache(),
|
||||||
account_ring=FakeRing(), container_ring=FakeRing(),
|
account_ring=FakeRing(), container_ring=FakeRing(),
|
||||||
object_ring=FakeRing())
|
object_ring=FakeRing())
|
||||||
|
monkey_patch_mimetools()
|
||||||
|
|
||||||
def assert_status_map(self, method, statuses, expected, raise_exc=False):
|
def assert_status_map(self, method, statuses, expected, raise_exc=False):
|
||||||
with save_globals():
|
with save_globals():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user