[Swift-commit] r7617 - SwiftApps/swift-galaxy/swift

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Mon Feb 24 21:34:45 CST 2014


Author: ketan
Date: 2014-02-24 21:34:45 -0600 (Mon, 24 Feb 2014)
New Revision: 7617

Added:
   SwiftApps/swift-galaxy/swift/swiftforeachlist.py
   SwiftApps/swift-galaxy/swift/swiftforeachrange.py
Log:
python version

Added: SwiftApps/swift-galaxy/swift/swiftforeachlist.py
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachlist.py	                        (rev 0)
+++ SwiftApps/swift-galaxy/swift/swiftforeachlist.py	2014-02-25 03:34:45 UTC (rev 7617)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+import rpy
+import os
+
+#echo $@ > /tmp/args.txt
+def setwdir():
+    return subprocess.check_output(["mktemp", "-d", "/tmp/swift-gal.XXXX"])
+
+# numeric range
+def main():
+    try:
+        sites=sys.argv[1] # comma separated list of sites
+        swiftargs=sys.argv[2]
+        interpreter=sys.argv[3]
+        executable=sys.argv[4]
+        rstart=sys.argv[5]
+        rend=sys.argv[6]
+        stepsize=sys.argv[7]
+        outloc=sys.argv[8]
+        outlistfile=sys.argv[9]
+        logfile=sys.argv[10]
+        stringargs=sys.argv[11]
+    except:
+        rpy.stop_error('Wrong number or type of args')
+
+    #workout the array only if user adds args else make it blank
+    if stringargs:
+        stringarrayexpr='string stringargs[]='+str(stringargs.split())+';'
+    else:
+        stringarrayexpr='string stringargs[];'
+    
+    fileargs=list()
+    for files in sys.argv[12:]:
+        fileargs.append(files)
+    
+    #workout the array only if user adds file args else make it blank
+    if fileargs: 
+        filearrayexpr='file fileargs[]='+str(fileargs)';'
+    else
+        filearrayexpr='file fileargs[];'
+    fi
+
+    wdir=setwdir()
+    #Build Swift source code
+    f=open(wdir+"/script.swift", 'w');
+    f.write(type file;)
+    
+    f.write('app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[]){')
+    f.write('    '+interpreter+' @_exec _i _stringargs @_fileargs stdout=@_out stderr=@_err;')
+    f.write('}')
+    
+    f.write(stringarrayexpr)
+    f.write(filearrayexpr)
+    
+    f.write('file exec<'+executable+'>;')
+    f.write('foreach i in ['+rstart+':'+rend+':'+stepsize+']{')
+    f.write('    file out <single_file_mapper; file=@strcat("'+outloc+'", "/", i, ".out")>;')
+    f.write('    file err <single_file_mapper; file=@strcat("'+outloc+'", "/", i, ".err")>;')
+    f.write('    (out,err) = anapp(exec, i, stringargs, fileargs);')
+    f.write('}')
+    f.close()
+
+    swift=subprocess.check_output(["which", "swift"])
+    
+    #build site
+    basedir=os.path.dirname(sys.argv[0])
+    subprocess.call([basedir, "/buildsite.sh", "sites", "wdir"])
+    
+    #build config
+    f=open(wdir+"/cf", 'w');
+    f.write('use.provider.staging=true')
+    f.write('wrapperlog.always.transfer=true')
+    f.write('execution.retries=0')
+    f.write('provider.staging.pin.swiftfiles=false')
+    f.write('sitedir.keep=true')
+    f.write('lazy.errors=false')
+    f.close()
+    
+
+    #build tc
+     
+    f=open(wdir+"/tc", 'w');
+    for site in sites.split():
+        f.write(site+' '+interpreter+' '+interpreter)
+    f.close()
+
+    exitcode=subprocess.call([swift, '-sites.file', wdir, '/sites.xml', '-tc.file', wdir, '/tc', '-config', wdir, '/cf', wdir, '/script.swift', swiftargs, '2>logfile'])
+    
+    #`for i in \`find $HOME/swift-sandbox -type f\`; do echo "\`basename $i\` $i"; done`
+    #Populate output file
+    outlist=subprocess.check_output(["find", outloc, "-type", "f", "-iname", "*.out"])
+    f=open(outlistfile)
+    f.write(i);
+    f.close()
+    #dum ditty dum ditty dum dum dum


Property changes on: SwiftApps/swift-galaxy/swift/swiftforeachlist.py
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/swift-galaxy/swift/swiftforeachrange.py
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachrange.py	                        (rev 0)
+++ SwiftApps/swift-galaxy/swift/swiftforeachrange.py	2014-02-25 03:34:45 UTC (rev 7617)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+import rpy
+import os
+
+#echo $@ > /tmp/args.txt
+def setwdir():
+    return subprocess.check_output(["mktemp", "-d", "/tmp/swift-gal.XXXX"])
+
+# numeric range
+def main():
+    try:
+        sites=sys.argv[1] # comma separated list of sites
+        swiftargs=sys.argv[2]
+        interpreter=sys.argv[3]
+        executable=sys.argv[4]
+        rstart=sys.argv[5]
+        rend=sys.argv[6]
+        stepsize=sys.argv[7]
+        outloc=sys.argv[8]
+        outlistfile=sys.argv[9]
+        logfile=sys.argv[10]
+        stringargs=sys.argv[11]
+    except:
+        rpy.stop_error('Wrong number or type of args')
+
+    #workout the array only if user adds args else make it blank
+    if stringargs:
+        stringarrayexpr='string stringargs[]='+str(stringargs.split())+';'
+    else:
+        stringarrayexpr='string stringargs[];'
+    
+    fileargs=list()
+    for files in sys.argv[12:]:
+        fileargs.append(files)
+    
+    #workout the array only if user adds file args else make it blank
+    if fileargs: 
+        filearrayexpr='file fileargs[]='+str(fileargs)';'
+    else
+        filearrayexpr='file fileargs[];'
+    fi
+
+    wdir=setwdir()
+    #Build Swift source code
+    f=open(wdir+"/script.swift", 'w');
+    f.write(type file;)
+    
+    f.write('app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[]){')
+    f.write('    '+interpreter+' @_exec _i _stringargs @_fileargs stdout=@_out stderr=@_err;')
+    f.write('}')
+    
+    f.write(stringarrayexpr)
+    f.write(filearrayexpr)
+    
+    f.write('file exec<'+executable+'>;')
+    f.write('foreach i in ['+rstart+':'+rend+':'+stepsize+']{')
+    f.write('    file out <single_file_mapper; file=@strcat("'+outloc+'", "/", i, ".out")>;')
+    f.write('    file err <single_file_mapper; file=@strcat("'+outloc+'", "/", i, ".err")>;')
+    f.write('    (out,err) = anapp(exec, i, stringargs, fileargs);')
+    f.write('}')
+    f.close()
+
+    swift=subprocess.check_output(["which", "swift"])
+    
+    #build site
+    basedir=os.path.dirname(sys.argv[0])
+    subprocess.call([basedir, "/buildsite.sh", "sites", "wdir"])
+    
+    #build config
+    f=open(wdir+"/cf", 'w');
+    f.write('use.provider.staging=true')
+    f.write('wrapperlog.always.transfer=true')
+    f.write('execution.retries=0')
+    f.write('provider.staging.pin.swiftfiles=false')
+    f.write('sitedir.keep=true')
+    f.write('lazy.errors=false')
+    f.close()
+    
+
+    #build tc
+     
+    f=open(wdir+"/tc", 'w');
+    for site in sites.split():
+        f.write(site+' '+interpreter+' '+interpreter)
+    f.close()
+
+    exitcode=subprocess.call([swift, '-sites.file', wdir, '/sites.xml', '-tc.file', wdir, '/tc', '-config', wdir, '/cf', wdir, '/script.swift', swiftargs, '2>logfile'])
+    
+    #`for i in \`find $HOME/swift-sandbox -type f\`; do echo "\`basename $i\` $i"; done`
+    #Populate output file
+    outlist=subprocess.check_output(["find", outloc, "-type", "f", "-iname", "*.out"])
+    f=open(outlistfile)
+    f.write(i);
+    f.close()
+    #dum ditty dum ditty dum dum dum


Property changes on: SwiftApps/swift-galaxy/swift/swiftforeachrange.py
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list