]> git.evergreen-ils.org Git - working/random.git/blob - contrib/sip2/sip2_item_info_endurance.py
new SIP2 client contrib module. currently supports login and item information requests
[working/random.git] / contrib / sip2 / sip2_item_info_endurance.py
1 # -----------------------------------------------------------------------
2 # Copyright (C) 2010 Equinox Software, Inc
3 # Bill Erickson <erickson@esilibrary.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 3
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 # -----------------------------------------------------------------------
15
16 import constrictor.script
17 import constrictor.properties
18 import constrictor.log as log
19 import sip2_client
20
21
22 class SIP2ItemInfoEnduranceScript(constrictor.script.Script):
23
24     def __init__(self):
25         constrictor.script.Script.__init__(self)
26
27     def run(self):
28         props = constrictor.properties.Properties.get_properties()
29
30         username = props.get_property('sip2.username')
31         password = props.get_property('sip2.password')
32         institution = props.get_property('sip2.institution')
33         server = props.get_property('sip2.server')
34         port = int(props.get_property('sip2.port'))
35
36         barcodes = props.get_property('sip2.copyBarcodes').split(',')
37         copy_barcode = barcodes[constrictor.script.ScriptThread.get_thread_id()]
38
39         client = sip2_client.SIP2Client(server, port)
40         client.init_socket()
41
42         if client.login(username, password, institution):
43             for i in range(100):
44                 if not client.item_info_request(institution, copy_barcode):
45                     break
46
47 constrictor.script.ScriptManager.go(SIP2ItemInfoEnduranceScript())
48
49