mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Refactored Uploader.stringContainsOneOf and StringMatchers.wildcardMatch into StringUitils
SSHUploader: filtered out some platform specific files
This commit is contained in:
@ -31,6 +31,7 @@ import processing.app.Preferences;
|
|||||||
import processing.app.debug.MessageConsumer;
|
import processing.app.debug.MessageConsumer;
|
||||||
import processing.app.debug.MessageSiphon;
|
import processing.app.debug.MessageSiphon;
|
||||||
import processing.app.debug.RunnerException;
|
import processing.app.debug.RunnerException;
|
||||||
|
import processing.app.helpers.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -60,15 +61,6 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
"avrdude: error: buffered memory access not supported.");
|
"avrdude: error: buffered memory access not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean stringContainsOneOf(String input, List<String> listOfStrings) {
|
|
||||||
for (String string : listOfStrings) {
|
|
||||||
if (input.contains(string)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String error;
|
private String error;
|
||||||
protected boolean verbose;
|
protected boolean verbose;
|
||||||
protected boolean notFoundError;
|
protected boolean notFoundError;
|
||||||
@ -126,7 +118,7 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
|
|
||||||
public void message(String s) {
|
public void message(String s) {
|
||||||
// selectively suppress a bunch of avrdude output for AVR109/Caterina that should already be quelled but isn't
|
// selectively suppress a bunch of avrdude output for AVR109/Caterina that should already be quelled but isn't
|
||||||
if (!verbose && stringContainsOneOf(s, STRINGS_TO_SUPPRESS)) {
|
if (!verbose && StringUtils.stringContainsOneOf(s, STRINGS_TO_SUPPRESS)) {
|
||||||
s = "";
|
s = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +137,7 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
error = _("Device is not responding, check the right serial port is selected or RESET the board right before exporting");
|
error = _("Device is not responding, check the right serial port is selected or RESET the board right before exporting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stringContainsOneOf(s, AVRDUDE_PROBLEMS)) {
|
if (StringUtils.stringContainsOneOf(s, AVRDUDE_PROBLEMS)) {
|
||||||
error = _("Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.");
|
error = _("Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,20 @@ import processing.app.Preferences;
|
|||||||
import processing.app.debug.RunnerException;
|
import processing.app.debug.RunnerException;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
|
import processing.app.helpers.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
public class SSHUploader extends Uploader {
|
public class SSHUploader extends Uploader {
|
||||||
|
|
||||||
|
private static final List<String> FILES_NOT_TO_COPY = Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX");
|
||||||
|
|
||||||
private final String ipAddress;
|
private final String ipAddress;
|
||||||
|
|
||||||
public SSHUploader(String port) {
|
public SSHUploader(String port) {
|
||||||
@ -142,6 +147,7 @@ public class SSHUploader extends Uploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
|
if (!StringUtils.stringContainsOneOf(file.getName(), FILES_NOT_TO_COPY)) {
|
||||||
if (file.isDirectory() && file.canExecute()) {
|
if (file.isDirectory() && file.canExecute()) {
|
||||||
scp.startFolder(file.getName());
|
scp.startFolder(file.getName());
|
||||||
recursiveSCP(file, scp);
|
recursiveSCP(file, scp);
|
||||||
@ -151,6 +157,7 @@ public class SSHUploader extends Uploader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean burnBootloader() throws RunnerException {
|
public boolean burnBootloader() throws RunnerException {
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
package processing.app.helpers;
|
package processing.app.helpers;
|
||||||
|
|
||||||
public class StringMatchers {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StringUtils {
|
||||||
|
|
||||||
|
public static boolean stringContainsOneOf(String input, List<String> listOfStrings) {
|
||||||
|
for (String string : listOfStrings) {
|
||||||
|
if (input.contains(string)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to match <b>input</b> with <b>pattern</b>. The pattern can use the
|
* Tries to match <b>input</b> with <b>pattern</b>. The pattern can use the
|
||||||
* "*" and "?" globs to match any-char-sequence and any-char respectively.
|
* "*" and "?" globs to match any-char-sequence and any-char respectively.
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input The string to be checked
|
||||||
* The string to be checked
|
* @param pattern The pattern to match
|
||||||
* @param pattern
|
|
||||||
* The pattern to match
|
|
||||||
* @return <b>true</b> if the <b>input</b> matches the <b>pattern</b>,
|
* @return <b>true</b> if the <b>input</b> matches the <b>pattern</b>,
|
||||||
* <b>false</b> otherwise.
|
* <b>false</b> otherwise.
|
||||||
*/
|
*/
|
||||||
@ -17,5 +26,4 @@ public class StringMatchers {
|
|||||||
String regex = pattern.replace("?", ".?").replace("*", ".*?");
|
String regex = pattern.replace("?", ".?").replace("*", ".*?");
|
||||||
return input.matches(regex);
|
return input.matches(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static processing.app.helpers.StringMatchers.wildcardMatch;
|
import static processing.app.helpers.StringUtils.wildcardMatch;
|
||||||
|
|
||||||
public class Library {
|
public class Library {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user