[rhmessaging-commits] rhmessaging commits: r1307 - mgmt/cumin/bin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Nov 13 15:52:35 EST 2007


Author: justi9
Date: 2007-11-13 15:52:35 -0500 (Tue, 13 Nov 2007)
New Revision: 1307

Modified:
   mgmt/cumin/bin/cumin-test
Log:
Makes cumin-test set up a database connection.  Makes cumin-test load
params from a config file as well as from its arguments.



Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test	2007-11-13 20:43:12 UTC (rev 1306)
+++ mgmt/cumin/bin/cumin-test	2007-11-13 20:52:35 UTC (rev 1307)
@@ -1,16 +1,17 @@
 #!/usr/bin/env python
 
-import sys
-from time import time
-from wooly.devel import BenchmarkHarness
-from wooly.server import WebServer
+import sys, os
+from ConfigParser import SafeConfigParser
 
-from cumin import *
-from cumin.demo import *
-from cumin.model import *
-
 def load_args(argv):
     args = dict()
+
+    conf = SafeConfigParser()
+    conf.read(os.path.expanduser("~/.cumin.conf"))
+
+    for key, value in conf.items("main"):
+        args[key] = value
+    
     key = None
 
     for arg in sys.argv:
@@ -21,8 +22,32 @@
             args[key] = arg
             key = None
 
+    print "Parameters:"
+    for key in args:
+        print " %10s %s" % (key, args[key])
+
     return args
 
+from sqlobject import *
+
+args = load_args(sys.argv)
+
+try:
+    connuri = args["data"]
+    conn = connectionForURI(connuri)
+    sqlhub.processConnection = conn
+except KeyError:
+    print "No data source; use --data DATABASE-URL"
+    sys.exit(1)
+
+from time import time
+from wooly.devel import BenchmarkHarness
+from wooly.server import WebServer
+
+from cumin import *
+from cumin.demo import *
+from cumin.model import *
+
 def do_main(port, bench_hits, debug=True, demodata=True):
     model = CuminModel()
 
@@ -44,8 +69,6 @@
         server.run()
 
 def main():
-    args = load_args(sys.argv)
-
     in_port = int(args.get("port", 9090))
     in_profile = "profile" in args
     in_debug = "no-debug" not in args




More information about the rhmessaging-commits mailing list