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

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Thu Feb 27 17:23:51 CST 2014


Author: ketan
Date: 2014-02-27 17:23:51 -0600 (Thu, 27 Feb 2014)
New Revision: 7622

Modified:
   SwiftApps/swift-galaxy/swift/swiftforeachrange.py
Log:
fix newline issues in swift source

Modified: SwiftApps/swift-galaxy/swift/swiftforeachrange.py
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachrange.py	2014-02-27 15:43:06 UTC (rev 7621)
+++ SwiftApps/swift-galaxy/swift/swiftforeachrange.py	2014-02-27 23:23:51 UTC (rev 7622)
@@ -27,12 +27,16 @@
     except:
         #rpy.stop_error('Wrong number or type of args')
         sys.exit(1)
+    
+    print sites
+    print swiftargs
+    print interpreter
 
     #workout the array only if user adds args else make it blank
     if stringargs:
-        stringarrayexpr='string stringargs[]='+str(stringargs.split())+';'
+        stringarrayexpr="string stringargs[]="+str(stringargs.split())+";\n"
     else:
-        stringarrayexpr='string stringargs[];'
+        stringarrayexpr="string stringargs[];\n"
     
     fileargs=list()
     for files in sys.argv[12:]:
@@ -40,31 +44,31 @@
     
     #workout the array only if user adds file args else make it blank
     if fileargs: 
-        filearrayexpr='file fileargs[]='+str(fileargs)+';'
+        filearrayexpr="file fileargs[]="+str(fileargs)+";\n"
     else:
-        filearrayexpr='file fileargs[];'
+        filearrayexpr="file fileargs[];\n"
 
     wdir=setwdir().rstrip()
     #Build Swift source code
     f=open(wdir+"/script.swift", 'w');
-    f.write('type file;')
+    f.write("type file; \n")
     
-    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("app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[]){ \n")
+    f.write("    "+interpreter+" @_exec _i _stringargs @_fileargs stdout=@_out stderr=@_err; \n")
+    f.write("}\n")
     
     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.write("file exec<'"+executable+"'>;\n")
+    f.write("foreach i in ["+rstart+":"+rend+":"+stepsize+"]{\n")
+    f.write("    file out <single_file_mapper; file=@strcat("+outloc+", '/', i, '.out')>;\n")
+    f.write("    file err <single_file_mapper; file=@strcat('"+outloc+"', '/', i, '.err')>;\n")
+    f.write("    (out,err) = anapp(exec, i, "+stringargs+", "+",".join(fileargs)+");\n")
+    f.write("}\n")
     f.close()
 
-    swift=subprocess.check_output(["which", "swift"])
+    swift=subprocess.check_output(["which", "swift"]).rstrip()
     
     #build site
     if os.path.dirname(sys.argv[0]):
@@ -92,16 +96,15 @@
         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'])
+    #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.write(outlist);
     f.close()
     #dum ditty dum ditty dum dum dum
-'''
+
 if __name__=='__main__':
     main()




More information about the Swift-commit mailing list