From 86cb12036b4ee9554b0d011431ce0c928a6e9b4a Mon Sep 17 00:00:00 2001 From: David Goetz Date: Wed, 26 Jan 2011 14:31:33 -0800 Subject: [PATCH] removing blank excepts --- bin/st | 10 +++--- bin/swift-drive-audit | 2 +- bin/swift-object-info | 2 +- bin/swift-stats-populate | 4 +-- swift/account/server.py | 2 +- swift/auth/server.py | 6 ++-- swift/common/bench.py | 2 +- swift/common/client.py | 2 +- swift/common/db.py | 10 +++--- swift/common/db_replicator.py | 8 ++--- swift/common/middleware/swauth.py | 5 +-- swift/container/server.py | 5 +-- swift/container/updater.py | 6 ++-- swift/obj/server.py | 6 ++-- swift/obj/updater.py | 4 +-- swift/proxy/server.py | 34 +++++++++---------- swift/stats/log_processor.py | 2 +- test/probe/common.py | 2 +- test/probe/test_object_handoff.py | 10 +++--- test/unit/common/middleware/test_auth.py | 2 +- test/unit/common/middleware/test_ratelimit.py | 2 +- test/unit/common/middleware/test_swauth.py | 2 +- test/unit/common/test_db.py | 14 ++++---- test/unit/common/test_utils.py | 6 ++-- test/unit/proxy/test_server.py | 3 +- 25 files changed, 77 insertions(+), 74 deletions(-) diff --git a/bin/st b/bin/st index cab398910e..39872e8bd0 100755 --- a/bin/st +++ b/bin/st @@ -38,13 +38,13 @@ from urlparse import urlparse, urlunparse try: from eventlet import sleep -except: +except Exception: from time import sleep try: from swift.common.bufferedhttp \ import BufferedHTTPConnection as HTTPConnection -except: +except Exception: from httplib import HTTPConnection @@ -91,7 +91,7 @@ except ImportError: else: res.append(val) return eval(''.join(res), {}, consts) - except: + except Exception: raise AttributeError() @@ -1615,7 +1615,7 @@ def st_upload(options, args, print_queue, error_queue): conn.put_container(args[0]) if options.segment_size is not None: conn.put_container(args[0] + '_segments') - except: + except Exception: pass try: for arg in args[1:]: @@ -1722,7 +1722,7 @@ Example: error_thread.abort = True while error_thread.isAlive(): error_thread.join(0.01) - except: + except Exception: for thread in threading_enumerate(): thread.abort = True raise diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index 95143e8b56..e92d1e3c12 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -89,7 +89,7 @@ if __name__ == '__main__': c = ConfigParser() try: conf_path = sys.argv[1] - except: + except Exception: print "Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1] sys.exit(1) if not c.read(conf_path): diff --git a/bin/swift-object-info b/bin/swift-object-info index e7befddf8c..278a7de0f2 100755 --- a/bin/swift-object-info +++ b/bin/swift-object-info @@ -29,7 +29,7 @@ if __name__ == '__main__': sys.exit(1) try: ring = Ring('/etc/swift/object.ring.gz') - except: + except Exception: ring = None datafile = sys.argv[1] fp = open(datafile, 'rb') diff --git a/bin/swift-stats-populate b/bin/swift-stats-populate index ba531ddc87..483f22dbb6 100755 --- a/bin/swift-stats-populate +++ b/bin/swift-stats-populate @@ -38,7 +38,7 @@ def put_container(connpool, container, report): retries_done += conn.attempts - 1 if report: report(True) - except: + except Exception: if report: report(False) raise @@ -53,7 +53,7 @@ def put_object(connpool, container, obj, report): retries_done += conn.attempts - 1 if report: report(True) - except: + except Exception: if report: report(False) raise diff --git a/swift/account/server.py b/swift/account/server.py index a1e20c1f4f..2c83f51cc6 100644 --- a/swift/account/server.py +++ b/swift/account/server.py @@ -305,7 +305,7 @@ class AccountController(object): res = getattr(self, req.method)(req) else: res = HTTPMethodNotAllowed() - except: + except Exception: self.logger.exception(_('ERROR __call__ error with %(method)s' ' %(path)s '), {'method': req.method, 'path': req.path}) res = HTTPInternalServerError(body=traceback.format_exc()) diff --git a/swift/auth/server.py b/swift/auth/server.py index dac3a78a3e..a51ccdeb72 100644 --- a/swift/auth/server.py +++ b/swift/auth/server.py @@ -96,7 +96,7 @@ class AuthController(object): msg = _('No super_admin_key set in conf file! Exiting.') try: self.logger.critical(msg) - except: + except Exception: pass raise ValueError(msg) self.swift_dir = conf.get('swift_dir', '/etc/swift') @@ -237,7 +237,7 @@ YOU HAVE A FEW OPTIONS: except Exception, err: try: conn.close() - except: + except Exception: pass self.conn = get_db_connection(self.db_file) raise err @@ -637,7 +637,7 @@ YOU HAVE A FEW OPTIONS: else: return HTTPBadRequest(request=env)(env, start_response) response = handler(req) - except: + except Exception: self.logger.exception( _('ERROR Unhandled exception in ReST request')) return HTTPServiceUnavailable(request=req)(env, start_response) diff --git a/swift/common/bench.py b/swift/common/bench.py index 4abafeb947..943f9ebe4d 100644 --- a/swift/common/bench.py +++ b/swift/common/bench.py @@ -97,7 +97,7 @@ class Bench(object): self.logger.info(_("CannotSendRequest. Skipping...")) try: hc.close() - except: + except Exception: pass self.failures += 1 hc = self.conn_pool.create() diff --git a/swift/common/client.py b/swift/common/client.py index 9e80e9cef1..ebef5154dd 100644 --- a/swift/common/client.py +++ b/swift/common/client.py @@ -87,7 +87,7 @@ except ImportError: else: res.append(val) return eval(''.join(res), {}, consts) - except: + except Exception: raise AttributeError() diff --git a/swift/common/db.py b/swift/common/db.py index b3c80dbc8c..82648f9e49 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -269,7 +269,7 @@ class DatabaseBroker(object): yield conn conn.rollback() self.conn = conn - except: + except Exception: conn.close() raise @@ -288,13 +288,13 @@ class DatabaseBroker(object): conn.execute('BEGIN IMMEDIATE') try: yield True - except: + except Exception: pass try: conn.execute('ROLLBACK') conn.isolation_level = orig_isolation_level self.conn = conn - except: # pragma: no cover + except Exception: logging.exception( _('Broker error trying to rollback locked connection')) conn.close() @@ -749,7 +749,7 @@ class ContainerBroker(DatabaseBroker): timestamp, 'size': size, 'content_type': content_type, 'etag': etag, 'deleted': deleted}) - except: + except Exception: self.logger.exception( _('Invalid pending entry %(file)s: %(entry)s'), {'file': self.pending_file, 'entry': entry}) @@ -1216,7 +1216,7 @@ class AccountBroker(DatabaseBroker): 'object_count': object_count, 'bytes_used': bytes_used, 'deleted': deleted}) - except: + except Exception: self.logger.exception( _('Invalid pending entry %(file)s: %(entry)s'), {'file': self.pending_file, 'entry': entry}) diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 4c479a0ed0..49756f1f7b 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -21,7 +21,7 @@ import math import time import shutil -from eventlet import GreenPool, sleep, Timeout +from eventlet import GreenPool, sleep, Timeout, TimeoutError from eventlet.green import subprocess import simplejson from webob import Response @@ -79,7 +79,7 @@ class ReplConnection(BufferedHTTPConnection): response = self.getresponse() response.data = response.read() return response - except: + except Exception: self.logger.exception( _('ERROR reading HTTP response from %s'), self.node) return None @@ -359,7 +359,7 @@ class Replicator(Daemon): except DriveNotMounted: repl_nodes.append(more_nodes.next()) self.logger.error(_('ERROR Remote drive not mounted %s'), node) - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR syncing %(file)s with node' ' %(node)s'), {'file': object_file, 'node': node}) self.stats['success' if success else 'failure'] += 1 @@ -432,7 +432,7 @@ class Replicator(Daemon): while True: try: self.run_once() - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR trying to replicate')) sleep(self.run_pause) diff --git a/swift/common/middleware/swauth.py b/swift/common/middleware/swauth.py index 105098c807..0c8440aa86 100644 --- a/swift/common/middleware/swauth.py +++ b/swift/common/middleware/swauth.py @@ -25,6 +25,7 @@ from urlparse import urlparse from uuid import uuid4 from eventlet.timeout import Timeout +from eventlet import TimeoutError from webob import Response, Request from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \ HTTPCreated, HTTPForbidden, HTTPNoContent, HTTPNotFound, \ @@ -283,7 +284,7 @@ class Swauth(object): response = self.handle_request(req)(env, start_response) self.posthooklogger(env, req) return response - except: + except (Exception, TimeoutError): print "EXCEPTION IN handle: %s: %s" % (format_exc(), env) start_response('500 Server Error', [('Content-Type', 'text/plain')]) @@ -589,7 +590,7 @@ class Swauth(object): if resp.status // 100 != 2: raise Exception('Could not create account on the Swift ' 'cluster: %s %s %s' % (path, resp.status, resp.reason)) - except: + except (Exception, TimeoutError): self.logger.error(_('ERROR: Exception while trying to communicate ' 'with %(scheme)s://%(host)s:%(port)s/%(path)s'), {'scheme': self.dsc_parsed2.scheme, diff --git a/swift/container/server.py b/swift/container/server.py index 7ba375ce33..cfcdded1e4 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -24,6 +24,7 @@ from datetime import datetime import simplejson from eventlet.timeout import Timeout +from eventlet import TimeoutError from webob import Request, Response from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \ HTTPCreated, HTTPInternalServerError, HTTPNoContent, \ @@ -118,7 +119,7 @@ class ContainerController(object): 'device': account_device, 'status': account_response.status, 'reason': account_response.reason}) - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR account update failed with ' '%(ip)s:%(port)s/%(device)s (will retry later)'), {'ip': account_ip, 'port': account_port, @@ -393,7 +394,7 @@ class ContainerController(object): res = getattr(self, req.method)(req) else: res = HTTPMethodNotAllowed() - except: + except Exception: self.logger.exception(_('ERROR __call__ error with %(method)s' ' %(path)s '), {'method': req.method, 'path': req.path}) res = HTTPInternalServerError(body=traceback.format_exc()) diff --git a/swift/container/updater.py b/swift/container/updater.py index d6b1beb2b1..aea65e2425 100644 --- a/swift/container/updater.py +++ b/swift/container/updater.py @@ -20,7 +20,7 @@ import sys import time 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.common.bufferedhttp import http_connect @@ -221,7 +221,7 @@ class ContainerUpdater(Daemon): 'X-Object-Count': count, 'X-Bytes-Used': bytes, 'X-Account-Override-Deleted': 'yes'}) - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR account update failed with ' '%(ip)s:%(port)s/%(device)s (will retry later): '), node) return 500 @@ -230,7 +230,7 @@ class ContainerUpdater(Daemon): resp = conn.getresponse() resp.read() return resp.status - except: + except (Exception, TimeoutError): if self.logger.getEffectiveLevel() <= logging.DEBUG: self.logger.exception( _('Exception with %(ip)s:%(port)s/%(device)s'), node) diff --git a/swift/obj/server.py b/swift/obj/server.py index 4afc38057d..c1ddd63310 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -33,7 +33,7 @@ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \ HTTPNotModified, HTTPPreconditionFailed, \ HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed 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, \ storage_directory, hash_path, renamer, fallocate, \ @@ -308,7 +308,7 @@ class ObjectController(object): 'response from %(ip)s:%(port)s/%(dev)s'), {'status': response.status, 'ip': ip, 'port': port, 'dev': contdevice}) - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR container update failed with ' '%(ip)s:%(port)s/%(dev)s (saving for async update later)'), {'ip': ip, 'port': port, 'dev': contdevice}) @@ -582,7 +582,7 @@ class ObjectController(object): res = getattr(self, req.method)(req) else: res = HTTPMethodNotAllowed() - except: + except Exception: self.logger.exception(_('ERROR __call__ error with %(method)s' ' %(path)s '), {'method': req.method, 'path': req.path}) res = HTTPInternalServerError(body=traceback.format_exc()) diff --git a/swift/obj/updater.py b/swift/obj/updater.py index a226d4523e..2b28ff08c5 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -20,7 +20,7 @@ import sys import time 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.exceptions import ConnectionTimeout @@ -202,7 +202,7 @@ class ObjectUpdater(Daemon): resp = conn.getresponse() resp.read() return resp.status - except: + except (Exception, TimeoutError): self.logger.exception(_('ERROR with remote server ' '%(ip)s:%(port)s/%(device)s'), node) return 500 diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 32c7ad9004..f872199335 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -30,7 +30,7 @@ import uuid import functools from hashlib import md5 -from eventlet import sleep +from eventlet import sleep, TimeoutError from eventlet.timeout import Timeout from webob.exc import HTTPBadRequest, HTTPMethodNotAllowed, \ HTTPNotFound, HTTPPreconditionFailed, \ @@ -383,7 +383,7 @@ class Controller(object): attempts_left -= 1 if attempts_left <= 0: break - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Account'), _('Trying to get account info for %s') % path) if self.app.memcache and result_code in (200, 404): @@ -461,7 +461,7 @@ class Controller(object): attempts_left -= 1 if attempts_left <= 0: break - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Container'), _('Trying to get container info for %s') % path) if self.app.memcache and result_code in (200, 404): @@ -592,7 +592,7 @@ class Controller(object): query_string=req.query_string) with Timeout(self.app.node_timeout): source = conn.getresponse() - except: + except (Exception, TimeoutError): self.exception_occurred(node, server_type, _('Trying to %(method)s %(path)s') % {'method': req.method, 'path': req.path}) @@ -624,7 +624,7 @@ class Controller(object): except GeneratorExit: res.client_disconnect = True self.app.logger.info(_('Client disconnected on read')) - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Object'), _('Trying to read during GET of %s') % req.path) raise @@ -691,7 +691,7 @@ class ObjectController(Controller): _('ERROR %(status)d %(body)s From Object Server') % {'status': response.status, 'body': body[:1024]}) return response.status, response.reason, body - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Object'), _('Trying to %(method)s %(path)s') % {'method': req.method, 'path': req.path}) @@ -998,7 +998,7 @@ class ObjectController(Controller): conn.node = node with Timeout(self.app.node_timeout): resp = conn.getexpect() - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Object'), _('Expect: 100-continue on %s') % req.path) if conn and resp: @@ -1038,7 +1038,7 @@ class ObjectController(Controller): conn.send('%x\r\n%s\r\n' % (len_chunk, chunk)) else: conn.send(chunk) - except: + except (Exception, TimeoutError): self.exception_occurred(conn.node, _('Object'), _('Trying to write to %s') % req.path) conns.remove(conn) @@ -1055,7 +1055,7 @@ class ObjectController(Controller): self.app.logger.info( _('ERROR Client read timeout (%ss)'), err.seconds) return HTTPRequestTimeout(request=req) - except: + except Exception: req.client_disconnect = True self.app.logger.exception( _('ERROR Exception causing client disconnect')) @@ -1083,7 +1083,7 @@ class ObjectController(Controller): 'body': bodies[-1][:1024], 'path': req.path}) elif 200 <= response.status < 300: etags.add(response.getheader('etag').strip('"')) - except: + except (Exception, TimeoutError): self.exception_occurred(conn.node, _('Object'), _('Trying to get final status of PUT to %s') % req.path) if len(etags) > 1: @@ -1294,7 +1294,7 @@ class ContainerController(Controller): if source.status == 507: self.error_limit(node) accounts.insert(0, account) - except: + except (Exception, TimeoutError): accounts.insert(0, account) self.exception_occurred(node, _('Container'), _('Trying to PUT to %s') % req.path) @@ -1350,7 +1350,7 @@ class ContainerController(Controller): bodies.append(body) elif source.status == 507: self.error_limit(node) - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Container'), _('Trying to POST %s') % req.path) if len(statuses) >= len(containers): @@ -1406,7 +1406,7 @@ class ContainerController(Controller): if source.status == 507: self.error_limit(node) accounts.insert(0, account) - except: + except (Exception, TimeoutError): accounts.insert(0, account) self.exception_occurred(node, _('Container'), _('Trying to DELETE %s') % req.path) @@ -1491,7 +1491,7 @@ class AccountController(Controller): else: if source.status == 507: self.error_limit(node) - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Account'), _('Trying to PUT to %s') % req.path) if len(statuses) >= len(accounts): @@ -1539,7 +1539,7 @@ class AccountController(Controller): bodies.append(body) elif source.status == 507: self.error_limit(node) - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Account'), _('Trying to POST %s') % req.path) if len(statuses) >= len(accounts): @@ -1584,7 +1584,7 @@ class AccountController(Controller): bodies.append(body) elif source.status == 507: self.error_limit(node) - except: + except (Exception, TimeoutError): self.exception_occurred(node, _('Account'), _('Trying to DELETE %s') % req.path) if len(statuses) >= len(accounts): @@ -1685,7 +1685,7 @@ class BaseApplication(object): response = self.handle_request(req)(env, start_response) self.posthooklogger(env, req) return response - except: + except Exception: print "EXCEPTION IN __call__: %s: %s" % \ (traceback.format_exc(), env) start_response('500 Server Error', diff --git a/swift/stats/log_processor.py b/swift/stats/log_processor.py index f8938ddbc2..884e949842 100644 --- a/swift/stats/log_processor.py +++ b/swift/stats/log_processor.py @@ -273,7 +273,7 @@ class LogProcessorDaemon(Daemon): already_processed_files = cPickle.loads(buf) else: already_processed_files = set() - except: + except Exception: already_processed_files = set() self.logger.debug(_('found %d processed files') % \ len(already_processed_files)) diff --git a/test/probe/common.py b/test/probe/common.py index c29f142713..08e8309a4b 100644 --- a/test/probe/common.py +++ b/test/probe/common.py @@ -49,7 +49,7 @@ def kill_pids(pids): for pid in pids.values(): try: kill(pid, SIGTERM) - except: + except Exception: pass diff --git a/test/probe/test_object_handoff.py b/test/probe/test_object_handoff.py index ba81e4c559..212fcc2c5e 100755 --- a/test/probe/test_object_handoff.py +++ b/test/probe/test_object_handoff.py @@ -95,7 +95,7 @@ class TestObjectHandoff(unittest.TestCase): try: direct_client.direct_get_object(onode, opart, self.account, container, obj) - except: + except Exception: exc = True if not exc: raise Exception('Previously downed object server had test object') @@ -119,7 +119,7 @@ class TestObjectHandoff(unittest.TestCase): try: direct_client.direct_get_object(another_onode, opart, self.account, container, obj) - except: + except Exception: exc = True if not exc: raise Exception('Handoff object server still had test object') @@ -134,7 +134,7 @@ class TestObjectHandoff(unittest.TestCase): try: direct_client.direct_get_object(another_onode, opart, self.account, container, obj) - except: + except Exception: exc = True if not exc: raise Exception('Handoff server claimed it had the object when ' @@ -171,7 +171,7 @@ class TestObjectHandoff(unittest.TestCase): exc = False try: client.head_object(self.url, self.token, container, obj) - except: + except Exception: exc = True if not exc: raise Exception('Regular object HEAD was still successful') @@ -209,7 +209,7 @@ class TestObjectHandoff(unittest.TestCase): try: direct_client.direct_get_object(another_onode, opart, self.account, container, obj) - except: + except Exception: exc = True if not exc: raise Exception('Handoff object server still had the object') diff --git a/test/unit/common/middleware/test_auth.py b/test/unit/common/middleware/test_auth.py index cabc7a9523..d3a73bb50a 100644 --- a/test/unit/common/middleware/test_auth.py +++ b/test/unit/common/middleware/test_auth.py @@ -51,7 +51,7 @@ class FakeMemcache(object): def delete(self, key): try: del self.store[key] - except: + except Exception: pass return True diff --git a/test/unit/common/middleware/test_ratelimit.py b/test/unit/common/middleware/test_ratelimit.py index 3f993a0402..48c07f1f65 100644 --- a/test/unit/common/middleware/test_ratelimit.py +++ b/test/unit/common/middleware/test_ratelimit.py @@ -51,7 +51,7 @@ class FakeMemcache(object): def delete(self, key): try: del self.store[key] - except: + except Exception: pass return True diff --git a/test/unit/common/middleware/test_swauth.py b/test/unit/common/middleware/test_swauth.py index 2e4d958a44..a69f272788 100644 --- a/test/unit/common/middleware/test_swauth.py +++ b/test/unit/common/middleware/test_swauth.py @@ -49,7 +49,7 @@ class FakeMemcache(object): def delete(self, key): try: del self.store[key] - except: + except Exception: pass return True diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index 49bc8a9229..e63397c954 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -165,14 +165,14 @@ class TestDatabaseBroker(unittest.TestCase): try: with broker.get() as conn: conn.execute('SELECT 1') - except: + except Exception: got_exc = True broker = DatabaseBroker(os.path.join(self.testdir, '1.db')) got_exc = False try: with broker.get() as conn: conn.execute('SELECT 1') - except: + except Exception: got_exc = True self.assert_(got_exc) def stub(*args, **kwargs): @@ -186,7 +186,7 @@ class TestDatabaseBroker(unittest.TestCase): conn.execute('INSERT INTO test (one) VALUES ("1")') raise Exception('test') conn.commit() - except: + except Exception: pass broker = DatabaseBroker(os.path.join(self.testdir, '1.db')) with broker.get() as conn: @@ -230,7 +230,7 @@ class TestDatabaseBroker(unittest.TestCase): try: with broker.lock(): raise Exception('test') - except: + except Exception: pass with broker.lock(): pass @@ -548,7 +548,7 @@ class TestContainerBroker(unittest.TestCase): with broker.get() as conn: self.assertEquals(first_conn, conn) raise Exception('OMG') - except: + except Exception: pass self.assert_(broker.conn == None) @@ -1363,7 +1363,7 @@ class TestAccountBroker(unittest.TestCase): try: with broker.get() as conn: pass - except: + except Exception: got_exc = True self.assert_(got_exc) broker.initialize(normalize_timestamp('1')) @@ -1384,7 +1384,7 @@ class TestAccountBroker(unittest.TestCase): with broker.get() as conn: self.assertEquals(first_conn, conn) raise Exception('OMG') - except: + except Exception: pass self.assert_(broker.conn == None) diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 1f5a94edd5..60ca38c2ca 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -107,7 +107,7 @@ class TestUtils(unittest.TestCase): testroot = os.path.join(os.path.dirname(__file__), 'mkdirs') try: os.unlink(testroot) - except: + except Exception: pass rmtree(testroot, ignore_errors=1) self.assert_(not os.path.exists(testroot)) @@ -211,14 +211,14 @@ class TestUtils(unittest.TestCase): try: for line in lfo: pass - except: + except Exception: got_exc = True self.assert_(got_exc) got_exc = False try: for line in lfo.xreadlines(): pass - except: + except Exception: got_exc = True self.assert_(got_exc) self.assertRaises(IOError, lfo.read) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index e5a4e40652..7e69502364 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -47,7 +47,7 @@ from swift.common import ring from swift.common.constraints import MAX_META_NAME_LENGTH, \ 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.wsgi import monkey_patch_mimetools # mocks logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) @@ -426,6 +426,7 @@ class TestObjectController(unittest.TestCase): self.app = proxy_server.Application(None, FakeMemcache(), account_ring=FakeRing(), container_ring=FakeRing(), object_ring=FakeRing()) + monkey_patch_mimetools() def assert_status_map(self, method, statuses, expected, raise_exc=False): with save_globals():