Browse Source

Added Exception to all try blocks

This should allow us to handle keyboard interrupts better
msmith-techempower 10 years ago
parent
commit
05ac870005

+ 1 - 1
frameworks/Nimrod/nawak/setup.py

@@ -27,7 +27,7 @@ def stop(logfile, errfile):
 
 
   try:
   try:
     subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
     subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except:
+  except Exception:
     ret = 1
     ret = 1
 
 
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)

+ 1 - 1
frameworks/Nimrod/nawak/setup_redis.py

@@ -28,7 +28,7 @@ def stop(logfile, errfile):
 
 
   try:
   try:
     subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
     subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except:
+  except Exception:
     ret = 1
     ret = 1
 
 
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)

+ 1 - 1
frameworks/Scala/play-activate-mysql/setup.py

@@ -26,7 +26,7 @@ def stop(logfile, errfile):
     with open("./play-activate-mysql/target/universal/play-activate-mysql-1.0-SNAPSHOT/RUNNING_PID") as f:
     with open("./play-activate-mysql/target/universal/play-activate-mysql-1.0-SNAPSHOT/RUNNING_PID") as f:
       pid = int(f.read())
       pid = int(f.read())
       os.kill(pid,15)
       os.kill(pid,15)
-  except:
+  except Exception:
     return 1
     return 1
 
 
   try:
   try:

+ 3 - 3
toolset/benchmark/benchmarker.py

@@ -494,7 +494,7 @@ class Benchmarker:
 
 
     try:
     try:
       os.makedirs(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name)))
       os.makedirs(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name)))
-    except:
+    except Exception:
       pass
       pass
     with open(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name), 'out.txt'), 'w') as out, \
     with open(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name), 'out.txt'), 'w') as out, \
          open(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name), 'err.txt'), 'w') as err:
          open(os.path.join(self.latest_results_directory, 'logs', "{name}".format(name=test.name), 'err.txt'), 'w') as err:
@@ -662,7 +662,7 @@ class Benchmarker:
       s.bind(("", port))
       s.bind(("", port))
       # If we get here, we were able to bind successfully,
       # If we get here, we were able to bind successfully,
       # which means the port is free.
       # which means the port is free.
-    except:
+    except Exception:
       # If we get an exception, it might be because the port is still bound
       # If we get an exception, it might be because the port is still bound
       # which would be bad, or maybe it is a privileged port (<1024) and we
       # which would be bad, or maybe it is a privileged port (<1024) and we
       # are not running as root, or maybe the server is gone, but sockets are
       # are not running as root, or maybe the server is gone, but sockets are
@@ -673,7 +673,7 @@ class Benchmarker:
         # If we get here, we were able to connect to something, which means
         # If we get here, we were able to connect to something, which means
         # that the port is still bound.
         # that the port is still bound.
         return True
         return True
-      except:
+      except Exception:
         # An exception means that we couldn't connect, so a server probably
         # An exception means that we couldn't connect, so a server probably
         # isn't still running on the port.
         # isn't still running on the port.
         pass
         pass

+ 1 - 1
toolset/benchmark/utils.py

@@ -43,7 +43,7 @@ def gather_tests(include = [], exclude=[], benchmarker=None):
     for k,v in defaults.iteritems():
     for k,v in defaults.iteritems():
       try:
       try:
         defaults[k] = literal_eval(v)
         defaults[k] = literal_eval(v)
-      except:
+      except Exception:
         pass
         pass
 
 
     # Ensure we only run the __init__ method of Benchmarker
     # Ensure we only run the __init__ method of Benchmarker

+ 1 - 1
toolset/run-ci.py

@@ -444,7 +444,7 @@ if __name__ == "__main__":
     log.warning("Environment key missing, are you running inside Travis-CI?")
     log.warning("Environment key missing, are you running inside Travis-CI?")
     print traceback.format_exc()
     print traceback.format_exc()
     retcode = 1
     retcode = 1
-  except:
+  except Exception:
     log.critical("Unknown error")
     log.critical("Unknown error")
     print traceback.format_exc()
     print traceback.format_exc()
     retcode = 1
     retcode = 1

+ 2 - 2
toolset/run-tests.py

@@ -85,7 +85,7 @@ def main(argv=None):
             for k,v in defaults.iteritems():
             for k,v in defaults.iteritems():
                 try:
                 try:
                     defaults[k] = literal_eval(v)
                     defaults[k] = literal_eval(v)
-                except:
+                except Exception:
                     pass
                     pass
     except IOError:
     except IOError:
         if args.conf_file != 'benchmark.cfg':
         if args.conf_file != 'benchmark.cfg':
@@ -105,7 +105,7 @@ def main(argv=None):
     maxThreads = 8
     maxThreads = 8
     try:
     try:
         maxThreads = multiprocessing.cpu_count()
         maxThreads = multiprocessing.cpu_count()
-    except:
+    except Exception:
         pass
         pass
 
 
     ##########################################################
     ##########################################################

+ 1 - 1
toolset/setup/linux/setup_util.py

@@ -62,7 +62,7 @@ def replace_environ(config=None, root=None, print_result=False, command='true'):
                     os.environ[key]=mini_environ[key]
                     os.environ[key]=mini_environ[key]
                 else:
                 else:
                     os.environ[key]=value    
                     os.environ[key]=value    
-            except:
+            except Exception:
                 if not line: # Don't warn for empty line
                 if not line: # Don't warn for empty line
                     continue 
                     continue 
                 print "WARN: Line '%s' from '%s' is not an environment variable" % (line, config)
                 print "WARN: Line '%s' from '%s' is not an environment variable" % (line, config)