Browse Source

Merge pull request #1174 from TechEmpower/1173

Fixed the bug with parsing files and getting str
Mike Smith 10 years ago
parent
commit
79c60e5bf0

+ 3 - 3
benchmark.cfg.example

@@ -12,9 +12,9 @@ exclude=None
 install=server
 install=server
 install_error_action=continue
 install_error_action=continue
 install_strategy=unified
 install_strategy=unified
-#install_only=True
-#list_test_metadata=True
-#list_tests=True
+install_only=False
+list_test_metadata=False
+list_tests=False
 concurrency_levels=[8, 16, 32, 64, 128, 256]
 concurrency_levels=[8, 16, 32, 64, 128, 256]
 query_levels=[1, 5,10,15,20]
 query_levels=[1, 5,10,15,20]
 threads=8
 threads=8

+ 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:

+ 4 - 4
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
@@ -940,7 +940,7 @@ class Benchmarker:
     
     
 
 
     args['max_threads'] = args['threads']
     args['max_threads'] = args['threads']
-    args['max_concurrency'] = str(max(args['concurrency_levels']))
+    args['max_concurrency'] = max(args['concurrency_levels'])
 
 
     self.__dict__.update(args)
     self.__dict__.update(args)
     # pprint(self.__dict__)
     # pprint(self.__dict__)

+ 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

+ 11 - 4
toolset/run-tests.py

@@ -11,6 +11,7 @@ from pprint import pprint
 from benchmark.benchmarker import Benchmarker
 from benchmark.benchmarker import Benchmarker
 from setup.linux.unbuffered import Unbuffered
 from setup.linux.unbuffered import Unbuffered
 from setup.linux import setup_util
 from setup.linux import setup_util
+from ast import literal_eval
 
 
 # Enable cross-platform colored output
 # Enable cross-platform colored output
 from colorama import init
 from colorama import init
@@ -80,6 +81,12 @@ def main(argv=None):
             config = ConfigParser.SafeConfigParser()
             config = ConfigParser.SafeConfigParser()
             config.read([os.getcwd() + '/' + args.conf_file])
             config.read([os.getcwd() + '/' + args.conf_file])
             defaults = dict(config.items("Defaults"))
             defaults = dict(config.items("Defaults"))
+            # Convert strings into proper python types
+            for k,v in defaults.iteritems():
+                try:
+                    defaults[k] = literal_eval(v)
+                except Exception:
+                    pass
     except IOError:
     except IOError:
         if args.conf_file != 'benchmark.cfg':
         if args.conf_file != 'benchmark.cfg':
             print 'Configuration file not found!'
             print 'Configuration file not found!'
@@ -98,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
 
 
     ##########################################################
     ##########################################################
@@ -185,13 +192,13 @@ def main(argv=None):
     # Run the benchmarker in the specified mode
     # Run the benchmarker in the specified mode
     #   Do not use benchmarker variables for these checks, 
     #   Do not use benchmarker variables for these checks, 
     #   they are either str or bool based on the python version
     #   they are either str or bool based on the python version
-    if (type(args.list_tests) is str and args.list_tests.lower() == 'true') or (type(args.list_tests) is bool and args.list_tests):
+    if args.list_tests:
       benchmarker.run_list_tests()
       benchmarker.run_list_tests()
-    elif (type(args.list_test_metadata) is str and args.list_test_metadata.lower() == 'true') or (type(args.list_test_metadata) is bool and args.list_test_metadata):
+    elif args.list_test_metadata:
       benchmarker.run_list_test_metadata()
       benchmarker.run_list_test_metadata()
     elif args.parse != None:
     elif args.parse != None:
       benchmarker.parse_timestamp()
       benchmarker.parse_timestamp()
-    elif not ((type(args.install_only) is str and args.install_only.lower() == 'true') or (type(args.install_only) is bool and args.install_only)):
+    elif not args.install_only:
       return benchmarker.run()
       return benchmarker.run()
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":

+ 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)