[open-ils-commits] r792 - in constrictor/trunk: . constrictor constrictor_gui constrictor_gui/control contrib/evergreen (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 22 22:43:36 EST 2010
Author: erickson
Date: 2010-02-22 22:43:33 -0500 (Mon, 22 Feb 2010)
New Revision: 792
Modified:
constrictor/trunk/constrictor.py
constrictor/trunk/constrictor/controller.py
constrictor/trunk/constrictor/data.py
constrictor/trunk/constrictor/db.py
constrictor/trunk/constrictor/log.py
constrictor/trunk/constrictor/script.py
constrictor/trunk/constrictor/task.py
constrictor/trunk/constrictor/utils.py
constrictor/trunk/constrictor_gui/control/views.py
constrictor/trunk/constrictor_gui/urls.py
constrictor/trunk/contrib/evergreen/eg_bib_search.py
constrictor/trunk/contrib/evergreen/eg_checkin.py
constrictor/trunk/contrib/evergreen/eg_checkout.py
constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py
constrictor/trunk/contrib/evergreen/eg_data.py
constrictor/trunk/contrib/evergreen/eg_fetch_user_groups.py
constrictor/trunk/contrib/evergreen/eg_renew.py
constrictor/trunk/contrib/evergreen/eg_title_hold.py
constrictor/trunk/contrib/evergreen/eg_user_search.py
constrictor/trunk/contrib/evergreen/eg_user_transactions.py
constrictor/trunk/contrib/evergreen/eg_utils.py
constrictor/trunk/contrib/evergreen/eg_workflow.py
constrictor/trunk/deploy.py
Log:
Make this look more like python. (thanks, Perl one-liners)
Added a clear cache option to clear the local file cache at startup
Modified: constrictor/trunk/constrictor/controller.py
===================================================================
--- constrictor/trunk/constrictor/controller.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/controller.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -71,7 +71,7 @@
def reset(self):
''' Creates a new stream parser and flags this object as not being
connected to the remote node '''
- logInfo("Resetting controller connection")
+ log_info("Resetting controller connection")
self.parser = make_parser()
self.parser.setContentHandler(CommandParser(self))
self.connected = False
@@ -84,7 +84,7 @@
v = re.compile("'").sub('"', str(v)) # change ' to " to prevent xml attr breaking..
s += " %s='%s'" % (saxutils.escape(k), saxutils.escape(v))
s += '/>'
- logDebug('Sending ' + s)
+ log_debug('Sending ' + s)
self.remote.send(s)
@@ -99,7 +99,7 @@
if self.remote is None:
# we're acting as a server process, waiting for a connection
self.remote = self.socket.accept()
- logInfo('Controller connection from %s' % str(self.remote.remoteAddress))
+ log_info('Controller connection from %s' % str(self.remote.remoteAddress))
try:
data = self.remote.recv()
@@ -135,7 +135,7 @@
if self.remote is None:
# we're acting as a server process, waiting for a connection
self.remote, address = self.socket.accept()
- logInfo('Controller connection from %s' % str(address))
+ log_info('Controller connection from %s' % str(address))
try:
data = self.remote.recv(READSIZE)
@@ -145,7 +145,7 @@
self.reset()
continue
- logDebug("Read %s" % data)
+ log_debug("Read %s" % data)
self.parser.feed(data)
self.remote.setblocking(0)
@@ -216,13 +216,13 @@
except socket.error, e:
err = _("Error connecting to %s:%s %s" % (self.address, self.port, str(e)))
self.failed = err
- logError(err)
+ log_error(err)
return False
except socket.timeout:
err = _("Connection to %s:%s timed out" % (self.address, self.port))
self.failed = err
- logError(err)
+ log_error(err)
return False
def __str__(self):
@@ -259,7 +259,7 @@
try:
rlist = select.select(rlist, [], [], timeout)
except Exception, e:
- logError("select() failed with " + str(e))
+ log_error("select() failed with " + str(e))
return []
return [ c for c in self.controllers if c.socket in rlist[0] ]
return []
@@ -340,7 +340,7 @@
return p
def startElement(self, name, attrs):
- logDebug("Received %s %s" % (name, str([(k,v) for k,v in attrs.items()])))
+ log_debug("Received %s %s" % (name, str([(k,v) for k,v in attrs.items()])))
if name == 'controlset':
if not self.controller.connected:
Modified: constrictor/trunk/constrictor/data.py
===================================================================
--- constrictor/trunk/constrictor/data.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/data.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -23,7 +23,7 @@
def __init__(self, db_file):
if Data.singleton is None:
- log.logInfo("sqlite:////%s" % db_file)
+ log.log_info("sqlite:////%s" % db_file)
self.engine = create_engine('sqlite:////%s' % db_file)
self.meta = MetaData()
self.meta.bind = self.engine
@@ -76,7 +76,7 @@
def store_data(self):
- log.logInfo("Inserting data into data store...")
+ log.log_info("Inserting data into data store...")
# close out the task set
self.engine.execute(
@@ -85,6 +85,7 @@
# insert all of the task data
for task in self.runtime_data:
+ log.log_debug("Storing " + task['name'])
self.engine.execute(
self.task_table.insert().values(
task_name = task['name'],
Modified: constrictor/trunk/constrictor/db.py
===================================================================
--- constrictor/trunk/constrictor/db.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/db.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -102,13 +102,13 @@
if summary['num_task_success'] > 0:
summary['amortized_tasks_per_second'] = 1.0 / float(summary['amortized_task_duration'])
- props = Properties.getProperties()
- summary['thread_count'] = props.getProperty('constrictor.numThreads')
- summary['iteration_count'] = props.getProperty('constrictor.numIterations')
+ props = Properties.get_properties()
+ summary['thread_count'] = props.get_property('constrictor.numThreads')
+ summary['iteration_count'] = props.get_property('constrictor.numIterations')
self.makeTaskTypeSummary(summary)
- logInfo('created summary %s' % summary)
+ log_info('created summary %s' % summary)
return summary
def makeTaskTypeSummary(self, summary):
@@ -150,7 +150,7 @@
def execute(self, sql, commit=False):
- logDebug('SQL ' + sql)
+ log_debug('SQL ' + sql)
from script import ScriptThread
cur = None
try:
@@ -160,7 +160,7 @@
if commit:
self.conn.commit()
except Exception, e:
- sys.stderr.write('DB error: thread = %d : %s\n' % (ScriptThread.getThreadID(), str(e)))
+ sys.stderr.write('DB error: thread = %d : %s\n' % (ScriptThread.get_thread_id(), str(e)))
sys.stderr.flush()
dbSema.release()
sys.exit(1)
@@ -177,7 +177,7 @@
task.name,
time.time(),
1, # XXX get me from the task runner ?
- ScriptThread.getThreadID(),
+ ScriptThread.get_thread_id(),
DBConnection.taskSetID,
task.duration,
task.success
Modified: constrictor/trunk/constrictor/log.py
===================================================================
--- constrictor/trunk/constrictor/log.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/log.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -19,20 +19,20 @@
import sys
loglevel = 1
-def initLog():
+def init_log():
global loglevel
- props = Properties.getProperties()
- loglevel = int(props.getProperty('constrictor.loglevel') or 0)
+ props = Properties.get_properties()
+ loglevel = int(props.get_property('constrictor.loglevel') or 0)
-def logError(msg=''):
+def log_error(msg=''):
if loglevel < 1: return
sys.stderr.write('Error*: %s\n' % msg)
sys.stderr.flush()
-def logInfo(msg=''):
+def log_info(msg=''):
if loglevel < 2: return
print 'Info: %s' % msg
-def logDebug(msg=''):
+def log_debug(msg=''):
if loglevel < 3: return
print 'Debug: %s' % msg
Modified: constrictor/trunk/constrictor/script.py
===================================================================
--- constrictor/trunk/constrictor/script.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/script.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -26,11 +26,11 @@
def __init__(self, name=''):
self.name = name
def run(self):
- logError('Override Script.run() to run a script!')
+ log_error('Override Script.run() to run a script!')
sys.exit(1)
- def onThreadInit(self, scriptThread):
+ def on_thread_init(self, scriptThread):
pass
- def onThreadComplete(self, scriptThread):
+ def on_thread_complete(self, scriptThread):
pass
@@ -41,49 +41,49 @@
# this is used to determine the thread ID of newly created threads
threadSeed = 0
- def __init__(self, script, numItr, onComplete=None ):
+ def __init__(self, script, numItr, on_complete=None ):
Thread.__init__(self)
- logDebug("Creating thread with ID %d" % ScriptThread.threadSeed)
+ log_debug("Creating thread with ID %d" % ScriptThread.threadSeed)
self.script = script # our script object
self.numItr = numItr # number of times to run our script
self.setName(ScriptThread.threadSeed) # use the Thread name as our threadID
- self.onComplete = onComplete
+ self.on_complete = on_complete
ScriptThread.threadSeed += 1
self.userData = None
- def resetThreadSeed():
+ def reset_thread_seed():
ScriptThread.threadSeed = 0
- resetThreadSeed = staticmethod(resetThreadSeed)
+ reset_thread_seed = staticmethod(reset_thread_seed)
def run(self):
""" Run our script object up to numItr times."""
- self.initThread()
- tid = ScriptThread.getThreadID()
- self.script.onThreadInit(self)
+ self.init_thread()
+ tid = ScriptThread.get_thread_id()
+ self.script.on_thread_init(self)
for i in range(0, self.numItr):
- logInfo('running thread %d, iteration %d' % (tid, i))
+ log_info('running thread %d, iteration %d' % (tid, i))
try:
self.script.run()
except Exception, e:
traceback.print_exc()
- logError("Script exception: %s" % str(e))
+ log_error("Script exception: %s" % str(e))
break
- self.script.onThreadComplete(self)
+ self.script.on_thread_complete(self)
- if self.onComplete:
- self.onComplete(self)
+ if self.on_complete:
+ self.on_complete(self)
- def initThread(self):
+ def init_thread(self):
""" Perform any thread-specific house keeping."""
- data = ScriptThread.__threadData()
+ data = ScriptThread.__thread_data()
data.scriptThread = self
- props = Properties.getProperties()
+ props = Properties.get_properties()
- def getThreadID():
+ def get_thread_id():
""" Returns the ID of the current thread.
Returns -1 if this is the main thread
"""
@@ -93,21 +93,21 @@
except:
pass
return i
- getThreadID = staticmethod(getThreadID)
+ get_thread_id = staticmethod(get_thread_id)
- def currentScriptThread():
- data = ScriptThread.__threadData()
+ def current_script_thread():
+ data = ScriptThread.__thread_data()
return data.scriptThread
- currentScriptThread = staticmethod(currentScriptThread)
+ current_script_thread = staticmethod(current_script_thread)
- threadDataStore = None
- def __threadData():
- if ScriptThread.threadDataStore is None:
- ScriptThread.threadDataStore = threading.local()
- return ScriptThread.threadDataStore
- __threadData = staticmethod(__threadData)
+ thread_dataStore = None
+ def __thread_data():
+ if ScriptThread.thread_dataStore is None:
+ ScriptThread.thread_dataStore = threading.local()
+ return ScriptThread.thread_dataStore
+ __thread_data = staticmethod(__thread_data)
class ScriptManager(object):
@@ -126,43 +126,43 @@
self.numComplete = 0
if self.script is None:
- logError('Please register a script to run')
+ log_error('Please register a script to run')
sys.exit(1)
- def setOnThreadsComplete(func):
+ def set_on_threads_complete(func):
ScriptManager.onThreadsComplete = staticmethod(func)
- setOnThreadsComplete = staticmethod(setOnThreadsComplete)
+ set_on_threads_complete = staticmethod(set_on_threads_complete)
- def runScriptThreads(self):
+ def run_script_threads(self):
- def onComplete(scriptThread):
+ def on_complete(scriptThread):
self.numComplete += 1
if self.numComplete == self.numThreads:
# all threads have completed
constrictor.data.Data.get_instance().store_data()
- logInfo('all threads done.. finishing task set')
+ log_info('all threads done.. finishing task set')
if ScriptManager.onThreadsComplete:
ScriptManager.onThreadsComplete(ScriptManager)
""" Launches the script threads. """
for i in range(0, self.numThreads):
- tt = ScriptThread(self.script, self.numItr, onComplete)
+ tt = ScriptThread(self.script, self.numItr, on_complete)
tt.start()
def go(script):
""" The main script passes control to the ScriptManager via this function.
Here, we parse the config and launch the script threads
"""
- props = Properties.getProperties()
+ props = Properties.get_properties()
- threads = int(props.getProperty('constrictor.numThreads'))
- itrs = int(props.getProperty('constrictor.numIterations'))
+ threads = int(props.get_property('constrictor.numThreads'))
+ itrs = int(props.get_property('constrictor.numIterations'))
- logDebug('launching %d threads with %d iterations' % (threads, itrs))
+ log_debug('launching %d threads with %d iterations' % (threads, itrs))
manager = ScriptManager(script, threads, itrs)
- manager.runScriptThreads()
+ manager.run_script_threads()
go = staticmethod(go)
Modified: constrictor/trunk/constrictor/task.py
===================================================================
--- constrictor/trunk/constrictor/task.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/task.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -41,7 +41,7 @@
def run(self, **kwargs):
"""Override this method with the work to perform"""
- logError('Override me!')
+ log_error('Override me!')
def start(self, **kwargs):
@@ -59,8 +59,8 @@
sys.stderr.write(str(E))
# store the error info somewhere?
- logDebug('%s: thread = %d : duration = %f' % (
- self.name, ScriptThread.getThreadID(), self.duration))
+ log_debug('%s: thread = %d : duration = %f' % (
+ self.name, ScriptThread.get_thread_id(), self.duration))
sys.stdout.flush()
constrictor.data.Data.get_instance().add_task(self)
@@ -72,7 +72,7 @@
'duration' : self.duration,
'success' : self.success,
'run_time' : self.run_time,
- 'thread_id' : ScriptThread.getThreadID()
+ 'thread_id' : ScriptThread.get_thread_id()
}
Modified: constrictor/trunk/constrictor/utils.py
===================================================================
--- constrictor/trunk/constrictor/utils.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor/utils.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -25,12 +25,12 @@
props = Properties()
-def loadProps(file=PROPS_FILENAME):
+def load_props(file=PROPS_FILENAME):
try:
# parse the properties file
p = open(file)
- Properties.setGlobalProperties(props)
+ Properties.set_global_properties(props)
props.load(p)
p.close()
except IOError:
@@ -39,7 +39,7 @@
Using command line options only.
'''
-def saveProps():
+def save_props():
try:
p = open(PROPS_FILENAME, 'w')
props.store(p)
@@ -48,23 +48,23 @@
print "WARNING: Unable to store properties to file\n%s" % str(e)
-def initDB():
+def init_db():
''' connect to the db and make sure the tables exist '''
data = constrictor.data.Data(
- os.path.join(os.getcwd(), props.getProperty('constrictor.dbFile'))
+ os.path.join(os.getcwd(), props.get_property('constrictor.dbFile'))
)
data.create_schema()
data.create_task_set()
data.disconnect()
-def initDirs():
- cachedir = props.getProperty('constrictor.cacheDir')
+def init_dirs():
+ cachedir = props.get_property('constrictor.cacheDir')
if not os.path.exists(cachedir):
- os.mkdir(props.getProperty('constrictor.cacheDir'))
+ os.mkdir(props.get_property('constrictor.cacheDir'))
pathsAdded = []
-def openScript(dirs, script):
+def open_script(dirs, script):
''' Finds the script file in the set of script diretories,
opens the file and returns the file object '''
f = None
@@ -81,7 +81,7 @@
return f
except IOError:
pass
- logError("Unable to find script %s in path %s" % (script, str(dirs)))
+ log_error("Unable to find script %s in path %s" % (script, str(dirs)))
return None
Modified: constrictor/trunk/constrictor.py
===================================================================
--- constrictor/trunk/constrictor.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -14,12 +14,12 @@
# GNU General Public License for more details.
# -----------------------------------------------------------------------
-import sys, getopt, os, errno
+import sys, getopt, os, errno, shutil
from constrictor.properties import Properties
from constrictor.controller import DroneController
from constrictor.script import ScriptThread, ScriptManager
from constrictor.log import *
-from constrictor.utils import loadProps, saveProps, initDirs, initDB, openScript, PROPS_FILENAME
+from constrictor.utils import load_props, save_props, init_dirs, init_db, open_script, PROPS_FILENAME
import constrictor.data
props = None
@@ -42,6 +42,8 @@
-d database file (property constrictor.dbFile)
-p port to listen for controller connections on
-l listen address for incoming controller connections
+ -x clear the local cache file cache
+
''' % sys.argv[0]
sys.exit(0)
@@ -51,55 +53,60 @@
global props_filename
# 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:h')
+ ops, args = getopt.getopt(sys.argv[1:], 's:t:i:d:p:l:f:hx')
options = dict( (k,v) for k,v in ops )
if options.has_key('-f'):
props_filename = options['-f']
- loadProps(props_filename)
- props = Properties.getProperties()
+ load_props(props_filename)
+ props = Properties.get_properties()
if options.has_key('-h'):
usage()
if options.has_key('-s'):
- props.setProperty('constrictor.script', options['-s'])
+ props.set_property('constrictor.script', options['-s'])
if options.has_key('-t'):
- props.setProperty('constrictor.numThreads', options['-t'])
+ props.set_property('constrictor.numThreads', options['-t'])
if options.has_key('-i'):
- props.setProperty('constrictor.numIterations', options['-i'])
+ props.set_property('constrictor.numIterations', options['-i'])
if options.has_key('-d'):
- props.setProperty('constrictor.dbFile', options['-d'])
+ props.set_property('constrictor.dbFile', options['-d'])
if options.has_key('-p'):
- props.setProperty('constrictor.port', options['-p'])
+ props.set_property('constrictor.port', options['-p'])
if options.has_key('-l'):
- props.setProperty('constrictor.listenAddress', options['-l'])
+ props.set_property('constrictor.listenAddress', options['-l'])
+ if options.has_key('-x'):
+ # delete the cache directory
+ cacheDir = props.get_property('constrictor.cacheDir')
+ shutil.rmtree(os.path.join(os.getcwd(), cacheDir))
+
def onThreadsComplete(scriptManager):
global droneController
- #summary = ScriptThread.currentScriptThread().dbConnection.createTaskSummary()
+ #summary = ScriptThread.current_script_thread().dbConnection.createTaskSummary()
#droneController.sendResult(type='task_summary', **summary)
read_args_and_props()
-initDirs()
-initLog()
-scriptDirs = props.getProperty('constrictor.scriptDirs').split(',')
+init_dirs()
+init_log()
+scriptDirs = props.get_property('constrictor.scriptDirs').split(',')
-if props.getProperty('constrictor.listen') == 'true':
+if props.get_property('constrictor.listen') == 'true':
''' This is the main controller listen loop. Here, we
accept commands from the controller module, perform
the action, then go back to listening '''
droneController = DroneController(
- props.getProperty('constrictor.address'),
- int(props.getProperty('constrictor.port')))
+ props.get_property('constrictor.address'),
+ int(props.get_property('constrictor.port')))
- ScriptManager.setOnThreadsComplete(onThreadsComplete)
+ ScriptManager.set_on_threads_complete(onThreadsComplete)
while True:
try:
@@ -108,26 +115,26 @@
if command['action'] == 'setprop':
prop = str(command['prop'])
val = str(command['val'])
- logInfo('setting property %s %s' % (prop, val))
- props.setProperty(prop, val)
+ log_info('setting property %s %s' % (prop, val))
+ props.set_property(prop, val)
continue
if command['action'] == 'saveprops':
- logInfo("saving properties back to file")
- saveProps()
+ log_info("saving properties back to file")
+ save_props()
continue
if command['action'] == 'run':
- ScriptThread.resetThreadSeed()
- script = props.getProperty('constrictor.script')
- logInfo('running ' + script)
- f = openScript(scriptDirs, script)
+ ScriptThread.reset_thread_seed()
+ script = props.get_property('constrictor.script')
+ log_info('running ' + script)
+ f = open_script(scriptDirs, script)
if f:
- initDB()
+ init_db()
try:
exec(f)
except Exception, e:
- logError("script execution failed: %s" % str(e))
+ log_error("script execution failed: %s" % str(e))
droneController.sendError(text=str(e))
f.close()
continue
@@ -136,10 +143,10 @@
droneController.shutdown()
else:
- initDB()
- script = props.getProperty('constrictor.script') # execute the requested script
- ScriptThread.resetThreadSeed()
- f = openScript(scriptDirs, script)
+ init_db()
+ script = props.get_property('constrictor.script') # execute the requested script
+ ScriptThread.reset_thread_seed()
+ f = open_script(scriptDirs, script)
if f:
exec(f)
f.close()
Modified: constrictor/trunk/constrictor_gui/control/views.py
===================================================================
--- constrictor/trunk/constrictor_gui/control/views.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor_gui/control/views.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -181,12 +181,12 @@
return render_to_response(SET_PROP_TEMPLATE, makeContext('Set Properties'))
setProps = staff_member_required(never_cache(setProps))
-def saveProps(request):
+def save_props(request):
__init()
controllerSet.broadcastCommand(action='saveprops')
return render_to_response(SET_PROP_TEMPLATE, makeContext('Set Properties'))
-saveProps = staff_member_required(never_cache(saveProps))
+save_props = staff_member_required(never_cache(save_props))
Modified: constrictor/trunk/constrictor_gui/urls.py
===================================================================
--- constrictor/trunk/constrictor_gui/urls.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/constrictor_gui/urls.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -12,6 +12,6 @@
# (r'^control/setScript/$', 'constrictor_gui.control.views.setScript'),
(r'^control/updateBasicProps/$', 'constrictor_gui.control.views.updateBasicProps'),
(r'^control/setProps/$', 'constrictor_gui.control.views.setProps'),
- (r'^control/saveProps/$', 'constrictor_gui.control.views.saveProps'),
+ (r'^control/save_props/$', 'constrictor_gui.control.views.save_props'),
(r'^admin/', include('django.contrib.admin.urls')),
)
Modified: constrictor/trunk/contrib/evergreen/eg_bib_search.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_bib_search.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_bib_search.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -18,14 +18,14 @@
}
search_term = eg_utils.random_phrase(None, 3) # search phrase has 1-3 words
- logInfo('Search term="%s" args="%s"' % (search_term, str(search_args)))
+ log_info('Search term="%s" args="%s"' % (search_term, str(search_args)))
res = eg_tasks.BibSearchTask().start(
search_args = search_args,
search_term = search_term
)
- logInfo('Search returned %d hits' % int(res['count']))
+ log_info('Search returned %d hits' % int(res['count']))
return True
eg_utils.init()
Modified: constrictor/trunk/contrib/evergreen/eg_checkin.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_checkin.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_checkin.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -7,8 +7,8 @@
class CheckinScript(Script):
- def onThreadInit(self, scriptThread):
- eg_utils.initThread()
+ def on_thread_init(self, scriptThread):
+ eg_utils.init_thread()
def run(self):
Modified: constrictor/trunk/contrib/evergreen/eg_checkout.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_checkout.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_checkout.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -10,8 +10,8 @@
class CheckoutScript(Script):
- def onThreadInit(self, scriptThread):
- eg_utils.initThread()
+ def on_thread_init(self, scriptThread):
+ eg_utils.init_thread()
def run(self):
Modified: constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -10,8 +10,8 @@
class CheckoutRoundtripScript(Script):
- def onThreadInit(self, scriptThread):
- eg_utils.initThread()
+ def on_thread_init(self, scriptThread):
+ eg_utils.init_thread()
def run(self):
Modified: constrictor/trunk/contrib/evergreen/eg_data.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_data.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_data.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -22,9 +22,9 @@
def __init__(self):
self.data = {}
- self.props = Properties.getProperties()
+ self.props = Properties.get_properties()
self.readProps()
- logDebug(self)
+ log_debug(self)
def __str__(self):
s = 'DataManager() read properties:\n'
@@ -52,11 +52,11 @@
self.readProp(PROP_ORG_IDS, True)
def readProp(self, prop, split=False):
- v = self.props.getProperty(prop)
+ v = self.props.get_property(prop)
if split and v:
v = unique(v.split(','))
self.data[prop] = v
- logDebug("DataManager set property %s => %s" % (prop, str(v)))
+ log_debug("DataManager set property %s => %s" % (prop, str(v)))
def getThreadData(self, prop, noSharing=False):
''' If the caller is requesting array-based data, we want to de-multiplex(?)
@@ -72,8 +72,8 @@
if not isinstance(data, list):
return data
- currentThread = ScriptThread.getThreadID()
- totalThreads = self.props.getProperty(PROP_CONSTRICTOR_THREADS)
+ currentThread = ScriptThread.get_thread_id()
+ totalThreads = self.props.get_property(PROP_CONSTRICTOR_THREADS)
if len(data) > currentThread:
return data[currentThread]
Modified: constrictor/trunk/contrib/evergreen/eg_fetch_user_groups.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_fetch_user_groups.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_fetch_user_groups.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -18,7 +18,7 @@
class FetchUserGroupsScript(Script):
def run(self):
res = FetchUserGroupsTask().start()
- logInfo('Fetched group tree with root "%s"' % res.name())
+ log_info('Fetched group tree with root "%s"' % res.name())
return True
eg_utils.init()
Modified: constrictor/trunk/contrib/evergreen/eg_renew.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_renew.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_renew.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -10,8 +10,8 @@
class RenewScript(Script):
- def onThreadInit(self, scriptThread):
- eg_utils.initThread()
+ def on_thread_init(self, scriptThread):
+ eg_utils.init_thread()
def run(self):
Modified: constrictor/trunk/contrib/evergreen/eg_title_hold.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_title_hold.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_title_hold.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -8,10 +8,10 @@
class CreateTitleHoldScript(Script):
- def onThreadInit(self, scriptThread):
+ def on_thread_init(self, scriptThread):
# collect all of the holds the current thread user already has
# so any new holds can be cancelled after the thread is complete
- eg_utils.initThread()
+ eg_utils.init_thread()
dm = DataManager()
patronID = dm.getThreadData(PROP_PATRON_IDS)
Modified: constrictor/trunk/contrib/evergreen/eg_user_search.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_user_search.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_user_search.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -17,12 +17,12 @@
'first_given_name' : {'value' : eg_utils.random_phrase(1), 'group' : 0}
}
- logInfo('Search for patron %s' % str(search_args))
+ log_info('Search for patron %s' % str(search_args))
try:
res = eg_tasks.UserSearchTask().start(search_args = search_args)
- logInfo('Search returned %d hits' % len(res))
+ log_info('Search returned %d hits' % len(res))
except Exception, e:
logErrror(e)
Modified: constrictor/trunk/contrib/evergreen/eg_user_transactions.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_user_transactions.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_user_transactions.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -28,7 +28,7 @@
user_id = dm.getThreadData(eg_data.PROP_PATRON_IDS)
for type in types:
- logInfo('Loading patron(%s) transactions with %s' % (int(user_id), type))
+ log_info('Loading patron(%s) transactions with %s' % (int(user_id), type))
res = eg_tasks.UserTransactionsByType().start(
method = type,
user_id = user_id
Modified: constrictor/trunk/contrib/evergreen/eg_utils.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_utils.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_utils.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -9,7 +9,7 @@
from oils.const import *
import os, errno, random
-props = Properties.getProperties()
+props = Properties.get_properties()
words = []
default_dictionary = '/usr/share/dict/words'
@@ -19,33 +19,33 @@
loadIDL()
initOsrf()
- if props.getProperty('evergreen.autologin') == 'true':
+ if props.get_property('evergreen.autologin') == 'true':
login(
- props.getProperty('evergreen.username'),
- props.getProperty('evergreen.password'),
- props.getProperty('evergreen.workstation'))
+ props.get_property('evergreen.username'),
+ props.get_property('evergreen.password'),
+ props.get_property('evergreen.workstation'))
user = None
- if not props.getProperty('evergreen.patronIDs'):
+ if not props.get_property('evergreen.patronIDs'):
# if there are not configured patron IDs, go ahead
# and use the ID of the logged in user
user = fetchSessionUser()
- logInfo("Setting evergreen.patronIDs to logged in user %s" % str(user.id()))
- props.setProperty('evergreen.patronIDs', str(user.id()))
+ log_info("Setting evergreen.patronIDs to logged in user %s" % str(user.id()))
+ props.set_property('evergreen.patronIDs', str(user.id()))
- if not props.getProperty('evergreen.orgIDs'):
+ if not props.get_property('evergreen.orgIDs'):
# simlilarly, if no org is provided, use the home org of the logged in user
if not user:
user = fetchSessionUser()
- logInfo("Setting evergreen.orgIDs to logged in user's home_ou %s" % str(user.home_ou()))
- props.setProperty('evergreen.orgIDs', str(user.home_ou()))
+ log_info("Setting evergreen.orgIDs to logged in user's home_ou %s" % str(user.home_ou()))
+ props.set_property('evergreen.orgIDs', str(user.home_ou()))
- dict_file = props.getProperty('evergreen.dictionary') or default_dictionary
+ dict_file = props.get_property('evergreen.dictionary') or default_dictionary
try:
words_file = open(dict_file)
except Exception:
- logError("Unable to open dictionary file '%s'" % dict_file)
+ log_error("Unable to open dictionary file '%s'" % dict_file)
return
words = words_file.readlines()
@@ -54,16 +54,16 @@
def initOsrf():
# if necessary, create a connection to the opensrf network for this thread
- if str(props.getProperty('evergreen.netProtocol')).lower() == 'jabber':
- if props.getProperty('evergreen.osrfConfig'):
- logInfo("Connecting to the opensrf network")
+ if str(props.get_property('evergreen.netProtocol')).lower() == 'jabber':
+ if props.get_property('evergreen.osrfConfig'):
+ log_info("Connecting to the opensrf network")
from osrf.system import osrfConnect
osrfConnect(
- props.getProperty('evergreen.osrfConfig'),
- props.getProperty('evergreen.osrfConfigContext'))
+ props.get_property('evergreen.osrfConfig'),
+ props.get_property('evergreen.osrfConfigContext'))
-def initThread():
+def init_thread():
''' Performs thread-specific initialization '''
initOsrf()
@@ -71,15 +71,15 @@
user = request('open-ils.auth', 'open-ils.auth.session.retrieve', authtoken()).send()
if Event.parse_event(user):
raise ILSEventException(osrf.json.to_json(user))
- logInfo("fetched user %s" % user.usrname())
+ log_info("fetched user %s" % user.usrname())
return user
def loadIDL():
# XX add logic to allow IDL fetching via jabber
- server = props.getProperty('evergreen.server')
- cacheDir = props.getProperty('constrictor.cacheDir')
+ server = props.get_property('evergreen.server')
+ cacheDir = props.get_property('constrictor.cacheDir')
GatewayRequest.setDefaultHost(server)
import urllib2
@@ -92,8 +92,8 @@
file = open(filePath, 'r')
except IOError:
- logInfo('fetching: http://%s/%s' % (server, props.getProperty('evergreen.IDLPath')))
- f = urllib2.urlopen('http://%s/%s' % (server, props.getProperty('evergreen.IDLPath')))
+ log_info('fetching: http://%s/%s' % (server, props.get_property('evergreen.IDLPath')))
+ f = urllib2.urlopen('http://%s/%s' % (server, props.get_property('evergreen.IDLPath')))
if not os.path.exists('%s/evergreen' % cacheDir):
os.mkdir('%s/evergreen' % cacheDir)
@@ -102,7 +102,7 @@
file.write(f.read())
file.close()
- logInfo("parsing Evergreen IDL file...")
+ log_info("parsing Evergreen IDL file...")
parser.set_IDL(filePath)
parser.parse_IDL()
@@ -124,7 +124,7 @@
def request(service, method, *args):
global props
- proto = props.getProperty('evergreen.netProtocol')
+ proto = props.get_property('evergreen.netProtocol')
if str(proto).lower() == 'jabber':
req = AtomicReqWrapper(service, method, *args)
else:
@@ -132,7 +132,7 @@
req = JSONGatewayRequest(service, method, *args)
else:
req = XMLGatewayRequest(service, method, *args)
- req.setPath(props.getProperty('evergreen.gatewayPath'))
+ req.setPath(props.get_property('evergreen.gatewayPath'))
return req
@@ -146,7 +146,7 @@
''' Login to the server and get back an authtoken'''
global __authtoken
- logInfo("attempting login with user " + username)
+ log_info("attempting login with user " + username)
seed = request(
'open-ils.auth',
Modified: constrictor/trunk/contrib/evergreen/eg_workflow.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_workflow.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/contrib/evergreen/eg_workflow.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -14,7 +14,7 @@
evt = eg_tasks.CheckoutTask().start(
copy_barcode=copyBarcode, patron_id=patronID)
evt_txt = Event.parse_event(evt).text_code
- logInfo("Checkout(%s,%s) -> %s" % (copyBarcode, patronID, evt_txt))
+ log_info("Checkout(%s,%s) -> %s" % (copyBarcode, patronID, evt_txt))
if evt_txt == OILS_EVENT_SUCCESS:
return evt
@@ -25,7 +25,7 @@
evt = doCheckin(copyBarcode)
if evt_txt == OILS_EVENT_SUCCESS:
return doCheckout(copyBarcode, patronID, True)
- logInfo("* Unable to checkin open circ: %s" % copyBarcode)
+ log_info("* Unable to checkin open circ: %s" % copyBarcode)
return None
@@ -34,7 +34,7 @@
evt = eg_tasks.RenewTask().start(copy_barcode=copyBarcode)
evt_txt = Event.parse_event(evt).text_code
- logInfo("Renew(%s) -> %s" % (copyBarcode, evt_txt))
+ log_info("Renew(%s) -> %s" % (copyBarcode, evt_txt))
if evt_txt == OILS_EVENT_SUCCESS:
return evt
@@ -47,18 +47,18 @@
evt = eg_tasks.CheckinTask().start(copy_barcode=copyBarcode)
evt_txt = Event.parse_event(evt).text_code
- logInfo("Checkin(%s) -> %s" % (copyBarcode, evt_txt))
+ log_info("Checkin(%s) -> %s" % (copyBarcode, evt_txt))
if evt_txt == OILS_EVENT_SUCCESS or evt_txt == 'NO_CHANGE':
return SUCCESS
if evt_txt == 'ROUTE_ITEM':
- logInfo("Cancelling post-checkin transit...")
+ log_info("Cancelling post-checkin transit...")
res = eg_tasks.AbortTransitTask().start(copy_barcode=copyBarcode)
if Event.parse_event(res): # transit returns "1" on success
- logError("Unable to abort transit for %s : %s" % (copyBarcode, osrf.json.to_json(evt)))
+ log_error("Unable to abort transit for %s : %s" % (copyBarcode, osrf.json.to_json(evt)))
return None
return SUCCESS
@@ -78,11 +78,11 @@
titleID, patronID, pickupLib, osrf.json.to_json(evt)))
if str(evt['success']) != '1':
- logInfo("TitleHoldPermit(%s, %s, %s) not allowed -> %s" % (
+ log_info("TitleHoldPermit(%s, %s, %s) not allowed -> %s" % (
titleID, patronID, pickupLib, evt))
return None
- logInfo('TitleHoldPermit(%s, %s, %s) -> SUCCESS' % (titleID, patronID, pickupLib))
+ log_info('TitleHoldPermit(%s, %s, %s) -> SUCCESS' % (titleID, patronID, pickupLib))
return True
@@ -93,25 +93,25 @@
evt = et_tasks.TitleHoldTask().start(title_id=titleID, patron_id=patronID, pickup_lib=pickupLib)
- logInfo("title task returned %s" % str(evt))
+ log_info("title task returned %s" % str(evt))
if isinstance(evt, list):
evts = []
for e in evt:
evts.append(e['text_code'])
- logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, str(evts)))
+ log_info("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, str(evts)))
return None
if Event.parse_event(evt):
- logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, Event.parse_event(evt).code))
+ log_info("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, Event.parse_event(evt).code))
return None
if str(evt) == '-1':
- logInfo("TitleHold(%s, %s, %s) placement failed: %s" % (
+ log_info("TitleHold(%s, %s, %s) placement failed: %s" % (
titleID, patronID, pickupLib, str(evt)))
return None
- logInfo('TitleHold(%s, %s, %s) -> SUCCESS' % (titleID, patronID, pickupLib))
+ log_info('TitleHold(%s, %s, %s) -> SUCCESS' % (titleID, patronID, pickupLib))
return int(evt) # new hold ID
def doTitleHoldCancel(holdID):
@@ -125,7 +125,7 @@
raise ILSEventException(
"TitleHoldCancel(%s) failed -> %s" % (holdID, str(evt)))
- logInfo('TitleHoldCancel(%s) -> SUCCESS' % holdID)
+ log_info('TitleHoldCancel(%s) -> SUCCESS' % holdID)
return True
def doTitleHoldFetchAll(patronID):
Modified: constrictor/trunk/deploy.py
===================================================================
--- constrictor/trunk/deploy.py 2010-02-22 21:57:41 UTC (rev 791)
+++ constrictor/trunk/deploy.py 2010-02-23 03:43:33 UTC (rev 792)
@@ -21,7 +21,7 @@
from django.contrib.auth.models import User
from constrictor_gui.control.models import Drone, Script, Plugin, Property
-from constrictor.utils import loadProps
+from constrictor.utils import load_props
import constrictor_gui.settings as settings
from constrictor.log import *
import xml.dom.minidom
@@ -73,8 +73,8 @@
def loadModuleConfigs():
''' Returns the DOM nodes for the XML configs if a config is found '''
- props = constrictor.properties.Properties.getProperties()
- scriptDirs = props.getProperty('constrictor.scriptDirs').split(',')
+ props = constrictor.properties.Properties.get_properties()
+ scriptDirs = props.get_property('constrictor.scriptDirs').split(',')
configs = []
for d in scriptDirs:
conf = None
@@ -149,7 +149,7 @@
-loadProps('consctrictor.properties')
+load_props('consctrictor.properties')
basedir = os.getcwd()
os.chdir('constrictor_gui')
os.environ['PYTHONPATH'] = os.path.join(os.path.abspath(''), '..')
More information about the open-ils-commits
mailing list