From 68361d77ab3ddbdb575bd8c43ffa61a7b96f6587 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 5 Sep 2010 13:54:09 +0100 Subject: [PATCH] write HTML results etc. to debug files --- .../tedpearson/ypp/market/MarketUploader.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/tedpearson/ypp/market/MarketUploader.java b/src/com/tedpearson/ypp/market/MarketUploader.java index 6cf889a..e0b4973 100644 --- a/src/com/tedpearson/ypp/market/MarketUploader.java +++ b/src/com/tedpearson/ypp/market/MarketUploader.java @@ -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("(.*)", 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).+?.+?"); @@ -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("

Unexpected output from YARRG server

\n" + output); return false; } - if (dtxt!=null) dtxt.println(output); + debug_write_stringdata("yarrg-result.txt", output); return true; } -- 2.30.2