source: fedd/fedd_info.py @ 1d91791f

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 1d91791f was 2fd8f8c, checked in by Ted Faber <faber@…>, 15 years ago

ftopo improvements

  • Property mode set to 100755
File size: 1.8 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, info_format
8
9class exp_data_opts(client_opts):
10    def __init__(self):
11        client_opts.__init__(self)
12        self.add_option("--experiment_cert", dest="exp_certfile",
13                type="string", help="experiment certificate file")
14        self.add_option("--experiment_name", dest="exp_name",
15                type="string", help="human readable experiment name")
16        self.add_option("--data", dest="data", default=[],
17                action="append", type="choice",
18                choices=("id", "experimentdescription", "federant", "vtopo", 
19                    "vis", "log", "status", "embedding"),
20                help="data to extract")
21       
22parser = exp_data_opts()
23(opts, args) = parser.parse_args()
24cert, fid = wrangle_standard_options(opts)
25
26if opts.exp_name and opts.exp_certfile:
27    sys.exit("Only one of --experiment_cert and --experiment_name permitted")
28elif opts.exp_certfile:
29    exp_id = { 'fedid': fedid(file=opts.exp_certfile) }
30elif opts.exp_name:
31    exp_id = { 'localname' : opts.exp_name }
32else:
33    sys.exit("specify one of --experiment_cert and --experiment_name")
34
35req = { 'experiment': exp_id }
36
37try:
38    resp_dict = do_rpc(req,
39            opts.url, opts.transport, cert, opts.trusted, 
40            serialize_only=opts.serialize_only,
41            tracefile=opts.tracefile,
42            caller=service_caller('Info'), responseBody='InfoResponseBody')
43except RPCException, e:
44    exit_with_fault(e)
45except RuntimeError, e:
46    sys.exit("Error processing RPC: %s" % e)
47
48formatter = info_format()
49for d in opts.data:
50    try:
51        formatter(resp_dict, d)
52    except RuntimeError, e:
53        print >>sys.stderr, "Warning: %s" % e
Note: See TracBrowser for help on using the repository browser.