| 1 | #!/usr/bin/env python |
|---|
| 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 | |
|---|
| 12 | from federation.proof import proof |
|---|
| 13 | from federation.remote_service import service_caller |
|---|
| 14 | from federation.client_lib import client_opts, exit_with_fault, RPCException,\ |
|---|
| 15 | wrangle_standard_options, do_rpc, info_format, log_authentication |
|---|
| 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() |
|---|
| 28 | try: |
|---|
| 29 | cert, fid, url = wrangle_standard_options(opts) |
|---|
| 30 | except RuntimeError, e: |
|---|
| 31 | sys.exit("%s" %e) |
|---|
| 32 | |
|---|
| 33 | try: |
|---|
| 34 | resp_dict = do_rpc({ }, |
|---|
| 35 | url, opts.transport, cert, opts.trusted, |
|---|
| 36 | serialize_only=opts.serialize_only, |
|---|
| 37 | tracefile=opts.tracefile, |
|---|
| 38 | caller=service_caller('MultiInfo'), |
|---|
| 39 | responseBody='MultiInfoResponseBody') |
|---|
| 40 | except RPCException, e: |
|---|
| 41 | exit_with_fault(e, 'MultiInfo', opts) |
|---|
| 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 "---" |
|---|
| 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) |
|---|