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

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

Major directory structure reorganisation.

The python source tree is now divided into 3 components: common,
server and client. Each component has it's own setup.py.

Do "python setup.py bdist_egg" to create 3 eggs for each component.

Some things in the distribution are now out of sync (e.g. documentation) but
the test cases work (I havn't tried the remote test cases).

  • 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.common.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.