[open-ils-commits] r615 - in constrictor/trunk: . contrib/evergreen (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 13 13:12:47 EDT 2009
Author: erickson
Date: 2009-08-13 13:12:43 -0400 (Thu, 13 Aug 2009)
New Revision: 615
Modified:
constrictor/trunk/constrictor.py
constrictor/trunk/contrib/evergreen/eg_tasks.py
constrictor/trunk/contrib/evergreen/eg_title_hold.py
constrictor/trunk/contrib/evergreen/eg_workflow.py
Log:
used new hold id returned from place hold method to subsequently cancel placed hold. props_filename is a global var, fixed
Modified: constrictor/trunk/constrictor.py
===================================================================
--- constrictor/trunk/constrictor.py 2009-08-10 21:40:35 UTC (rev 614)
+++ constrictor/trunk/constrictor.py 2009-08-13 17:12:43 UTC (rev 615)
@@ -55,6 +55,7 @@
def read_args_and_props():
global props
+ 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')
Modified: constrictor/trunk/contrib/evergreen/eg_tasks.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_tasks.py 2009-08-10 21:40:35 UTC (rev 614)
+++ constrictor/trunk/contrib/evergreen/eg_tasks.py 2009-08-13 17:12:43 UTC (rev 615)
@@ -2,7 +2,7 @@
from constrictor.log import *
import eg_utils
from oils.const import *
-from osrf.net_obj import *
+import osrf.net_obj
TASKS = {}
@@ -115,7 +115,7 @@
kw[pickup_lib]
'''
# construct the hold object
- hold = osrfNetworkObject.ahr()
+ hold = osrf.net_obj.NetworkObject.ahr()
hold.pickup_lib(kw['pickup_lib'])
hold.usr(kw['patron_id'])
hold.target(kw['title_id'])
Modified: constrictor/trunk/contrib/evergreen/eg_title_hold.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_title_hold.py 2009-08-10 21:40:35 UTC (rev 614)
+++ constrictor/trunk/contrib/evergreen/eg_title_hold.py 2009-08-13 17:12:43 UTC (rev 615)
@@ -14,8 +14,6 @@
eg_utils.initThread()
dm = DataManager()
patronID = dm.getThreadData(PROP_PATRON_IDS)
- scriptThread.userData = doTitleHoldFetchAll(patronID)
- logDebug("init: grabbed existing holds %s" % str([ int(i) for i in scriptThread.userData]))
def run(self):
@@ -25,23 +23,11 @@
pickupLib = dm.getThreadData(PROP_ORG_IDS)
patronID = dm.getThreadData(PROP_PATRON_IDS)
- doTitleHold(titleID, patronID, pickupLib)
+ hold_id = doTitleHold(titleID, patronID, pickupLib)
+ if hold_id:
+ doTitleHoldCancel(hold_id)
- # XXX TODO update EG to return hold IDs for new holds so
- # that this script does not have to manually sort through
- # the holds to find what to clean up
-
- # go ahead and cancel any new holds
- allHolds = doTitleHoldFetchAll(patronID)
- logDebug("grabbed all holds %s" % str([ int(i) for i in allHolds]))
- scriptThread = ScriptThread.currentScriptThread()
- cancelHolds = [ h for h in allHolds if h not in scriptThread.userData ]
- for hold in cancelHolds:
- doTitleHoldCancel(hold)
-
-
-
ScriptManager.go(CreateTitleHoldScript())
Modified: constrictor/trunk/contrib/evergreen/eg_workflow.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_workflow.py 2009-08-10 21:40:35 UTC (rev 614)
+++ constrictor/trunk/contrib/evergreen/eg_workflow.py 2009-08-13 17:12:43 UTC (rev 615)
@@ -77,7 +77,7 @@
"TitleHoldPermit(%s, %s, %s) failed -> %s" % (
titleID, patronID, pickupLib, osrf.json.to_json(evt)))
- if str(evt) != '1':
+ if str(evt['success']) != '1':
logInfo("TitleHoldPermit(%s, %s, %s) not allowed -> %s" % (
titleID, patronID, pickupLib, evt))
return None
@@ -92,6 +92,8 @@
return
evt = TASKS['TitleHoldTask'].run(title_id=titleID, patron_id=patronID, pickup_lib=pickupLib)
+
+ logInfo("title task returned %s" % str(evt))
if isinstance(evt, list):
evts = []
@@ -104,20 +106,20 @@
logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, Event.parse_event(evt).code))
return None
- if str(evt) != '1':
+ if str(evt) == '-1':
logInfo("TitleHold(%s, %s, %s) placement failed: %s" % (
titleID, patronID, pickupLib, str(evt)))
return None
logInfo('TitleHold(%s, %s, %s) -> SUCCESS' % (titleID, patronID, pickupLib))
- return True
+ return int(evt) # new hold ID
def doTitleHoldCancel(holdID):
evt = TASKS['TitleHoldCancelTask'].run(hold_id=holdID)
- evt_txt = Event.parse_event(evt).text_code
if Event.parse_event(evt):
+ evt_txt = Event.parse_event(evt).text_code
if evt_txt == 'ACTION_HOLD_REQUEST_NOT_FOUND':
return True
raise ILSEventException(
More information about the open-ils-commits
mailing list