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()
+
+
+
+
+
--- /dev/null
+# -----------------------------------------------------------------------
+# Copyright (C) 2010 Equinox Software, Inc
+# Bill Erickson <erickson@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())
+
+