Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/InstallServerSapfor.java

130 lines
5.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.Machine.MachineType;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.User.User;
import ProjectData.LanguageName;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import java.util.Date;
import java.util.Vector;
public class InstallServerSapfor extends ConnectionPass<Object> {
boolean result;
ServerSapfor serverSapfor;
String version_text;
@Override
public String getIconPath() {
return "/icons/DownloadAll.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
public void Connect() throws Exception {
machine = new Machine("Ubuntu", Global.properties.ServerAddress, Global.properties.ServerUserSHHPort, MachineType.Server);
user = new User(Global.properties.ServerUserName, "mprit_2011", "");
super.Connect();
}
@Override
protected boolean canStart(Object... args) {
result = false;
version_text = "";
serverSapfor = null;
return true;
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void ServerAction() throws Exception {
RemoteFile testingSystemHome = new RemoteFile(user.connection.sftpChannel.pwd(), "_testing_system", true);
RemoteFile repo = new RemoteFile(testingSystemHome.full_name, "Repo", true);
RemoteFile repoSapforHome = new RemoteFile(repo.full_name + Constants.SAPFOR_REPOSITORY_BIN, true);
//--
ShowMessage1("Синхронизация ветви DVM...");
user.connection.performScript(repo,
"svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.DVM_REPOSITORY + "\n"
);
ShowMessage1("Синхронизация ветви SAPFOR...");
user.connection.performScript(repo,
"svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.SAPFOR_REPOSITORY + "\n"
);
ShowMessage1("Сборка SAPFOR...");
//-
RemoteFile repo_bin = new RemoteFile(repoSapforHome.full_name, "Sapfor_F");
if (user.connection.Exists(repo_bin))
user.connection.sftpChannel.rm(repo_bin.full_name);
//--
user.connection.performScript(repoSapforHome, "cmake ../", "make -j 4");
RemoteFile repoSapfor = new RemoteFile(repoSapforHome, "Sapfor_F");
result = user.connection.Exists(repoSapfor);
if (result) {
RemoteFile sapforsDirectory = new RemoteFile(testingSystemHome.full_name, "Sapfors", true);
//создать папку. Для того чтобы скопировать из репозитория.
RemoteFile sapforHome = new RemoteFile(sapforsDirectory.full_name, Utils.getDateName("sapfor"));
user.connection.MKDIR(sapforHome);
RemoteFile sapforBin = new RemoteFile(sapforHome, "Sapfor_F");
user.connection.copy(repo_bin, sapforBin);
//-->>>
serverSapfor = new ServerSapfor();
serverSapfor.home_path = sapforHome.full_name;
serverSapfor.call_command = sapforBin.full_name;
serverSapfor.languageName = LanguageName.fortran;
serverSapfor.buildDate = new Date().getTime();
///--->>
RemoteFile version =new RemoteFile(sapforHome, "version.txt");
user.connection.ShellCommand(serverSapfor.getVersionCommand()+" 1>"+Utils.DQuotes(version.full_name));
if (user.connection.Exists(version)){
String raw = user.connection.readFromFile(version);
String[] data = raw.split(" ");
if (data.length >= 4) serverSapfor.version = data[3].replace(",", "");
}
//---
}
}
@Override
protected void performFinish() throws Exception {
super.performFinish();
new TestingSystemPass() {
@Override
public String getDescription() {
return "Рассылка выходных файлов сборки SAPFOR";
}
@Override
protected void ServerAction() throws Exception {
Vector<String> info = new Vector<>();
info.add(result ? serverSapfor.version : "?");
info.add(result ? "Успешно" : "С ошибками");
Command(new ServerExchangeUnit_2021(ServerCode.EmailSapforAssembly,
Current.getAccount().email,
info
));
}
}.Do();
}
@Override
protected boolean validate() {
return result;
}
@Override
protected void showFail() throws Exception {
Log.Writeln_("Файл [SAPFOR_F] не найден!");
}
@Override
protected void performDone() throws Exception {
passes.get(PassCode_2021.PublishServerSapfor).Do(serverSapfor);
}
}