Ignore:
Timestamp:
Jun 3, 2014 4:29:31 PM (10 years ago)
Author:
Ted Faber <faber@…>
Branches:
master
Children:
0b217d1
Parents:
ba07149
Message:

Service info in xml files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_ns2topdl.py

    rba07149 rc259a77  
    88from federation.remote_service import service_caller
    99from federation.client_lib import client_opts, exit_with_fault, RPCException, \
    10         wrangle_standard_options, do_rpc, get_experiment_names, save_certfile
     10        wrangle_standard_options, do_rpc, get_experiment_names, save_certfile,\
     11        ns_service_re
    1112
    1213class ns_topdl_opts(client_opts):
     
    2627except RuntimeError, e:
    2728    sys.exit("%s" %e)
    28 
     29svcs = []
     30contents = ''
    2931if opts.file:
    3032    try:
    31         contents = "".join([l for l in open(opts.file, "r")])
     33        for l in open(opts.file, 'r'):
     34            contents += l
     35            if  ns_service_re.match(l):
     36                svcs.append('SERVICE: %s' % ns_service_re.match(l).group(1))
    3237    except EnvironmentError, e:
    3338        sys.exit("Can't read %s: %s" % (opts.file, e))
     
    6267    sys.exit("Bad response. %s" % e.message)
    6368
     69if len(svcs) > 0 :
     70    comments = '<!--\n%s\n-->' % '\n'.join(svcs)
     71else:
     72    comments = ''
     73
    6474if opts.outfile:
    6575    try:
    6676        f = open(opts.outfile, "w")
     77        print >>f, comments
    6778        print >>f, topdl.topology_to_xml(top, top="experiment")
    6879        f.close()
     
    7081        sys.exit("Can't write to %s: %s" % (opts.outfile, e))
    7182else:
     83    print comments
    7284    print topdl.topology_to_xml(top, top="experiment")
    7385proof = proof.from_dict(resp_dict.get('proof', {}))
Note: See TracChangeset for help on using the changeset viewer.