[open-ils-commits] r949 - in constrictor/trunk: . contrib/sip2 (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 4 10:23:33 EDT 2010
Author: erickson
Date: 2010-08-04 10:23:31 -0400 (Wed, 04 Aug 2010)
New Revision: 949
Added:
constrictor/trunk/contrib/sip2/sip2_patron_status_endurance.py
Modified:
constrictor/trunk/constrictor.properties
constrictor/trunk/contrib/sip2/sip2_client.py
Log:
added patron status test and simple endurance script
Modified: constrictor/trunk/constrictor.properties
===================================================================
--- constrictor/trunk/constrictor.properties 2010-08-04 13:33:10 UTC (rev 948)
+++ constrictor/trunk/constrictor.properties 2010-08-04 14:23:31 UTC (rev 949)
@@ -82,5 +82,7 @@
sip2.server=sip.example.org
sip2.port=6001
sip2.copyBarcodes=
+sip2.userBarcodes=
+# passwords must correspond to user barcodes by position in the list
+sip2.userPasswords=
-
Modified: constrictor/trunk/contrib/sip2/sip2_client.py
===================================================================
--- constrictor/trunk/contrib/sip2/sip2_client.py 2010-08-04 13:33:10 UTC (rev 948)
+++ constrictor/trunk/contrib/sip2/sip2_client.py 2010-08-04 14:23:31 UTC (rev 949)
@@ -135,15 +135,40 @@
constrictor.task.Task.__init__(self, self.__class__.__name__)
def run(self, **kw):
- # TODO: use a generated date
log.log_info("ItemInfoTask: %s" % copy_barcode)
msg = '1720060110 215612AO%s|AB%s|' % (institution, copy_barcode)
client.send_msg(msg)
data = client.recv_msg()
- # TODO: check for valid response
+ if data is None:
+ return False
log.log_info('SIP2 item info response: %s' % data)
return data
-
+
return ItemInfoTask().start()
+ def patron_status_request(self, institution, user_barcode, user_password):
+
+ client = self
+ class PatronStatusTask(constrictor.task.Task):
+
+ def __init__(self, name=None):
+ constrictor.task.Task.__init__(self, self.__class__.__name__)
+
+ def run(self, **kw):
+ log.log_info("PatronStatusTask: %s" % user_barcode)
+ msg = '2300120060101 084237AO%s|AA%s|AD%s|AC|' % (institution, user_barcode, user_password)
+ client.send_msg(msg)
+ data = client.recv_msg()
+ if data is None:
+ return False
+ log.log_info('SIP2 patron status response: %s' % data)
+ return data
+
+ return PatronStatusTask().start()
+
+
+
+
+
+
Added: constrictor/trunk/contrib/sip2/sip2_patron_status_endurance.py
===================================================================
--- constrictor/trunk/contrib/sip2/sip2_patron_status_endurance.py (rev 0)
+++ constrictor/trunk/contrib/sip2/sip2_patron_status_endurance.py 2010-08-04 14:23:31 UTC (rev 949)
@@ -0,0 +1,53 @@
+# -----------------------------------------------------------------------
+# Copyright (C) 2010 Equinox Software, Inc
+# Bill Erickson <erickson at esilibrary.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# -----------------------------------------------------------------------
+
+import constrictor.script
+import constrictor.properties
+import constrictor.log as log
+import sip2_client
+
+
+class SIP2PatronStatusEnduranceScript(constrictor.script.Script):
+
+ def __init__(self):
+ constrictor.script.Script.__init__(self)
+
+ def run(self):
+ props = constrictor.properties.Properties.get_properties()
+
+ username = props.get_property('sip2.username')
+ password = props.get_property('sip2.password')
+ institution = props.get_property('sip2.institution')
+ server = props.get_property('sip2.server')
+ port = int(props.get_property('sip2.port'))
+
+ user_barcodes = props.get_property('sip2.userBarcodes').split(',')
+ user_passwords = props.get_property('sip2.userPasswords').split(',')
+
+ user_barcode = user_barcodes[constrictor.script.ScriptThread.get_thread_id()]
+ user_password = user_passwords[constrictor.script.ScriptThread.get_thread_id()]
+
+ client = sip2_client.SIP2Client(server, port)
+
+ if client.init_socket() and client.login(username, password, institution):
+ for i in range(100):
+ if not client.patron_status_request(institution, user_barcode, user_password):
+ break
+
+ client.disconnect()
+
+constrictor.script.ScriptManager.go(SIP2PatronStatusEnduranceScript())
+
+
More information about the open-ils-commits
mailing list