Changeset 8cb269a
- Timestamp:
- Oct 13, 2011 2:48:24 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- 0dc62df
- Parents:
- c167378
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/ns2topdl.py
rc167378 r8cb269a 6 6 import logging 7 7 import topdl 8 9 import os.path 8 10 9 11 from util import * … … 105 107 raise service_error(service_error.internal, "Cannot create tmp dir") 106 108 107 tclfile = tmpdir + "/experiment.tcl" 109 tclfile = os.path.join(tmpdir, "experiment.tcl") 110 # save error output in case the parse fails. 111 errfile = os.path.join(tmpdir, "errfile") 108 112 pid = "dummy" 109 113 gid = "dummy" … … 124 128 f.write(file_content) 125 129 f.close() 130 ef = open(errfile, 'w') 126 131 except EnvironmentError: 127 132 raise service_error(service_error.internal, … … 138 143 tclcmd.extend([pid, gid, eid, tclfile]) 139 144 self.log.debug("Calling splitter %s" % " ".join(tclcmd)) 140 tclparser = subprocess.Popen(tclcmd, stdout=subprocess.PIPE )145 tclparser = subprocess.Popen(tclcmd, stdout=subprocess.PIPE, stderr=ef) 141 146 142 top = topdl.topology_from_xml(file=tclparser.stdout, top="experiment") 147 try: 148 top = topdl.topology_from_xml(file=tclparser.stdout, 149 top="experiment") 150 except: 151 top = None 152 153 if top is None: 154 # There was an ns parsing error, gather up the error from the 155 # errfile and raise a service_error containing the error text 156 try: 157 ef = open(errfile, 'r') 158 parse_err = ef.read() 159 ef.close() 160 except EnvironmentError: 161 raise service_error(service_error.internal, 162 "Cannot read error string") 163 164 raise service_error(service_error.req, 165 "Cannot parse ns file: %s" % parse_err) 143 166 144 167 # Walk up tmpdir, deleting as we go
Note: See TracChangeset
for help on using the changeset viewer.