source: fedd/fedd_info.py @ d743d60

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since d743d60 was d743d60, checked in by Ted Faber <faber@…>, 14 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.7 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"),
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    formatter(resp_dict, d)
Note: See TracBrowser for help on using the repository browser.