[Swift-commit] r4926 - SwiftApps/GOSwift/pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Mon Aug 1 17:15:41 CDT 2011
Author: jonmon
Date: 2011-08-01 17:15:41 -0500 (Mon, 01 Aug 2011)
New Revision: 4926
Modified:
SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
Log:
o koa_goswift.py
-- write stdout/stderr to file after watch mode completes
-- keep track of stdout/stderr in SwiftObserver
-- comments
-- Add exit code to swift.info file in each run directory
Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-08-01 21:11:20 UTC (rev 4925)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-08-01 22:15:41 UTC (rev 4926)
@@ -27,10 +27,12 @@
def stdout_event(self, line):
sys.stdout.write(line)
+ self.lines.append(line)
return
def stderr_event(self, line):
sys.stderr.write(line)
+ self.lines.append(line)
return
def setup_opts(argv):
@@ -271,8 +273,8 @@
os.environ["GLOBUS_SOURCE_PORT_RANGE"] = "50000,51000"
# Execute the script
-# cmd = os.path.join(os.environ["HOME"], "Swift_lib/swift-0.92/bin", "swift") # stable 0.92.1 release
- cmd = os.path.join(os.environ["HOME"], "Swift_lib/bin", "swift") # trunk release
+# cmd = os.path.join(os.environ["HOME"], "Swift_lib/0.92", "swift") # stable 0.92.1 release
+ cmd = os.path.join(os.environ["HOME"], "Swift_lib/trunk", "swift") # trunk release
os.chdir(work_directory)
status = -1
@@ -281,13 +283,16 @@
if options.watch_swift_stdoutput:
try:
with BlockInterrupt():
- execute = cmd + " -runid "+str(run_id)+" -sites.file sites.xml -tc.file tc -config cf script.swift | tee -a swift.out"
+ execute = cmd + " -runid "+str(run_id)+" -sites.file sites.xml -tc.file tc -config cf script.swift"
pykoa.debug( "running %s in watch mode" % (execute))
with open(work_directory+"/run.sh", "w") as run_sh:
run_sh.write( "#!/bin/bash\n" )
run_sh.write( "[ -f /opt/osg/setup.sh ] && source /opt/osg/setup.sh\n")
run_sh.write( execute + "\n" )
+ run_sh.write( "\n" )
+ run_sh.write( "echo \"\nExit Code: $?\" >> swift.info\n" )
+ run_sh.write( "exit $?" )
os.chmod(work_directory+"/run.sh", stat.S_IRUSR | stat.S_IXUSR )
@@ -298,13 +303,25 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ pid = p.pid
+
+ with open("swift.info", "w") as swift_info:
+ swift_info.write("StartTime: "+str(datetime.datetime.utcnow())+"\n")
+ swift_info.write("Swift pid: "+str(pid)+"\n")
+ swift_info.write("Run id: "+str(run_id)+"\n")
+ swift_info.write("\n")
+ swift_info.write("Command Line:\n "+execute+"\n")
+
c = SwiftObserver()
status = c.run(p)
- pid = p.pid
finally:
if src_cred:
os.remove( proxyfile )
+ with open("swift.out", "w") as swift_out:
+ for line in c.lines:
+ swift_out.write(line)
+
sys.stdout.write( "Swift exit status: " + str(status) + "\n" )
else:
@@ -316,6 +333,8 @@
run_sh.write( "#!/bin/bash\n" )
run_sh.write( "[ -f /opt/osg/setup.sh ] && source /opt/osg/setup.sh\n")
run_sh.write( execute + "\n" )
+ run_sh.write( "echo \"\nExit Code: $? >> swift.info\"\n" )
+ run_sh.write( "exit $?" )
os.chmod(work_directory+"/run.sh", stat.S_IRUSR | stat.S_IXUSR )
@@ -329,13 +348,6 @@
swift_out.close()
- with open("swift.info", "w") as swift_info:
- swift_info.write("StartTime: "+str(datetime.datetime.utcnow())+"\n")
- swift_info.write("Swift pid: "+str(pid)+"\n")
- swift_info.write("Run id: "+str(run_id)+"\n")
- swift_info.write("\n")
- swift_info.write("Command Line:\n "+execute+"\n")
-
return status
def create_work_directory():
More information about the Swift-commit
mailing list