[Swift-commit] r7853 - SwiftApps/swift-galaxy/swift
ketan at ci.uchicago.edu
ketan at ci.uchicago.edu
Sun May 11 18:09:31 CDT 2014
Author: ketan
Date: 2014-05-11 18:09:31 -0500 (Sun, 11 May 2014)
New Revision: 7853
Added:
SwiftApps/swift-galaxy/swift/testpy.sh
Modified:
SwiftApps/swift-galaxy/swift/swiftforeach.py
Log:
test and fixes for py
Modified: SwiftApps/swift-galaxy/swift/swiftforeach.py
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeach.py 2014-05-11 19:32:48 UTC (rev 7852)
+++ SwiftApps/swift-galaxy/swift/swiftforeach.py 2014-05-11 23:09:31 UTC (rev 7853)
@@ -3,7 +3,8 @@
import subprocess
import sys
import os
-import distutils.
+import distutils.spawn
+import traceback
def setwdir():
return subprocess.check_output(["mktemp", "-d", "/tmp/swift-gal.XXXX"])
@@ -12,7 +13,7 @@
for a in args:
yield a
-def buildcfg():
+def buildcfg(wdir):
f=open(wdir+"/cf", 'w');
f.write('use.provider.staging=true')
f.write('wrapperlog.always.transfer=true')
@@ -26,13 +27,21 @@
def main():
myargs = genargs(sys.argv)
try:
+ this=next(myargs)
range_or_list = next(myargs)
+ #print "range or list=> "+ range_or_list
k_or_t = next(myargs)
+ #print "k or t=> "+ k_or_t
sites = next(myargs)
+ #print "sites=> " + sites
swiftargs = next(myargs)
+ #print "swiftargs=> " + swiftargs
interpreter = next(myargs)
+ #print "interpreter=> " + interpreter
executable = next(myargs)
+ #print "executable=> " + executable
stdin = next(myargs)
+ #print "stdin => " + stdin
if range_or_list == "list":
listfile = next(myargs)
@@ -41,17 +50,15 @@
rstart = next(myargs)
rend = next(myargs)
stepsize = next(myargs)
-
- rstart = next(myargs)
- rend = next(myargs)
- stepsize = next(myargs)
+
outloc = next(myargs)
outlistfile = next(myargs)
+ #print "outlistfile=>"+outlistfile
logfile = next(myargs)
stringargs = next(myargs)
except:
+ traceback.print_exc()
sys.exit(1)
-
swift = distutils.spawn.find_executable("swift")
BASEDIR = os.path.dirname(os.path.realpath(__file__))
@@ -70,7 +77,7 @@
filearrayexpr="file fileargs[];"
# create outloc dir
- if not os.path.exists(directory):
+ if not os.path.exists(outloc):
os.makedirs(outloc)
# workout the stringargs
@@ -134,7 +141,7 @@
subprocess.call([basedir+"/buildsite.sh", sites, wdir])
#build config
- buildcfg()
+ buildcfg(wdir)
#build tc
tc=open(wdir+"/tc", 'w');
@@ -161,9 +168,9 @@
if range_or_list == "list":
f.write(" \n");
- f.write("file listfile=input("$listfile");\n")
+ f.write("file listfile=input(\""+listfile+"\");\n")
f.write("string list[] = split(read(listfile),);\n");
- f.write("foreach l, i in list{"\n)
+ f.write("foreach l, i in list{\n")
f.write(" file out <sprintf(\""+outloc+"/%s.%i.out\", l, i)>;\n")
f.write(" file err <sprintf(\""+outloc+"/%s.%i.err\", l, i)>;\n")
@@ -175,14 +182,14 @@
f.write("(out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);\n")
f.write("}\n");
- f.write("printf("%s", "Done!");\n");
+ f.write("printf(\"%s\", \"Done!\");\n");
f.write("}\n");
f.close()
#Populate output file
outlist=subprocess.check_output(["find", outloc, "-type", "f", "-iname", "*.out"])
- f=open(outlistfile)
+ f=open(outlistfile, "w")
f.write(outlist);
f.close()
#dum ditty dum ditty dum dum dum
Added: SwiftApps/swift-galaxy/swift/testpy.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/testpy.sh (rev 0)
+++ SwiftApps/swift-galaxy/swift/testpy.sh 2014-05-11 23:09:31 UTC (rev 7853)
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+#!/bin/bash
+
+cat << EOF > list.txt
+a
+b
+c
+EOF
+
+cat << EOF > x.sh
+#!/bin/bash
+
+echo \$\@
+EOF
+
+chmod 755 x.sh
+
+echo "List, no input parameters and files"
+./swiftforeach.py list swiftK localhost "" bash x.sh "" list.txt tmpoutlist a.log list1.out ""
+
+echo "Range, no input parameters and files"
+./swiftforeach.py range swiftK localhost "" bash x.sh "" 0 9 1 tmpoutrange b.log list2.out ""
+
+echo "List, string input parameters"
+./swiftforeach.py range swiftK localhost "" bash x.sh "" 0 9 1 tmpoutrange b.log list2.out "hello there list!"
+
+echo "Range, string input parameters"
+./swiftforeach.py range swiftK localhost "" bash x.sh "" 0 9 1 tmpoutrange b.log list2.out "hi there range!"
+
+echo "List, no input parameters and files stdin /dev/null"
+./swiftforeach.py list swiftK localhost "" bash x.sh "/dev/null" list.txt tmpoutlist a.log list1.out ""
+
+echo "T list"
+./swiftforeach.py list swiftT localhost "" bash x.sh "" list.txt tmpoutlist a.log list1.out ""
+
+echo "T range"
+./swiftforeach.py range swiftT localhost "" bash x.sh "" 0 9 1 tmpoutlist a.log list1.out "hello there T"
+
+echo "Call from Galaxy"
+python /nfs2/ketan/galaxy-dist/tools/swift/swiftforeach.py "range" "swiftT" "localhost" "" "sh" "/nfs2/ketan/galaxy-dist/database/files/000/dataset_1.dat" "None" "0" "9" "1" "$HOME/swift-sandbox" "/nfs2/ketan/galaxy-dist/database/files/000/dataset_12.dat" "/nfs2/ketan/galaxy-dist/database/files/000/dataset_13.dat" "hello how are you"
Property changes on: SwiftApps/swift-galaxy/swift/testpy.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the Swift-commit
mailing list