chiark / gitweb /
write HTML results etc. to debug files
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 12:54:09 +0000 (13:54 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 12:54:09 +0000 (13:54 +0100)
src/com/tedpearson/ypp/market/MarketUploader.java

index 6cf889a..e0b4973 100644 (file)
@@ -97,6 +97,13 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
            dtxt.println("progress "+(now - startTime)+"ms "+s);
        }
 
+        private void debug_write_stringdata(String what, String data) throws FileNotFoundException,IOException {
+           if (dtxt==null) return;
+           PrintStream strm = new PrintStream(new File("jarrg-debug-"+what));
+           strm.print(data);
+           strm.close();
+       }
+
         private void progressNote(ProgressMonitor pm, String s) {
            String arb = null;
            if (arbitrageResult != null)
@@ -383,8 +390,6 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
        }
        
        private void error_html(String msg, String html) {
-               //System.err.println("===" + html + "===");
-
                Pattern body = Pattern.compile("<body>(.*)</body>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
                Matcher m = body.matcher(html);
                if (m.find()) {
@@ -533,6 +538,8 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                        progressNote(pm, "Yarrg: Uploading");
                        progresslog("yarrg upload...");
 
+                       debug_write_stringdata("yarrg-deduped.tsv", yarrgdata);
+
                        doneyarrg = runYarrg(yarrgts, oceanName, islandName, yarrgdata);
                        progresslog("yarrg done.");
                }
@@ -985,7 +992,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
        */
        private boolean finishUpload(InputStream in) throws IOException {
                String html = readstreamstring(in);
-               // if (dtxt!=null) dtxt.println(html);
+               debug_write_stringdata("pctb-initial.html", html);
                Matcher m;
 
                Pattern params = Pattern.compile("(?s)<input type=\"hidden\" name=\"action\" value=\"setisland\" />.+?<input type=\"hidden\" name=\"forcereload\" value=\"([^\"]+)\" />.+?<input type=\"hidden\" name=\"filename\" value=\"([^\"]+)\" />");
@@ -1017,10 +1024,10 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                URL get = new URL(PCTB_HOST_URL + "upload.php?action=setisland&ocean=" + oceanNum + "&island="
                        + islandNum + "&forcereload=" + forceReload + "&filename=" + filename);
                String complete = readstreamstring(get.openStream());
+               debug_write_stringdata("pctb-final.html", complete);
                Pattern done = Pattern.compile("Your data has been integrated into the database. Thank you!");
                m = done.matcher(complete);
                if(m.find()) {
-                       if (dtxt!=null) dtxt.println("FILE upload successful!!!");
                        return true;
                } else {
                        error_html("Something was wrong with the final upload parameters!", complete);
@@ -1072,7 +1079,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
            error("<html><h1>Unexpected output from YARRG server</h1>\n" + output);
            return false;
        }
-       if (dtxt!=null) dtxt.println(output);
+       debug_write_stringdata("yarrg-result.txt", output);
        return true;
     }