[Swift-commit] r7061 - SwiftApps/tryswift

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Thu Sep 12 13:58:30 CDT 2013


Author: davidk
Date: 2013-09-12 13:58:30 -0500 (Thu, 12 Sep 2013)
New Revision: 7061

Modified:
   SwiftApps/tryswift/tryswift.php
Log:
Recursive find and sort of swift output files
Disaply size of output files


Modified: SwiftApps/tryswift/tryswift.php
===================================================================
--- SwiftApps/tryswift/tryswift.php	2013-09-12 17:21:20 UTC (rev 7060)
+++ SwiftApps/tryswift/tryswift.php	2013-09-12 18:58:30 UTC (rev 7061)
@@ -9,13 +9,13 @@
 function copy_file($src, $dst) {
    if(!copy($src, $dst)) {
       die("Failed to copy $src to $dst\n");
-   }
+   }   
 }
 
 $source = $_POST['source'];
 $web_directory = "/home/tryswift/tryswift";
 $url = "http://54.212.60.65:8080";
-$cmd = "PATH=/usr/bin:/bin:$PATH /home/tryswift/swift-0.94.1-RC2/bin/swift -sites.file sites.xml -tc.file tc.data script.swift";
+$cmd = "PATH=/usr/bin:/bin:\$PATH /home/tryswift/swift-0.94.1-RC2/bin/swift -sites.file sites.xml -tc.file tc.data script.swift";
 
 # Create directory structure
 $unique = uniqid();
@@ -38,7 +38,7 @@
 $descriptorspec = array(
    0 => array("pipe", "r"),   // stdin is a pipe that the child will read from
    1 => array("pipe", "w"),   // stdout is a pipe that the child will write to
-   2 => array("file", "$dirname/err.txt", "a")    // stderr is a pipe that the child will write to
+   2 => array("pipe", "w")    // stderr is a pipe that the child will write to
 );
 
 echo "<pre>";
@@ -49,7 +49,7 @@
 foreach(explode("\n", $_POST['source']) as $line) {
         print "<tr style=\"background-color:#f6f6f6;\">" .
               "<td style=\"text-align: center; width: 25px\">" . ++$count . "</td>" .
-              "<td style=\"text-align: left; border-left: 1px solid black; padding-left: 10px;\">$line&nbsp</td></tr>\n";
+              "<td style=\"text-align: left; border-left: 1px solid black; padding-left: 10px;\">" . htmlentities($line) . "</td></tr>\n";
 }
 print "</table>\n";
 print "<table cellspacing=\"0\" title=\"Swift Results\">\n";
@@ -72,26 +72,32 @@
 $filehtml = "";
 $print_files=0;
 
-if ($handle = opendir("$web_directory/$unique")) {
-    while (false !== ($entry = readdir($handle))) {
-        if ( $entry != "." && 
-             $entry != ".." &&
-             $entry != "err.txt" &&
-             $entry != "tc.data" &&
-             $entry != "sites.xml" &&
-             $entry != "script.swift" &&
-             substr($entry, -2) != ".d" &&
-             substr($entry, -4) != ".kml" &&
-             substr($entry, -7) != ".swiftx" &&
-             substr($entry, -4) != ".log"
-        ) {
-           if($print_files == 0) { $print_files=1; }
-           $filehtml .= "<tr style=\"background-color:#f6f6f6;\">" .
+# Sorted, recursive list of all files
+$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("$web_directory/$unique"));
+$paths = array();
+while($iterator->valid()) {
+  if($iterator->isFile()) {
+     $paths[] = $iterator->getSubPathname();
+   }
+   $iterator->next();
+}
+sort($paths);
+
+foreach ($paths as $file) {
+      if(  $file != "err.txt" &&
+           $file != "tc.data" &&
+           $file != "sites.xml" &&
+           $file != "script.swift" &&
+           substr($file, -2) != ".d" &&
+           substr($file, -4) != ".kml" &&
+           substr($file, -7) != ".swiftx" &&
+           substr($file, -4) != ".log"
+	) {
+             if($print_files == 0) { $print_files=1; }
+             $filehtml .= "<tr style=\"background-color:#f6f6f6;\">" .
                  "<td style=\"text-align: left; border-left: 0px solid black; padding-left: 10px;\">" .
-                 "<a href=\"$url/$unique/$entry\">$entry</a>&nbsp</td></tr>\n";
-        }
-    }
-    closedir($handle);
+                 "<a href=\"$url/$unique/$file\">$file</a> [" . filesize($file) . " bytes]</td></tr>\n";
+         }
 }
 
 if($print_files) {




More information about the Swift-commit mailing list