[Swift-commit] r4876 - SwiftApps/GOSwift/pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Fri Jul 29 16:17:40 CDT 2011
Author: jonmon
Date: 2011-07-29 16:17:40 -0500 (Fri, 29 Jul 2011)
New Revision: 4876
Modified:
SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
Log:
o changes to the goswift command
-- Pipe stderr to stdout
-- Write stdout to file
-- Swift to using the trunk release
Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-07-29 19:15:13 UTC (rev 4875)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-07-29 21:17:40 UTC (rev 4876)
@@ -4,6 +4,7 @@
import sys
import subprocess
import datetime
+import stat
from sqlalchemy.sql import text
@@ -270,7 +271,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")
+# 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
os.chdir(work_directory)
status = -1
@@ -279,14 +281,22 @@
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 2>&1 | tee -a swift.out"
+ execute = cmd + " -runid "+str(run_id)+" -sites.file sites.xml -tc.file tc -config cf script.swift | tee -a swift.out"
pykoa.debug( "running %s in watch mode" % (execute))
- p = subprocess.Popen(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" )
+
+ os.chmod(work_directory+"/run.sh", stat.S_IRUSR | stat.S_IXUSR )
+
+ p = subprocess.Popen("exec "+work_directory+"/run.sh",
close_fds=True, shell=True,
preexec_fn=enable_sigint,
cwd=os.getcwd(),
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.STDOUT)
c = SwiftObserver()
status = c.run(p)
@@ -298,15 +308,27 @@
sys.stdout.write( "Swift exit status: " + str(status) + "\n" )
else:
- execute = cmd + " -runid "+str(run_id)+" -sites.file sites.xml -tc.file tc -config cf script.swift &>>swift.out"
+ swift_out = open("swift.out", "w")
+ execute = cmd + " -runid "+str(run_id)+" -sites.file sites.xml -tc.file tc -config cf script.swift"
pykoa.debug( "running %s in background mode" % (execute))
- p = subprocess.Popen(execute, close_fds=True,
- shell=True, preexec_fn=enable_sigint,
+
+ 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" )
+
+ os.chmod(work_directory+"/run.sh", stat.S_IRUSR | stat.S_IXUSR )
+
+ p = subprocess.Popen("exec "+work_directory+"/run.sh",
+ close_fds=True, shell=True,
+ preexec_fn=enable_sigint,
cwd=os.getcwd(),
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.STDOUT,
+ stdout=swift_out)
pid = p.pid
+ 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")
More information about the Swift-commit
mailing list