source: fedd/fedd_info.py @ 6b25610

axis_examplecompt_changesinfo-ops
Last change on this file since 6b25610 was 2e46f35, checked in by mikeryan <mikeryan@…>, 14 years ago

switch to /usr/bin/env python to run python

  • Property mode set to 100755
File size: 2.1 KB
Line 
1#!/usr/bin/env python
2
3import sys
4
5from federation.proof import proof
6from federation.remote_service import service_caller
7from federation.client_lib import client_opts, exit_with_fault, RPCException,\
8        wrangle_standard_options, do_rpc, get_experiment_names, info_format, \
9        log_authentication
10
11class exp_data_opts(client_opts):
12    def __init__(self):
13        client_opts.__init__(self)
14        self.add_option("--experiment_cert", dest="exp_certfile",
15                action='callback', callback=self.expand_file, type='str',
16                help="experiment certificate file")
17        self.add_option("--experiment_name", dest="exp_name",
18                type="string", help="human readable experiment name")
19        self.add_option("--data", dest="data", default=[],
20                action="append", type="choice",
21                choices=("id", "experimentdescription", "federant", "vtopo", 
22                    "vis", "log", "status", "embedding"),
23                help="data to extract")
24       
25parser = exp_data_opts()
26(opts, args) = parser.parse_args()
27cert, fid, url = wrangle_standard_options(opts)
28
29if opts.exp_name and opts.exp_certfile:
30    sys.exit("Only one of --experiment_cert and --experiment_name permitted")
31elif opts.exp_certfile:
32    exp_id = { 'fedid': fedid(file=opts.exp_certfile) }
33elif opts.exp_name:
34    exp_id = { 'localname' : opts.exp_name }
35else:
36    sys.exit("specify one of --experiment_cert and --experiment_name")
37
38req = { 'experiment': exp_id }
39
40try:
41    resp_dict = do_rpc(req,
42            url, opts.transport, cert, opts.trusted, 
43            serialize_only=opts.serialize_only,
44            tracefile=opts.tracefile,
45            caller=service_caller('Info'), responseBody='InfoResponseBody')
46except RPCException, e:
47    exit_with_fault(e, 'Info', opts)
48except RuntimeError, e:
49    sys.exit("Error processing RPC: %s" % e)
50
51formatter = info_format()
52for d in opts.data:
53    try:
54        formatter(resp_dict, d)
55    except RuntimeError, e:
56        print >>sys.stderr, "Warning: %s" % e
57proof = proof.from_dict(resp_dict.get('proof', {}))
58if proof and opts.auth_log:
59    log_authentication(opts.auth_log, 'Info', 'succeeded', proof)
Note: See TracBrowser for help on using the repository browser.