[open-ils-commits] r887 - constrictor/trunk/contrib/evergreen (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue May 18 17:30:42 EDT 2010
Author: erickson
Date: 2010-05-18 17:30:37 -0400 (Tue, 18 May 2010)
New Revision: 887
Modified:
constrictor/trunk/contrib/evergreen/eg_batch.py
constrictor/trunk/contrib/evergreen/eg_data.py
Log:
only load dynamic test objects when they are not already defined in the properties file; in batch api loader, only load/parse the file once at start (instead of once per thread); removed some unused code
Modified: constrictor/trunk/contrib/evergreen/eg_batch.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_batch.py 2010-05-14 00:08:37 UTC (rev 886)
+++ constrictor/trunk/contrib/evergreen/eg_batch.py 2010-05-18 21:30:37 UTC (rev 887)
@@ -25,42 +25,8 @@
def __init__(self):
Script.__init__(self)
self.calls = []
- self.loaded = False
self.data_mgr = None
- self.bibs = []
- self.copies = []
- self.call_numbers = []
- self.org_unis = []
-
- '''
- def _fetch_dynamic_data(self):
- pcrud = 'open-ils.pcrud'
- method = 'open-ils.pcrud.search.%s.atomic'
-
- auth = eg_utils.authtoken()
- thread_count = props.get_property('constrictor.numThreads')
-
- self.bibs = BatchMethodTask(pcrud, method % 'bre').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.copies = BatchMethodTask(pcrud, method % 'acp').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.call_numbers = BatchMethodTask(pcrud, method % 'acn').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.org_units = BatchMethodTask(pcrud, method % 'aou').start(
- params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.data_mgr.insert_prop_data(eg_data.PROP_TITLE_ID, [obj.id() for obj in self.bibs])
- self.data_mgr.insert_prop_data(eg_data.PROP_COPY_ID, [obj.id() for obj in self.copies])
- self.data_mgr.insert_prop_data(eg_data.PROP_COPY_BARCODE, [obj.barcode() for obj in self.copies])
- self.data_mgr.insert_prop_data(eg_data.PROP_CALLNUMBER_ID, [obj.id() for obj in self.call_numbers])
- self.data_mgr.insert_prop_data(eg_data.PROP_ORG_ID, [obj.id() for obj in self.org_units])
- self.data_mgr.insert_prop_data(eg_data.PROP_ORG_SHORTNAME, [obj.shortname() for obj in self.org_units])
- '''
-
def load_file(self):
batch_file = props.get_property('evergreen.batchAPIFile')
@@ -147,9 +113,6 @@
def run(self):
- if not self.loaded:
- self.load_file()
-
for idx in range(0, len(self.calls)):
call = self.calls[int(random.random() * len(self.calls))]
try:
@@ -164,4 +127,6 @@
-ScriptManager.go(BatchScript())
+script = BatchScript()
+script.load_file() # load the batch API file
+ScriptManager.go(script)
Modified: constrictor/trunk/contrib/evergreen/eg_data.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_data.py 2010-05-14 00:08:37 UTC (rev 886)
+++ constrictor/trunk/contrib/evergreen/eg_data.py 2010-05-18 21:30:37 UTC (rev 887)
@@ -48,26 +48,44 @@
auth = eg_utils.authtoken()
thread_count = self.props.get_property('constrictor.numThreads')
- bibs = DataMethodTask(pcrud, method % 'bre').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ if not self.data.get(PROP_TITLE_ID):
- copies = DataMethodTask(pcrud, method % 'acp').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ bibs = DataMethodTask(pcrud, method % 'bre').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
- call_numbers = DataMethodTask(pcrud, method % 'acn').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs])
- org_units = DataMethodTask(pcrud, method % 'aou').start(
- params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
+ if not self.data.get(PROP_COPY_ID) or not self.data.get(PROP_COPY_BARCODE):
- self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs])
- self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies])
- self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies])
- self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers])
- self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units])
- self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units])
+ copies = DataMethodTask(pcrud, method % 'acp').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ if not self.data.get(PROP_COPY_ID):
+ self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies])
+ if not self.data.get(PROP_COPY_BARCODE):
+ self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies])
+
+ if not self.data.get(PROP_CALLNUMBER_ID):
+
+ call_numbers = DataMethodTask(pcrud, method % 'acn').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+
+ self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers])
+
+ if not self.data.get(PROP_ORG_ID) or not self.data.get(PROP_ORG_SHORTNAME):
+
+ org_units = DataMethodTask(pcrud, method % 'aou').start(
+ params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
+
+ if not self.data.get(PROP_ORG_ID):
+ self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units])
+
+ if not self.data.get(PROP_ORG_SHORTNAME):
+
+ self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units])
+
+
def __str__(self):
s = 'DataManager() read properties:\n'
for p in [
More information about the open-ils-commits
mailing list