[2e46f35] | 1 | #!/usr/bin/env python |
---|
[d743d60] | 2 | |
---|
| 3 | import sys |
---|
| 4 | import os |
---|
| 5 | import pwd |
---|
| 6 | import tempfile |
---|
| 7 | import subprocess |
---|
| 8 | import re |
---|
| 9 | import xml.parsers.expat |
---|
| 10 | import time |
---|
| 11 | |
---|
[e83f2f2] | 12 | from federation.proof import proof |
---|
[d743d60] | 13 | from federation.remote_service import service_caller |
---|
| 14 | from federation.client_lib import client_opts, exit_with_fault, RPCException,\ |
---|
[e83f2f2] | 15 | wrangle_standard_options, do_rpc, info_format, log_authentication |
---|
[d743d60] | 16 | |
---|
| 17 | class exp_data_opts(client_opts): |
---|
| 18 | def __init__(self): |
---|
| 19 | client_opts.__init__(self) |
---|
| 20 | self.add_option("--data", dest="data", default=[], |
---|
| 21 | action="append", type="choice", |
---|
| 22 | choices=("id", "experimentdescription", "federant", "vtopo", |
---|
| 23 | "vis", "log", "status"), |
---|
| 24 | help="data to extract") |
---|
| 25 | |
---|
| 26 | parser = exp_data_opts() |
---|
| 27 | (opts, args) = parser.parse_args() |
---|
[a0c2866] | 28 | try: |
---|
| 29 | cert, fid, url = wrangle_standard_options(opts) |
---|
| 30 | except RuntimeError, e: |
---|
| 31 | sys.exit("%s" %e) |
---|
[d743d60] | 32 | |
---|
| 33 | try: |
---|
| 34 | resp_dict = do_rpc({ }, |
---|
[5d854e1] | 35 | url, opts.transport, cert, opts.trusted, |
---|
[d743d60] | 36 | serialize_only=opts.serialize_only, |
---|
| 37 | tracefile=opts.tracefile, |
---|
| 38 | caller=service_caller('MultiInfo'), |
---|
| 39 | responseBody='MultiInfoResponseBody') |
---|
| 40 | except RPCException, e: |
---|
[e83f2f2] | 41 | exit_with_fault(e, 'MultiInfo', opts) |
---|
[d743d60] | 42 | except RuntimeError, e: |
---|
| 43 | sys.exit("Error processing RPC: %s" % e) |
---|
| 44 | |
---|
| 45 | formatter = info_format() |
---|
| 46 | for i in resp_dict.get('info', []): |
---|
| 47 | for d in opts.data: |
---|
| 48 | formatter(i, d) |
---|
| 49 | print "---" |
---|
[e83f2f2] | 50 | proof = proof.from_dict(resp_dict.get('proof', {})) |
---|
| 51 | if proof and opts.auth_log: |
---|
| 52 | log_authentication(opts.auth_log, 'MultiInfo', 'succeeded', proof) |
---|