From 1a640f61394b19549996cf97c8c02b267281b008 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 7 Nov 2016 17:34:13 +0100 Subject: [PATCH] ...and Upload too (part 3/3) This commit concludes the refactoring. --- app/src/processing/app/Base.java | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 43ace0eee..a5d9787c1 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -25,6 +25,7 @@ package processing.app; import cc.arduino.Compiler; import cc.arduino.Constants; import cc.arduino.UpdatableBoardsLibsFakeURLsHandler; +import cc.arduino.UploaderUtils; import cc.arduino.contributions.*; import cc.arduino.contributions.libraries.*; import cc.arduino.contributions.libraries.ui.LibraryManagerUI; @@ -377,13 +378,29 @@ public class Base { } if (parser.isUploadMode()) { - splash.splashText(tr("Verifying and uploading...")); - // XXX: TODO - //editor.exportHandler.run(); - // Error during upload - //if (editor.status.isErr()) { - // System.exit(1); - //} + // Upload + splash.splashText(tr("Uploading...")); + + try { + List warnings = new ArrayList<>(); + UploaderUtils uploader = new UploaderUtils(); + boolean res = uploader.upload(sketch, null, outputFile, + parser.isDoUseProgrammer(), + parser.isNoUploadPort(), warnings); + for (String warning : warnings) { + System.out.println(tr("Warning") + ": " + warning); + } + if (!res) { + throw new Exception(); + } + } catch (Exception e) { + // Error during upload + System.out.flush(); + System.err.flush(); + System.err + .println(tr("An error occurred while uploading the sketch")); + System.exit(1); + } } // No errors exit gracefully