-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
executable file
·71 lines (64 loc) · 2.26 KB
/
Copy pathMain.java
File metadata and controls
executable file
·71 lines (64 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* *Main*
*
* RU Запуск Sh скриптов необходимых для пересборки venv и запуска
* ----------------------------------------------------------------
* En Running Sh scripts required to rebuild venv and run
*
*/
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.File;
public class Main
{
public static void main(String[] args)
{
String nowPath = new File("").getAbsolutePath();
String lastPath = "";
try
{
lastPath = new String(Files.readAllBytes(Paths.get("path.conf")));
}
catch (Exception e)
{
try
{
Files.write(Paths.get("path.conf"), nowPath.getBytes());
}
catch (Exception writeException){}
}
if (!nowPath.equals(lastPath))
{
System.out.println("Изменение директории");
try
{
// Выполняем скрипт Rebuild_Libs.sh
ProcessBuilder rebuildProcess = new ProcessBuilder("./Rebuild_Libs.sh");
rebuildProcess.inheritIO();
rebuildProcess.start().waitFor(); // Ждем завершения процесса
try
{
Files.write(Paths.get("path.conf"), nowPath.getBytes());
}
catch (Exception writeException){}
StartSh("Recognizer.sh", "Glava.sh");
}
catch (IOException | InterruptedException e){}
}
else{StartSh("Recognizer.sh", "Glava.sh");}
}
private static void StartSh(String scriptRecognizer, String scriptGlava)
{
//Процесс для Recognizer
ProcessBuilder builderRecognizer = new ProcessBuilder("bash", "./Sh/Start/" + scriptRecognizer);
builderRecognizer.inheritIO(); // Чтобы видеть вывод скрипта в консоли
//Процесс для Glava
ProcessBuilder builderGlava = new ProcessBuilder("bash", "./Sh/Start/" + scriptGlava);
try
{
builderRecognizer.start();
builderGlava.start();
}
catch (IOException e){}
}
}