Skip to content

Commit 1a640f6

Browse files
committed
...and Upload too (part 3/3)
This commit concludes the refactoring.
1 parent ae99095 commit 1a640f6

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

app/src/processing/app/Base.java

+24-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import cc.arduino.Compiler;
2626
import cc.arduino.Constants;
2727
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
28+
import cc.arduino.UploaderUtils;
2829
import cc.arduino.contributions.*;
2930
import cc.arduino.contributions.libraries.*;
3031
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
@@ -377,13 +378,29 @@ public Base(String[] args) throws Exception {
377378
}
378379

379380
if (parser.isUploadMode()) {
380-
splash.splashText(tr("Verifying and uploading..."));
381-
// XXX: TODO
382-
//editor.exportHandler.run();
383-
// Error during upload
384-
//if (editor.status.isErr()) {
385-
// System.exit(1);
386-
//}
381+
// Upload
382+
splash.splashText(tr("Uploading..."));
383+
384+
try {
385+
List<String> warnings = new ArrayList<>();
386+
UploaderUtils uploader = new UploaderUtils();
387+
boolean res = uploader.upload(sketch, null, outputFile,
388+
parser.isDoUseProgrammer(),
389+
parser.isNoUploadPort(), warnings);
390+
for (String warning : warnings) {
391+
System.out.println(tr("Warning") + ": " + warning);
392+
}
393+
if (!res) {
394+
throw new Exception();
395+
}
396+
} catch (Exception e) {
397+
// Error during upload
398+
System.out.flush();
399+
System.err.flush();
400+
System.err
401+
.println(tr("An error occurred while uploading the sketch"));
402+
System.exit(1);
403+
}
387404
}
388405

389406
// No errors exit gracefully

0 commit comments

Comments
 (0)