View | Details | Raw Unified | Return to bug 26701
Collapse All | Expand All

(-)a/C4/SIP/acstest.py (-42 lines)
Lines 1-42 Link Here
1
import operator
2
import socket
3
from time import strftime;
4
5
def SipSocket(host='localhost', port=5300):
6
    so = socket.socket()
7
    so.connect((host, port))
8
    return so
9
10
def login(so, uname='scclient', passwd='clientpwd', locn='The basement',
11
          seqno=0):
12
    port = so.getpeername()[1]
13
    if port == 5300:
14
        resp = send(so, '9300CN%s|CO%s|CP%s|' % (uname, passwd, locn), seqno)
15
        print "Received", repr(resp)
16
        print "Verified: ", verify(resp)
17
    else:
18
        raise "Logging in is only support for the raw transport on port 5300"
19
20
def send(so, msg, seqno=0):
21
    if seqno:
22
        msg += 'AY' + str(seqno)[0] + 'AZ'
23
        msg += ('%04X' % calculate_cksum(msg))
24
    msg += '\r'
25
    print 'Sending', repr(msg)
26
    so.send(msg)
27
    resp = so.recv(1000)
28
    return resp, verify(resp)
29
30
def calculate_cksum(msg):
31
    return (-reduce(operator.add, map(ord, msg)) & 0xFFFF)
32
33
def sipdate():
34
    return(strftime("%Y%m%d    %H%M%S"))
35
36
def verify(msg):
37
    if msg[-1] == '\r': msg = msg[:-2]
38
    if msg[-6:-4] == 'AZ':
39
        cksum = calculate_cksum(msg[:-4])
40
        return (msg[-4:] == ('%04X' % cksum))
41
    # If there's no checksum, then the message is ok
42
    return True
(-)a/C4/SIP/example_institution_dump.sh (-16 lines)
Lines 1-16 Link Here
1
#!/bin/bash
2
3
perl -I ./ -e '
4
use Data::Dumper;
5
use C4::SIP::ILS;
6
use C4::SIP::Sip::Configuration;
7
my $code = "MAIN";
8
my $conf = C4::SIP::Sip::Configuration->new("SIPconfig.xml");
9
my $ils  = C4::SIP::ILS->new($conf->{institutions}->{$code});
10
print "XML for $code: ", Dumper($conf->{institutions}->{$code}), "\n";
11
print "ILS for $code: ", Dumper($ils), "\n";
12
print "\$ils->checkout_ok(): ", ($ils->checkout_ok() ? "Y" : "N"), "\n";
13
print "\$ils->checkin_ok() : ", ($ils->checkin_ok()  ? "Y" : "N"), "\n";
14
print "\$ils->offline_ok() : ", ($ils->offline_ok()  ? "Y" : "N"), "\n";
15
print "\n";
16
'
(-)a/C4/SIP/interactive_item_dump.pl (-44 lines)
Lines 1-44 Link Here
1
#!/usr/bin/perl
2
#
3
4
use warnings;
5
use strict;
6
7
use C4::SIP::ILS::Item;
8
use Data::Dumper;
9
10
my $compare = (@ARGV) ? shift : 0;
11
while (1) {
12
	print "Enter item barcode: ";
13
	my $in = <>;
14
	defined($in) or last;
15
	chomp($in);
16
	last unless $in;
17
	my $item = C4::SIP::ILS::Item->new($in);
18
    unless ($item) {
19
        print "No item ($in)";
20
        next;
21
    }
22
    for (qw(marc marcxml)) { # Letting it just in case but should not longer be useful
23
        $item->{$_} = 'suppressed...';
24
    }
25
    my $queue = $item->hold_queue();
26
    print "Item ($in): ", Dumper($item);
27
    print "hold_queue: ", Dumper($queue);
28
    my $holdernumber;
29
	if ($queue and scalar(@$queue)) {
30
        $holdernumber = $queue->[0]->{borrowernumber};
31
        print "first borrowernumber: $holdernumber\n";
32
    }
33
    if ($compare) {
34
        print "Enter patron barcode: ";
35
        my $barcode = <>;
36
        defined($barcode) or next;
37
        chomp($barcode);
38
        next unless $barcode;
39
        my $x = ILS::Item::_barcode_to_borrowernumber($barcode) || 'UNDEF';
40
        print  "         converts to: $x\n";
41
        printf "         compares as: %s\n", 
42
            ($item->barcode_is_borrowernumber($barcode,$holdernumber) ? 'TRUE' : 'FALSE');
43
    }
44
}
(-)a/C4/SIP/interactive_patron_check_password.pl (-26 lines)
Lines 1-26 Link Here
1
#!/usr/bin/perl
2
#
3
4
use warnings;
5
use strict;
6
7
use C4::SIP::ILS::Patron;
8
use C4::SIP::Sip qw(sipbool);
9
use Data::Dumper;
10
11
while (1) {
12
	print "Enter patron barcode: ";
13
	my $in = <>;
14
	defined($in) or last;
15
	chomp($in);
16
	last unless $in;
17
	my $patron = C4::SIP::ILS::Patron->new($in);
18
	print Dumper($patron);
19
	$patron or next;
20
	print "Enter patron password: ";
21
	$in = <>;
22
	chomp($in);
23
	print "Raw password is: " . $patron->{password}, "\n"; 
24
	print " check_password: " . $patron->check_password($in), "\n"; 
25
	print "        sipbool: " . sipbool($patron->check_password($in)), "\n"; 
26
}
(-)a/C4/SIP/interactive_patron_dump.pl (-18 lines)
Lines 1-18 Link Here
1
#!/usr/bin/perl
2
#
3
4
use warnings;
5
use strict;
6
7
use C4::SIP::ILS::Patron;
8
use Data::Dumper;
9
10
while (1) {
11
	print "Enter patron barcode: ";
12
	my $in = <>;
13
	defined($in) or last;
14
	chomp($in);
15
	last unless $in;
16
	my $patron = C4::SIP::ILS::Patron->new($in);
17
	print "Patron ($in):\n", Dumper($patron);
18
}
(-)a/C4/SIP/interactive_renew_all_dump.pl (-22 lines)
Lines 1-22 Link Here
1
#!/usr/bin/perl
2
#
3
4
use warnings;
5
use strict;
6
7
use C4::SIP::ILS::Transaction::RenewAll;
8
use Data::Dumper;
9
10
while (1) {
11
	print "Enter patron barcode: ";
12
	my $in = <>;
13
	defined($in) or last;
14
	chomp($in);
15
	last unless $in;
16
	my $patron = ILS::Patron->new($in);
17
	print "Patron before: \n " . Dumper($patron);
18
	my $action = C4::SIP::ILS::Transaction::RenewAll->new();
19
	$action->do_renew_all();
20
	print "\n\nTransaction::RenewAll: " . Dumper($action);
21
	print "\n", "=" x 35, "\n";
22
}
(-)a/C4/SIP/test.txt (-27 lines)
Lines 1-27 Link Here
1
97AZFEF5
2
2300120071003    084235AOkohalibrary|AArch|ACkoha|ADkoha|
3
4
2300120060101    084236AOUWOLS|AAmjandkilde|ACterminal password|ADuser password|
5
2300120060101    084237AOUWOLS|AAdjfiander|ACterminal password|ADuser password|
6
9300CNLoginUserID|COLoginPassword|CPLocationCode|
7
11YN20060329    203000                  AOUWOLS|AAdjfiander|AB1565921879|AC|
8
09Y20060102    08423620060113    084235APUnder the bed|AOUWOLS|AB1565921879|ACterminal password|
9
01N20060102    084238AOUWOLS|ALHe's a jerk|AAdjfiander|ACterminal password|
10
11
2520060102    084238AOUWOLS|AAdjfiander|ACterminal password|AD6789|
12
9910302.00
13
14
3520060110    084237AOkohalibrary|AArch|ADkoha|
15
1720060110    215612AOUWOLS|AB1565921879|
16
17
patron information: 
18
6300020060329    201700Y         AOkohalibrary|AArch|ACkoha|ADkoha|
19
20
15+20060415    110158BW20060815    110158|BSTaylor|BY2|AOUWOLS|AAdjfiander|AB1565921879|
21
15-20060415    110158AOUWOLS|AAdjfiander|AB1565921879|
22
29NN20060415    110158                  AOUWOLS|AAdjfiander|AD6789|AB1565921879|
23
6520060415    110158AOUWOLS|AAdjfiander|AD6789|
24
25
working:
26
27
9300CNkoha|COkoha|CPkohalibrary|
(-)a/C4/SIP/xmlparse.pl (-32 lines)
Lines 1-31 Link Here
1
#!/usr/bin/perl
2
#
3
# This file reads a SIPServer xml-format configuration file and dumps it
4
# to stdout.  Just to see what the structures look like.
5
#
6
# The 'new XML::Simple' option must agree exactly with the configuration
7
# in Sip::Configuration.pm
8
#
9
use strict;
10
use warnings;
11
use English;
12
13
use XML::Simple qw(:strict);
14
use Data::Dumper;
15
16
my $parser = XML::Simple->new( KeyAttr   => { login => '+id',
17
					     institution => '+id',
18
					     service => '+port', },
19
			      GroupTags =>  { listeners => 'service',
20
					      accounts => 'login',
21
					      institutions => 'institution', },
22
			      ForceArray=> [ 'service',
23
					     'login',
24
					     'institution' ],
25
			      ValueAttr =>  { 'error-detect' => 'enabled',
26
					     'min_servers' => 'value',
27
					     'max_servers' => 'value'} );
28
29
my $ref = $parser->XMLin(@ARGV ? shift : 'SIPconfig.xml');
30
31
print Dumper($ref); 
32
- 

Return to bug 26701