chiark / gitweb /
Do not do PCTB stuff at all if we're not doing PCTB; make progress messages clearer...
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Sep 2010 15:59:41 +0000 (16:59 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Sep 2010 15:59:41 +0000 (16:59 +0100)
src/com/tedpearson/ypp/market/MarketUploader.java

index 4cd16dde3c648005fddd61d364c5e3f12f64ab71..7632c01f1221bd8ac3b27fd0c1242bcaeca3fbe6 100644 (file)
@@ -402,7 +402,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                ArrayList<ArrayList<String>> data = getData(t);
 
                if (uploadToYarrg && yarrgts != null) {
-                       pm.setNote("Preparing data for Yarrg");
+                       pm.setNote("Yarrg: Preparing data");
                        pm.setProgress(10);
 
                        StringBuilder yarrgsb = new StringBuilder();
@@ -422,7 +422,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
 
                        yarrgdata = yarrgsb.toString();
 
-                       pm.setNote("Uploading to Yarrg");
+                       pm.setNote("Yarrg: Uploading");
 
                        if (islandName != null) {
                                doneyarrg = runYarrg(yarrgts, oceanName, islandName, yarrgdata);
@@ -431,53 +431,53 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                        }
                }
 
-               pm.setNote("Getting stall names");
-               pm.setProgress(20);
-               if(pm.isCanceled()) {
+               if (uploadToPCTB) {
+                   pm.setNote("PCTB: Getting stall names");
+                   pm.setProgress(20);
+                   if(pm.isCanceled()) {
                        return;
-               }
-               TreeSet<Offer> buys = new TreeSet<Offer>();
-               TreeSet<Offer> sells = new TreeSet<Offer>();
-               LinkedHashMap<String,Integer> stallMap = getStallMap(data);
-               pm.setProgress(40);
-               pm.setNote("Sorting offers");
-               if(pm.isCanceled()) {
+                   }
+                   TreeSet<Offer> buys = new TreeSet<Offer>();
+                   TreeSet<Offer> sells = new TreeSet<Offer>();
+                   LinkedHashMap<String,Integer> stallMap = getStallMap(data);
+                   pm.setProgress(40);
+                   pm.setNote("PCTB: Sorting offers");
+                   if(pm.isCanceled()) {
                        return;
-               }
-               // get commod map
+                   }
+                   // get commod map
                
-               HashMap<String,Integer> commodMap = getCommodMap();
-               if(commodMap == null) {
+                   HashMap<String,Integer> commodMap = getCommodMap();
+                   if(commodMap == null) {
                        return;
-               }
-               int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap);
-               //println(buys.toString());
-               //System.out.println(sells);
-               //System.out.println("\n\n\n"+buys);
-
-               if (uploadToPCTB) {
-                       ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                       pm.setProgress(60);
-                       pm.setNote("Sending data");
-                       if(pm.isCanceled()) {
-                               return;
-                       }
-                       GZIPOutputStream out = new GZIPOutputStream(outStream);
-                       //FileOutputStream out = new FileOutputStream(new File("output.text"));
-                       DataOutputStream dos = new DataOutputStream(out);
-                       dos.writeBytes("005y\n");
-                       dos.writeBytes(stallMap.size()+"\n");
-                       dos.writeBytes(getAbbrevStallList(stallMap));
-                       writeBuySellOffers(buys,sells,offerCount,out);
-                       out.finish();
-                       InputStream in = sendInitialData(new ByteArrayInputStream(outStream.toByteArray()));
-                       if (in == null) return;
-                       pm.setProgress(80);
-                       if(pm.isCanceled()) {
-                               return;
-                       }
-                       pm.setNote("Waiting for PCTB...");
-                       donepctb = finishUpload(in);
+                   }
+                   int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap);
+                   //println(buys.toString());
+                   //System.out.println(sells);
+                   //System.out.println("\n\n\n"+buys);
+
+                   ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+                   pm.setProgress(60);
+                   pm.setNote("PCTB: Sending data");
+                   if(pm.isCanceled()) {
+                       return;
+                   }
+                   GZIPOutputStream out = new GZIPOutputStream(outStream);
+                   //FileOutputStream out = new FileOutputStream(new File("output.text"));
+                   DataOutputStream dos = new DataOutputStream(out);
+                   dos.writeBytes("005y\n");
+                   dos.writeBytes(stallMap.size()+"\n");
+                   dos.writeBytes(getAbbrevStallList(stallMap));
+                   writeBuySellOffers(buys,sells,offerCount,out);
+                   out.finish();
+                   InputStream in = sendInitialData(new ByteArrayInputStream(outStream.toByteArray()));
+                   if (in == null) return;
+                   pm.setProgress(80);
+                   if(pm.isCanceled()) {
+                       return;
+                   }
+                   pm.setNote("PCTB: Waiting ...");
+                   donepctb = finishUpload(in);
                }
                pm.setProgress(100);