Changeset 12830 in josm
- Timestamp:
- 2017-09-12T17:23:17+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r12776 r12830 23 23 import java.util.Arrays; 24 24 import java.util.Locale; 25 import java.util.concurrent.ExecutionException; 25 26 26 27 import org.openstreetmap.josm.Main; … … 34 35 35 36 private String osDescription; 36 37 // rpm returns translated string "package %s is not installed\n", can't find a way to force english output38 // translations from https://github.com/rpm-software-management/rpm39 private static final String[] NOT_INSTALLED = {40 "not installed", // en41 "no s'ha instal·lat", // ca42 "尚未安裝", // cmn43 "není nainstalován", // cs44 "ikke installeret", // da45 "nicht installiert", // de46 "ne estas instalita", // eo47 "no está instalado", // es48 "ole asennettu", // fi49 "pas installé", // fr50 "non è stato installato", // it51 "はインストールされていません。", // ja52 "패키지가 설치되어 있지 않습니다", // ko53 "ikke installert", // nb54 "nie jest zainstalowany", // pl55 "não está instalado", // pt56 "не установлен", // ru57 "ni nameščen", // sl58 "nie je nainštalovaný", // sk59 "није инсталиран", // sr60 "inte installerat", // sv61 "kurulu değil", // tr62 "не встановлено", // uk63 "chưa cài đặt gói", // vi64 "未安装软件包", // zh_CN65 "尚未安裝" // zh_TW66 };67 37 68 38 @Override … … 127 97 String dist = Utils.execOutput(Arrays.asList("lsb_release", "-i", "-s")); 128 98 return "Debian".equalsIgnoreCase(dist) || "Ubuntu".equalsIgnoreCase(dist) || "Mint".equalsIgnoreCase(dist); 129 } catch (IOException e) {99 } catch (IOException | ExecutionException | InterruptedException e) { 130 100 // lsb_release is not available on all Linux systems, so don't log at warning level 131 101 Logging.debug(e); … … 157 127 args = new String[] {"rpm", "-q", "--qf", "%{arch}-%{version}", packageName}; 158 128 } 159 String version = Utils.execOutput(Arrays.asList(args)); 160 if (version != null) { 161 for (String notInstalled : NOT_INSTALLED) { 162 if (version.contains(notInstalled)) 163 break; 129 try { 130 String version = Utils.execOutput(Arrays.asList(args)); 131 if (version != null && !version.isEmpty()) { 132 return packageName + ':' + version; 164 133 } 165 return packageName + ':' + version; 134 } catch (ExecutionException e) { 135 // Package does not exist, continue 136 Logging.trace(e); 166 137 } 167 138 } 168 139 } 169 } catch (IOException e) {140 } catch (IOException | InterruptedException e) { 170 141 Logging.warn(e); 171 142 } … … 186 157 return getPackageDetails("openjdk-8-jre", "java-1_8_0-openjdk", "java-1.8.0-openjdk"); 187 158 } else if (home.contains("java-9-openjdk") || home.contains("java-1.9.0-openjdk")) { 188 return getPackageDetails("openjdk-9-jre", "java-1_9_0-openjdk", "java-1.9.0-openjdk" );159 return getPackageDetails("openjdk-9-jre", "java-1_9_0-openjdk", "java-1.9.0-openjdk", "java-9-openjdk"); 189 160 } else if (home.contains("icedtea")) { 190 161 return getPackageDetails("icedtea-bin"); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r12798 r12830 45 45 import java.util.List; 46 46 import java.util.Locale; 47 import java.util.concurrent.ExecutionException; 47 48 import java.util.concurrent.Executor; 48 49 import java.util.concurrent.ForkJoinPool; … … 867 868 * @return the output 868 869 * @throws IOException when there was an error, e.g. command does not exist 869 */ 870 public static String execOutput(List<String> command) throws IOException { 870 * @throws ExecutionException when the return code is != 0. The output is can be retrieved in the exception message 871 * @throws InterruptedException if the current thread is {@linkplain Thread#interrupt() interrupted} by another thread while waiting 872 */ 873 public static String execOutput(List<String> command) throws IOException, ExecutionException, InterruptedException { 871 874 if (Logging.isDebugEnabled()) { 872 875 Logging.debug(join(" ", command)); … … 884 887 } 885 888 } 886 return all != null ? all.toString() : null; 889 String msg = all != null ? all.toString() : null; 890 if (p.waitFor() != 0) { 891 throw new ExecutionException(msg, null); 892 } 893 return msg; 887 894 } 888 895 }
Note:
See TracChangeset
for help on using the changeset viewer.