18/11/19: maintenance de la plate-forme - Interruptions du service gricad-gitlab et perturbations possibles tout au long de la journée.

Commit 7f545c98 authored by Tien's avatar Tien

Add option to save detail log

parent e342b3bb
......@@ -20,6 +20,7 @@ import Checker.Classifier;
import Checker.DistantCalculator;
import Checker.Indexer;
import Checker.Reader;
import Logger.Log;
import TextExtractor.pdfextractor;
import java.io.BufferedReader;
import java.io.File;
......@@ -39,14 +40,15 @@ import java.util.HashMap;
*/
public class ScigenChecker_Local {
private String loglocation;
private String detailloglocation;
// private String loglocation;
// private String detailloglocation;
private String testpath;
private String logtime;
//private String logtime;
private HashMap<String, HashMap<String, Integer>> samples = new HashMap<String, HashMap<String, Integer>>();
private HashMap<String, HashMap<String, Integer>> tests = new HashMap<String, HashMap<String, Integer>>();
private String SamplesFolder;
private HashMap<String, HashMap<String, Double>> distant = new HashMap<String, HashMap<String, Double>>();
private Boolean savedetaillog = false;
private void readconfig() throws FileNotFoundException, IOException {
File conf = new File("config.txt");
......@@ -61,11 +63,11 @@ public class ScigenChecker_Local {
}
if (b[0].equals("Default_log_folder")) {
loglocation = b[1];
Log.loglocation = b[1];
// System.out.println(loglocation);
}
if (b[0].equals("Default_detail_log_folder")) {
detailloglocation = b[1];
Log.detailloglocation = b[1];
//System.out.println(detailloglocation);
}
}
......@@ -77,7 +79,7 @@ public class ScigenChecker_Local {
if (testpath != null) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm dd.MM.yyyy");
Date date = new Date();
logtime = dateFormat.format(date);
Log.logtime = dateFormat.format(date);
try {
Reader reader = new Reader();
......@@ -95,66 +97,29 @@ public class ScigenChecker_Local {
Classifier cl = new Classifier();
String conclusion = cl.classify(distant);
System.out.println(conclusion);
savedetaillog();
savelog(conclusion);
} else {
System.out.println("can not read path to test folder");
}
}
private void savedetaillog() {
File distantout = new File(detailloglocation + logtime + ".xls");
//File distantout = new File(testpath+"/alldistant.xls");
PrintWriter out;
try {
out = new PrintWriter(distantout);
for (String key : distant.keySet()) {
for (String key2 : distant.get(key).keySet()) {
out.println(key + "\t" + key2 + "\t"
+ distant.get(key).get(key2));
}
Log log = new Log();
log.savelog(conclusion);
if (savedetaillog) {
log.savedetaillog(distant);
}
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void savelog(String conclusion) {
File distantout ;
if (!loglocation.equals("logs/")) {
distantout = new File(loglocation);
} else {
distantout = new File(loglocation+ logtime + ".xls");
}
PrintWriter out;
try {
out = new PrintWriter(distantout);
out.write(conclusion);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("can not read path to test folder");
}
}
public void readargs(String[] args) {
for (int i = 0; i < args.length; i += 2) {
for (int i = 0; i < args.length; i += 1) {
// System.out.println(args[i]);
if (args[i].equals("-l")) {
loglocation = args[i + 1];
Log.loglocation = args[i + 1];
}
if (args[i].equals("-c")) {
testpath = args[i + 1];
}
if (args[i].equals("-d")) {
savedetaillog = true;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment