source: fedd/fedd_info.py @ 62f3dd9

axis_examplecompt_changesinfo-ops
Last change on this file since 62f3dd9 was 62f3dd9, checked in by Ted Faber <faber@…>, 13 years ago

allow command line progams to expand tildes. Added a class derived from OptionParser? to make that easily available.

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