[open-ils-commits] r889 - in constrictor/trunk: . constrictor (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jun 7 15:47:06 EDT 2010
Author: erickson
Date: 2010-06-07 15:47:01 -0400 (Mon, 07 Jun 2010)
New Revision: 889
Modified:
constrictor/trunk/constrictor.py
constrictor/trunk/constrictor/data.py
constrictor/trunk/constrictor/utils.py
Log:
added support for optional task set names; name defaults to start time
Modified: constrictor/trunk/constrictor/data.py
===================================================================
--- constrictor/trunk/constrictor/data.py 2010-06-07 19:13:57 UTC (rev 888)
+++ constrictor/trunk/constrictor/data.py 2010-06-07 19:47:01 UTC (rev 889)
@@ -21,7 +21,7 @@
singleton = None
- def __init__(self, db_file):
+ def __init__(self, db_file, task_set_name = None):
if Data.singleton is None:
log.log_info("sqlite:////%s" % db_file)
self.engine = create_engine('sqlite:////%s' % db_file)
@@ -30,6 +30,7 @@
self.runtime_data = []
self.task_set_id = None
self.insert_data = True
+ self.task_set_name = task_set_name
Data.singleton = self
def disconnect(self):
@@ -59,6 +60,7 @@
Column('id', Integer, primary_key=True),
Column('start_time', Text),
Column('end_time', Text),
+ Column('name', Text),
)
if force:
@@ -70,12 +72,17 @@
def create_task_set(self):
self.task_set_start_time = time.time()
+ if self.task_set_name is None:
+ self.task_set_name = self.task_set_start_time
if self.insert_data:
-
res = self.engine.execute(
- self.task_set_table.insert().values(start_time = self.task_set_start_time)
+ self.task_set_table.insert().values(
+ start_time = self.task_set_start_time,
+ name = self.task_set_name
+ )
)
+
#self.task_set_id = res.inserted_primary_key
self.task_set_id = res.last_inserted_ids()[0]
res.close()
@@ -137,6 +144,7 @@
# log some basic stats
task_set_time = end_time - self.task_set_start_time
log.log_info("-"*70)
+ log.log_info("Task Set -> %s" % str(self.task_set_name))
log.log_info("Task Counts -> %s" % str(task_counts))
log.log_info("Total Tasks -> %d" % len(self.runtime_data))
log.log_info("Total time -> %0.3f seconds" % task_set_time)
Modified: constrictor/trunk/constrictor/utils.py
===================================================================
--- constrictor/trunk/constrictor/utils.py 2010-06-07 19:13:57 UTC (rev 888)
+++ constrictor/trunk/constrictor/utils.py 2010-06-07 19:47:01 UTC (rev 889)
@@ -48,10 +48,11 @@
print "WARNING: Unable to store properties to file\n%s" % str(e)
-def init_db(store_data = True):
+def init_db(task_set_name, store_data = True):
''' connect to the db and make sure the tables exist '''
data = constrictor.data.Data(
- os.path.join(os.getcwd(), props.get_property('constrictor.dbFile'))
+ os.path.join(os.getcwd(), props.get_property('constrictor.dbFile')),
+ task_set_name
)
data.insert_data = store_data
data.create_schema()
Modified: constrictor/trunk/constrictor.py
===================================================================
--- constrictor/trunk/constrictor.py 2010-06-07 19:13:57 UTC (rev 888)
+++ constrictor/trunk/constrictor.py 2010-06-07 19:47:01 UTC (rev 889)
@@ -26,6 +26,7 @@
props_filename = PROPS_FILENAME
drone_controller = None
store_data = True
+task_set_name = None
def usage():
print '''
@@ -45,6 +46,7 @@
-l listen address for incoming controller connections
-x clear the local cache file cache
-n do not store the results in the database
+ -m optional task set name
''' % sys.argv[0]
sys.exit(0)
@@ -54,9 +56,10 @@
global props
global props_filename
global store_data
+ global task_set_name
# see if we have any command-line args that override the properties file
- ops, args = getopt.getopt(sys.argv[1:], 's:t:i:d:p:l:f:hxn')
+ ops, args = getopt.getopt(sys.argv[1:], 's:t:i:d:p:l:f:m:hxn')
options = dict( (k,v) for k,v in ops )
if options.has_key('-f'):
@@ -79,6 +82,8 @@
props.set_property('constrictor.port', options['-p'])
if options.has_key('-l'):
props.set_property('constrictor.listenAddress', options['-l'])
+ if options.has_key('-m'):
+ task_set_name = options['-m']
if options.has_key('-n'):
store_data = False
@@ -135,7 +140,7 @@
log_info('running ' + script)
f = open_script(scriptDirs, script)
if f:
- init_db(store_data)
+ init_db(task_set_name, store_data)
try:
exec(f)
except Exception, e:
@@ -148,7 +153,7 @@
drone_controller.shutdown()
else:
- init_db(store_data)
+ init_db(task_set_name, store_data)
script = props.get_property('constrictor.script') # execute the requested script
ScriptThread.reset_thread_seed()
f = open_script(scriptDirs, script)
More information about the open-ils-commits
mailing list