source: TI03-DataExtractor/branches/old_stuff/abstractPWSC/SOAPpy_versions/CLClient_SOAPpy.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/abstractPWSC/SOAPpy_versions/CLClient_SOAPpy.py@793
Revision 793, 4.4 KB checked in by astephen, 13 years ago (diff)

Put all the old code in the old_stuff branch.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3#   Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ).
4#   This software may be distributed under the terms of the
5#   Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
6
7"""
8CLClient.py
9===============================
10
11Example Command Line client script to call the
12abstractPWSS Web Service package.
13
14Usage:
15
16    CLClient.py [-h] <SERVER_URL_PATHURL>
17   
18"""
19
20helpMessage="""
21CLClient.py
22===============================
23
24Example Command Line client script to call the
25abstractPWSS Web Service package.
26
27Usage:
28
29    CLClient.py [-h] <SERVER_URL_PATHURL>
30   
31"""
32
33# Imports from standard libary
34import sys
35
36
37def testCalls(SERVER_URL_PATH):
38    """
39    Tests some calls to the abstractPWSS Web Service, with narration
40    to standard out. It tests various methods, makes selections
41    and finally requests and output file.
42    """
43    print """\nImporting SOAP library...
44    > from SOAPpy import SOAPProxy,Config
45    > Config.debug=0"""   
46    from SOAPpy import SOAPProxy,Config
47    Config.debug=0
48   
49    print """\nConnecting to the server...
50    > server = SOAPProxy(SERVER_URL_PATH+":8444/") # port must be same as server
51    > sessionID, secureToken=server.startSession(username="jane", password="jane1")"""
52    server = SOAPProxy(SERVER_URL_PATH+":8444/") # port must be same as server
53    sessionID, secureToken=server.startSession(username="jane", password="jane1")   
54       
55    print "\nReturns sessionID and secureToken:",sessionID, secureToken
56   
57    print """\nGet next set of options...
58    > getter = SOAPProxy(SERVER_URL_PATH+":8445/")   
59    > (optionCategories, options, optionStrings, secureToken)=getter.getOptions(sessionID, secureToken=secureToken)"""   
60    getter = SOAPProxy(SERVER_URL_PATH+":8445/")   
61    (optionCategories, options, optionStrings, secureToken)=getter.getOptions(sessionID, secureToken=secureToken)   
62     
63    print "\Returns optionCategories, options, optionStrings, secureToken:", optionCategories, options, optionStrings, secureToken
64
65    print """\nSelect option_stage_1...
66    > selector = SOAPProxy(SERVER_URL_PATH+":8446/")
67    > (optionCategories, options, optionStrings, secureToken)=selector.selectOptions(sessionID, secureToken=secureToken,
68                                                            option1=options[0])"""
69    selector = SOAPProxy(SERVER_URL_PATH+":8446/") 
70    (optionCategories, options, optionStrings, secureToken)=selector.selectOptions(sessionID, secureToken=secureToken, 
71                                                            option1=options[0])
72                                                                                                                                                                           
73    print "\nReturns optionCategories, options, optionStrings, secureToken:", optionCategories, options, optionStrings, secureToken
74 
75   
76    print """\nSelect option_stage_2... 
77    > (optionCategories, options, optionStrings, secureToken)=selector.selectOptions(sessionID, secureToken=secureToken,
78                                                            option2=options[2])"""
79    (optionCategories, options, optionStrings, secureToken)=selector.selectOptions(sessionID, secureToken=secureToken, 
80                                                            option2=options[2])
81
82    print "\nReturns optionCategories, options, optionStrings, secureToken:", optionCategories, options, optionStrings, secureToken
83     
84    print """\nCheck if the request is complete...
85    > print SOAPProxy(SERVER_URL_PATH+":8447/").isComplete(sessionID, secureToken)[0]"""
86    print SOAPProxy(SERVER_URL_PATH+":8447/").isComplete(sessionID, secureToken)[0]   
87       
88    print """\nTell the server to produce an output file...   
89    > (outputLocations, secureToken) = SOAPProxy(SERVER_URL_PATH+":8448/").createOutput(sessionID, secureToken)"""
90    (outputLocations, secureToken) = SOAPProxy(SERVER_URL_PATH+":8448/").createOutput(sessionID, secureToken)   
91     
92    print """\nGet the path of the file that has been written...
93    > print outputLocations[0]"""
94    print outputLocations[0]
95   
96    print "\nEnd of session, you can grab the output file via FTP or HTTP."
97       
98
99   
100if __name__=="__main__":
101    if len(sys.argv)<2 or sys.argv[1][:7]!="http://":
102        print helpMessage
103        print "Please provide the URL of the apwss server as the only argument"
104        sys.exit()
105       
106    serverURL=sys.argv[1]
107    if serverURL[-1]=="/": serverURL=serverURL[:-1]
108    testCalls(serverURL)
109
110   
Note: See TracBrowser for help on using the repository browser.