diff --git a/supervisor/datatypes.py b/supervisor/datatypes.py index 7fa0dc2fe..a69b2068a 100644 --- a/supervisor/datatypes.py +++ b/supervisor/datatypes.py @@ -43,7 +43,7 @@ def list_of_strings(arg): return [] try: return [x.strip() for x in arg.split(',')] - except: + except Exception: raise ValueError("not a valid list of strings: " + repr(arg)) def list_of_ints(arg): @@ -52,7 +52,7 @@ def list_of_ints(arg): else: try: return list(map(int, arg.split(","))) - except: + except Exception: raise ValueError("not a valid list of ints: " + repr(arg)) def list_of_exitcodes(arg): @@ -62,7 +62,7 @@ def list_of_exitcodes(arg): if (val > 255) or (val < 0): raise ValueError('Invalid exit code "%s"' % val) return vals - except: + except Exception: raise ValueError("not a valid list of exit codes: " + repr(arg)) def dict_of_key_value_pairs(arg): @@ -221,7 +221,7 @@ def create_and_bind(self): try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(self.addr()) - except: + except Exception: sock.close() raise return sock @@ -252,7 +252,7 @@ def create_and_bind(self): sock.bind(self.addr()) self._chown() self._chmod() - except: + except Exception: sock.close() if os.path.exists(self.path): os.unlink(self.path) @@ -295,7 +295,7 @@ def colon_separated_user_group(arg): uid = name_to_uid(parts[0]) gid = name_to_gid(parts[1]) return (uid, gid) - except: + except Exception: raise ValueError('Invalid user:group definition %s' % arg) def name_to_uid(name): diff --git a/supervisor/dispatchers.py b/supervisor/dispatchers.py index 0718a5868..595ca8951 100644 --- a/supervisor/dispatchers.py +++ b/supervisor/dispatchers.py @@ -455,7 +455,7 @@ def handle_result(self, result): logger.warn('%s: event was rejected' % procname) self._change_listener_state(EventListenerStates.ACKNOWLEDGED) notify(EventRejectedEvent(process, process.event)) - except: + except Exception: logger.warn('%s: event caused an error' % procname) self._change_listener_state(EventListenerStates.UNKNOWN) notify(EventRejectedEvent(process, process.event)) diff --git a/supervisor/http.py b/supervisor/http.py index af3e3da87..3830b1e7d 100644 --- a/supervisor/http.py +++ b/supervisor/http.py @@ -448,7 +448,7 @@ def found_terminator (self): # This isn't used anywhere. # r.handler = h # CYCLE h.handle_request (r) - except: + except Exception: self.server.exceptions.increment() (file, fun, line), t, v, tbinfo = \ asyncore.compact_traceback() @@ -458,7 +458,7 @@ def found_terminator (self): 'error') try: r.error (500) - except: + except Exception: pass return @@ -588,7 +588,7 @@ def __init__(self, socketname, sockchmod, sockchown, logger_object): sys.stderr.write(msg) try: os.unlink(socketname) - except: + except Exception: pass sock.close() time.sleep(.3) @@ -819,7 +819,7 @@ def make_http_servers(options, supervisord): for name, factory, d in options.rpcinterface_factories: try: inst = factory(supervisord, **d) - except: + except Exception: tb = traceback.format_exc() options.logger.warn(tb) raise ValueError('Could not make %s rpc interface' % name) diff --git a/supervisor/loggers.py b/supervisor/loggers.py index 44d14b44c..232f06931 100644 --- a/supervisor/loggers.py +++ b/supervisor/loggers.py @@ -107,7 +107,7 @@ def emit(self, record): # time it's called. So just do it again self.stream.write(msg) self.flush() - except: + except Exception: self.handleError() def handleError(self): @@ -376,7 +376,7 @@ def emit(self, record): self._syslog(msg) except UnicodeError: self._syslog(msg.encode("UTF-8")) - except: + except Exception: self.handleError() def getLogger(level=None): diff --git a/supervisor/medusa/asyncore_25.py b/supervisor/medusa/asyncore_25.py index d3efdf7a5..e05ecb45f 100644 --- a/supervisor/medusa/asyncore_25.py +++ b/supervisor/medusa/asyncore_25.py @@ -70,7 +70,7 @@ def read(obj): obj.handle_read_event() except ExitNow: raise - except: + except Exception: obj.handle_error() def write(obj): @@ -78,7 +78,7 @@ def write(obj): obj.handle_write_event() except ExitNow: raise - except: + except Exception: obj.handle_error() def _exception (obj): @@ -86,7 +86,7 @@ def _exception (obj): obj.handle_expt_event() except ExitNow: raise - except: + except Exception: obj.handle_error() def readwrite(obj, flags): @@ -99,7 +99,7 @@ def readwrite(obj, flags): obj.handle_expt_event() except ExitNow: raise - except: + except Exception: obj.handle_error() def poll(timeout=0.0, map=None): @@ -415,7 +415,7 @@ def handle_error(self): # sometimes a user repr method will crash. try: self_repr = repr(self) - except: + except Exception: self_repr = '<__repr__(self) failed for object at %0x>' % id(self) self.log_info( diff --git a/supervisor/medusa/auth_handler.py b/supervisor/medusa/auth_handler.py index 0aba00d79..91aa5f040 100644 --- a/supervisor/medusa/auth_handler.py +++ b/supervisor/medusa/auth_handler.py @@ -53,7 +53,7 @@ def handle_request (self, request): cookie = get_header (AUTHORIZATION, request.header, 2) try: decoded = as_string(decodestring(as_bytes(cookie))) - except: + except Exception: sys.stderr.write('malformed authorization info <%s>\n' % cookie) request.error (400) return diff --git a/supervisor/medusa/default_handler.py b/supervisor/medusa/default_handler.py index 299171825..c1ca0460e 100644 --- a/supervisor/medusa/default_handler.py +++ b/supervisor/medusa/default_handler.py @@ -132,7 +132,7 @@ def handle_request (self, request): length = int(length) if length != file_length: length_match = 0 - except: + except Exception: pass ims_date = 0 @@ -142,7 +142,7 @@ def handle_request (self, request): try: mtime = self.filesystem.stat (path)[stat.ST_MTIME] - except: + except Exception: request.error (404) return diff --git a/supervisor/medusa/filesys.py b/supervisor/medusa/filesys.py index c056ce7c2..a2d7b384b 100644 --- a/supervisor/medusa/filesys.py +++ b/supervisor/medusa/filesys.py @@ -78,7 +78,7 @@ def longify (self, path): def safe_stat (path): try: return path, os.stat (path) - except: + except Exception: return None class os_filesystem: @@ -118,7 +118,7 @@ def cwd (self, path): os.chdir (translated_path) can = 1 self.wd = p - except: + except Exception: pass finally: if can: @@ -295,7 +295,7 @@ def msdos_longify (file, stat_info): def msdos_date (t): try: info = time.gmtime (t) - except: + except Exception: info = time.gmtime (0) # year, month, day, hour, minute, second, ... hour = info[3] @@ -359,7 +359,7 @@ def unix_longify (file, stat_info): def ls_date (now, t): try: info = time.gmtime (t) - except: + except Exception: info = time.gmtime (0) # 15,600,000 == 86,400 * 180 if (now - t) > 15600000: diff --git a/supervisor/medusa/http_server.py b/supervisor/medusa/http_server.py index 0817fd8a6..593296fc1 100644 --- a/supervisor/medusa/http_server.py +++ b/supervisor/medusa/http_server.py @@ -616,7 +616,7 @@ def found_terminator (self): # This isn't used anywhere. # r.handler = h # CYCLE h.handle_request (r) - except: + except Exception: self.server.exceptions.increment() (file, fun, line), t, v, tbinfo = asyncore.compact_traceback() self.log_info( @@ -624,7 +624,7 @@ def found_terminator (self): 'error') try: r.error (500) - except: + except Exception: pass return diff --git a/supervisor/medusa/logger.py b/supervisor/medusa/logger.py index d5386c366..894134137 100644 --- a/supervisor/medusa/logger.py +++ b/supervisor/medusa/logger.py @@ -134,7 +134,7 @@ def rotate (self): pass os.rename(self.filename, newname) self.file = open(self.filename, self.mode) - except: + except Exception: pass # log to a stream socket, asynchronously diff --git a/supervisor/medusa/xmlrpc_handler.py b/supervisor/medusa/xmlrpc_handler.py index fecb237a3..f815cdc0a 100644 --- a/supervisor/medusa/xmlrpc_handler.py +++ b/supervisor/medusa/xmlrpc_handler.py @@ -12,7 +12,7 @@ import supervisor.medusa.http_server as http_server try: import xmlrpclib -except: +except Exception: import xmlrpc.client as xmlrpclib import sys @@ -40,14 +40,14 @@ def continue_request (self, data, request): response = self.call (method, params) if type(response) != type(()): response = (response,) - except: + except Exception: # report exception back to server response = xmlrpclib.dumps ( xmlrpclib.Fault (1, "%s:%s" % (sys.exc_info()[0], sys.exc_info()[1])) ) else: response = xmlrpclib.dumps (response, methodresponse=1) - except: + except Exception: # internal error, report as HTTP server error request.error (500) else: diff --git a/supervisor/pidproxy.py b/supervisor/pidproxy.py index 3908cfcbb..87fe2684e 100755 --- a/supervisor/pidproxy.py +++ b/supervisor/pidproxy.py @@ -58,7 +58,7 @@ def passtochild(self, sig, frame): try: with open(self.pidfile, 'r') as f: pid = int(f.read().strip()) - except: + except Exception: print("Can't read child pidfile %s!" % self.pidfile) return os.kill(pid, sig) diff --git a/supervisor/process.py b/supervisor/process.py index b394be812..f77b2fe56 100644 --- a/supervisor/process.py +++ b/supervisor/process.py @@ -341,7 +341,7 @@ def _spawn_as_child(self, filename, argv): code = errno.errorcode.get(why.args[0], why.args[0]) msg = "couldn't exec %s: %s\n" % (argv[0], code) options.write(2, "supervisor: " + msg) - except: + except Exception: (file, fun, line), t,v,tbinfo = asyncore.compact_traceback() error = '%s, %s: file: %s line: %s' % (t, v, file, line) msg = "couldn't exec %s: %s\n" % (filename, error) @@ -474,7 +474,7 @@ def kill(self, sig): # not. we will do it during normal SIGCHLD processing. return None raise - except: + except Exception: tb = traceback.format_exc() msg = 'unknown problem killing %s (%s):%s' % (processname, self.pid, tb) @@ -523,7 +523,7 @@ def signal(self, sig): # not. we will do it during normal SIGCHLD processing. return None raise - except: + except Exception: tb = traceback.format_exc() msg = 'unknown problem sending sig %s (%s):%s' % ( processname, self.pid, tb) diff --git a/supervisor/supervisorctl.py b/supervisor/supervisorctl.py index 5d73e4cca..54b71f492 100755 --- a/supervisor/supervisorctl.py +++ b/supervisor/supervisorctl.py @@ -525,7 +525,7 @@ def do_tail(self, arg): else: try: bytes = int(what) - except: + except Exception: self.ctl.output('Error: bad argument %s' % modifier) self.ctl.exitstatus = LSBInitExitStatuses.GENERIC return @@ -590,7 +590,7 @@ def do_maintail(self, arg): return self._tailf(path) try: what = int(what) - except: + except Exception: self.ctl.output('Error: bad argument %s' % args[0]) self.ctl.exitstatus = LSBInitExitStatuses.GENERIC return diff --git a/supervisor/supervisord.py b/supervisor/supervisord.py index 2a7935ca5..eb9eb6914 100755 --- a/supervisor/supervisord.py +++ b/supervisor/supervisord.py @@ -226,7 +226,7 @@ def runforever(self): self.options.poller.unregister_readable(fd) except asyncore.ExitNow: raise - except: + except Exception: combined_map[fd].handle_error() else: # if the fd is not in combined_map, we should unregister it. otherwise, @@ -234,7 +234,7 @@ def runforever(self): self.options.logger.blather('unexpected read event from fd %r' % fd) try: self.options.poller.unregister_readable(fd) - except: + except Exception: pass for fd in w: @@ -249,13 +249,13 @@ def runforever(self): self.options.poller.unregister_writable(fd) except asyncore.ExitNow: raise - except: + except Exception: combined_map[fd].handle_error() else: self.options.logger.blather('unexpected write event from fd %r' % fd) try: self.options.poller.unregister_writable(fd) - except: + except Exception: pass for group in pgroups: diff --git a/supervisor/tests/test_dispatchers.py b/supervisor/tests/test_dispatchers.py index 92b43bad1..ef71ad412 100644 --- a/supervisor/tests/test_dispatchers.py +++ b/supervisor/tests/test_dispatchers.py @@ -116,7 +116,7 @@ def test_handle_error(self): dispatcher = self._makeOne(process) try: raise ValueError('foo') - except: + except Exception: dispatcher.handle_error() result = options.logger.data[0] self.assertTrue(result.startswith( @@ -680,7 +680,7 @@ def test_handle_error(self): dispatcher = self._makeOne(process) try: raise ValueError('foo') - except: + except Exception: dispatcher.handle_error() result = options.logger.data[0] self.assertTrue(result.startswith( @@ -1119,7 +1119,7 @@ def test_handle_error(self): dispatcher = self._makeOne(process) try: raise ValueError('foo') - except: + except Exception: dispatcher.handle_error() result = options.logger.data[0] self.assertTrue(result.startswith( diff --git a/supervisor/tests/test_process.py b/supervisor/tests/test_process.py index 24643b4dc..76a44cec1 100644 --- a/supervisor/tests/test_process.py +++ b/supervisor/tests/test_process.py @@ -690,7 +690,7 @@ def sighandler(*args): finally: try: os.remove(executable) - except: + except Exception: pass signal.signal(signal.SIGCHLD, signal.SIG_DFL) diff --git a/supervisor/web.py b/supervisor/web.py index 926e8d43f..3651a493c 100644 --- a/supervisor/web.py +++ b/supervisor/web.py @@ -54,7 +54,7 @@ def more(self): self.finished = True return self.sendresponse(response) - except: + except Exception: tb = traceback.format_exc() # this should go to the main supervisor log file self.request.channel.server.logger.log('Web interface error', tb) diff --git a/supervisor/xmlrpc.py b/supervisor/xmlrpc.py index 025ada883..2241900cc 100644 --- a/supervisor/xmlrpc.py +++ b/supervisor/xmlrpc.py @@ -87,7 +87,7 @@ def more(self): return self.getresponse(body) - except: + except Exception: tb = traceback.format_exc() self.request.channel.server.logger.log( "XML-RPC response callback error", tb @@ -247,7 +247,7 @@ def multi(remaining_calls=remaining_calls, except RPCError as exc: value = {'faultCode': exc.code, 'faultString': exc.text} - except: + except Exception: info = sys.exc_info() errmsg = "%s:%s" % (info[0], info[1]) value = {'faultCode': Faults.FAILED, @@ -276,7 +276,7 @@ def multi(remaining_calls=remaining_calls, except RPCError as exc: value = {'faultCode': exc.code, 'faultString': exc.text} - except: + except Exception: info = sys.exc_info() errmsg = "%s:%s" % (info[0], info[1]) value = {'faultCode': Faults.FAILED, @@ -383,7 +383,7 @@ def continue_request(self, data, request): if PY2: data = data.encode('ascii', 'xmlcharrefreplace') params, method = self.loads(data) - except: + except Exception: logger.error( 'XML-RPC request data %r is invalid: unmarshallable' % (data,) @@ -433,7 +433,7 @@ def continue_request(self, data, request): request.push(body) request.done() - except: + except Exception: tb = traceback.format_exc() logger.critical( "Handling XML-RPC request with data %r raised an unexpected "