source: fedd/fedd_new.py @ b501f63

version-3.02
Last change on this file since b501f63 was d743d60, checked in by Ted Faber <faber@…>, 15 years ago

Totally refactor fedd_client.py into component scripts. The previous layout
have become a twisty hell of misdirected OOP and learning python run amok.
This version is actually pretty readable and will be much easier to build on.

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/usr/local/bin/python
2
3import sys
4
5from federation.remote_service import service_caller
6from federation.client_lib import client_opts, exit_with_fault, RPCException, \
7        wrangle_standard_options, do_rpc, get_experiment_names, save_certfile
8
9
10class new_opts(client_opts):
11    def __init__(self):
12        client_opts.__init__(self)
13        self.add_option("--experiment_cert", dest="out_certfile",
14                type="string", help="output certificate file")
15        self.add_option("--experiment_name", dest="exp_name",
16                type="string", help="Suggested experiment name")
17
18parser = new_opts()
19(opts, args) = parser.parse_args()
20
21cert, fid = wrangle_standard_options(opts)
22
23out_certfile = opts.out_certfile
24
25msg = { }
26
27if opts.exp_name:
28    msg['experimentID'] = { 'localname': opts.exp_name }
29
30if opts.debug > 1: print >>sys.stderr, msg
31
32try:
33    resp_dict = do_rpc(msg, 
34            opts.url, opts.transport, cert, opts.trusted, 
35            serialize_only=opts.serialize_only,
36            tracefile=opts.tracefile, 
37            caller=service_caller("New"), responseBody='NewResponseBody')
38except RPCException, e:
39    exit_with_fault(e)
40except RuntimeError, e:
41    sys.exit("Error processing RPC: %s" % e)
42
43if opts.debug > 1: print >>sys.stderr, resp_dict
44
45try:
46    save_certfile(opts.out_certfile, resp_dict.get('experimentAccess', None))
47except EnvironmentError:
48    sys.exit('Could not write to %s' %  out_certfile)
49
50e_fedid, e_local = get_experiment_names(resp_dict.get('experimentID', None))
51st = resp_dict.get('experimentStatus', None)
52
53if e_local: print "localname: %s" % e_local
54if e_fedid: print "fedid: %s" % e_fedid
55if st: print "status: %s" % st
Note: See TracBrowser for help on using the repository browser.