Skip to content
Snippets Groups Projects
Commit ad9ace9e authored by Unknown's avatar Unknown
Browse files

formatStatistics: adding a try/catch block

parent 6e79bbf2
No related branches found
No related tags found
1 merge request!2Format statistics
...@@ -2,6 +2,7 @@ package cz.it4i.fiji.haas_spim_benchmark.core; ...@@ -2,6 +2,7 @@ package cz.it4i.fiji.haas_spim_benchmark.core;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
...@@ -185,30 +186,47 @@ public class BenchmarkJobManager { ...@@ -185,30 +186,47 @@ public class BenchmarkJobManager {
} }
private Predicate<String> downloadFinishedData(String filePattern) { private static Predicate<String> downloadFinishedData(String filePattern) {
return name -> { return name -> {
Path p = Paths.get(name); Path path = getPathSafely(name);
String fileName = p.getFileName().toString(); if (path == null)
return false;
String fileName = path.getFileName().toString();
return fileName.startsWith(filePattern) && fileName.endsWith("h5") || fileName.equals(filePattern + ".xml") return fileName.startsWith(filePattern) && fileName.endsWith("h5") || fileName.equals(filePattern + ".xml")
|| fileName.equals("benchmark_result.csv"); || fileName.equals("benchmark_result.csv");
}; };
} }
static private Predicate<String> downloadStatistics() { private static Predicate<String> downloadStatistics() {
return name -> { return name -> {
Path p = Paths.get(name); Path path = getPathSafely(name);
String fileName = p.getFileName().toString(); if (path == null)
return false;
String fileName = path.getFileName().toString();
return fileName.equals("benchmark_result.csv"); return fileName.equals("benchmark_result.csv");
}; };
} }
private Predicate<String> downloadFailedData() { private static Predicate<String> downloadFailedData() {
return name -> { return name -> {
Path p = Paths.get(name); Path path = getPathSafely(name);
return p.getFileName().toString().startsWith("snakejob.") if (path == null)
|| p.getParent().getFileName().toString().equals("logs"); return false;
return path.getFileName().toString().startsWith("snakejob.")
|| path.getParent().getFileName().toString().equals("logs");
}; };
} }
private static Path getPathSafely(String name) {
try {
return Paths.get(name);
} catch(InvalidPathException ex) {
return null;
}
}
private static Settings constructSettingsFromParams(BenchmarkSPIMParameters params) { private static Settings constructSettingsFromParams(BenchmarkSPIMParameters params) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment