source: TI05-delivery/trunk/examples/deliveryclient.py @ 1538

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/trunk/examples/deliveryclient.py@1538
Revision 1538, 1.1 KB checked in by spascoe, 13 years ago (diff)

Probably too many changes for one commit :-(.

I've reorganised the auth/authz API to separate interface from
implementation. Some C bug fixes but the example client now segfaults
on exit :-(.

I havn't refactored the test cases to match the new API, so I expect
they fail.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""
3A simple client.
4"""
5
6import os, sys
7from glob import glob
8
9import ndg.delivery.client.pybbftp as DC
10
11from ndg.delivery.auth_plugin import *
12
13def makeClient(username, hostname):
14    c = DC.ClientConnector()
15    try:
16        return DC.connect(AuthClientHandler(c), ['-m', '-u', username, '-r', '1', hostname])
17    except Exception, e:
18        if hasattr(e, 'clientMessages'):
19            print e.clientMessages
20        raise e
21
22def do(cmd):
23    return DC.docommand(cmd)
24
25def close():
26    return DC.close()
27
28
29if __name__ == '__main__':
30
31    try:
32        import readline
33    except ImportError:
34        pass
35
36
37    print """
38    ===================================
39    NDG Delivery Service example client
40    Type 'quit' to exit.
41    ==================================="""
42
43
44    (hostname, ) = sys.argv[1:]
45    makeClient('exampleUser', hostname)
46    cmd = ''
47    while 1:
48        print 'DS> ',
49        cmd = sys.stdin.readline()
50        if cmd.lower()[0] == 'q':
51            break
52        msgs = do(cmd.rstrip())
53        for msg in msgs:
54            print msg.rstrip()
55       
Note: See TracBrowser for help on using the repository browser.