рефакторинг. Исправлен баг. если прервать локальную задачу, не удалялся файл interrupt.
This commit is contained in:
2024-01-08 20:37:16 +03:00
parent 5baf2154e2
commit fce61bf55a
26 changed files with 281 additions and 582 deletions

View File

@@ -4,7 +4,7 @@ import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.User.User;
import files.ConnectionPass;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import com.jcraft.jsch.ChannelSftp;
import java.io.File;
@@ -20,18 +20,14 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
return true;
}
@Override
protected boolean needsInitialize() {
return false;
}
@Override
protected void ServerAction() throws Exception {
String workspace_path = Utils.toU(Paths.get(sftpChannel.getHome(),Global.properties.BackupWorkspace).toString());
String workspace_path = Utils.toU(Paths.get(user.connection.sftpChannel.getHome(), Global.properties.BackupWorkspace).toString());
RemoteFile workspace = new RemoteFile(workspace_path, true);
tryMKDir(workspace);
user.connection.MKDIR(workspace);
RemoteFile dst = new RemoteFile(workspace.full_name, src.getName());
putSingleFile(src, dst);
user.connection.putSingleFile(src, dst);
//-теперь, удалить старые файлы.
Vector<ChannelSftp.LsEntry> raw_files = sftpChannel.ls(workspace.full_name);
Vector<ChannelSftp.LsEntry> raw_files = user.connection.sftpChannel.ls(workspace.full_name);
Vector<RemoteFile> files = new Vector<>();
for (ChannelSftp.LsEntry file : raw_files) {
if (!file.getAttrs().isDir()) {
@@ -44,7 +40,7 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
files.sort((o1, o2) -> (int) (o2.updateTime - o1.updateTime));
for (int i = 2; i < files.size(); ++i) {
System.out.println(files.get(i).full_name + ":" + files.get(i).updateTime);
sftpChannel.rm(files.get(i).full_name);
user.connection.sftpChannel.rm(files.get(i).full_name);
}
//--------------
}

View File

@@ -70,6 +70,7 @@ public class Compile extends Pass_2021<db_project_info> {
subpass = passes.get(PassCode_2021.LinuxLocalCompilation);
break;
case Undefined:
case MVS_cluster:
throw new PassException("Компиляция не реализована для типа машины " + Utils.DQuotes(Current.getMachine().type));
default:
subpass = passes.get(PassCode_2021.RemoteCompilation);

View File

@@ -24,19 +24,19 @@ public class DownloadProject extends CurrentConnectionPass {
System.out.println(Current.getRemoteFile());
remote_archive = new RemoteFile(src.full_name, src.name + ".zip", false);
local_archive = Utils.getTempFileName(remote_archive.name);
if ((getFileKBSize(src.full_name)) <= maxSize) {
if ((user.connection.getFileKBSize(src.full_name)) <= maxSize) {
ShowMessage2("Запаковка папки проекта..");
Command(
user.connection.Command(
"cd " + Utils.DQuotes(src.full_name),
"zip -r " + Utils.DQuotes(remote_archive.full_name) + " ./"
);
// try {
ShowMessage2("Загрузка проекта..");
getSingleFile(remote_archive.full_name, local_archive.getAbsolutePath());
user.connection.getSingleFile(remote_archive.full_name, local_archive.getAbsolutePath());
// } catch (Exception ex) {
// throw new PassException("Ошибка загрузки");
// }
sftpChannel.rm(remote_archive.full_name);
user.connection.sftpChannel.rm(remote_archive.full_name);
} else throw new PassException("Размер проекта превышает " + maxSize + " KB.\n");
} else {
//диалога не вышло, сбрасываем файл.

View File

@@ -8,7 +8,7 @@ import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import Visual_DVM_2021.Passes.PassCode_2021;
import files.ConnectionPass;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import java.util.Date;
@@ -39,39 +39,39 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
return true;
}
@Override
protected boolean needsInitialize() {
return false;
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void ServerAction() throws Exception {
RemoteFile testingSystemHome = new RemoteFile(sftpChannel.pwd(), "_testing_system", true);
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...");
ShellCommand("cd " + Utils.DQuotes(repo.full_name), "svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.DVM_REPOSITORY + "\n");
user.connection.performScript(repo,
"svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.DVM_REPOSITORY + "\n"
);
ShowMessage1("Синхронизация ветви SAPFOR...");
ShellCommand("cd " + Utils.DQuotes(repo.full_name), "svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.SAPFOR_REPOSITORY + "\n");
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 (Exists(repo_bin))
sftpChannel.rm(repo_bin.full_name);
if (user.connection.Exists(repo_bin))
user.connection.sftpChannel.rm(repo_bin.full_name);
//--
performScript(repoSapforHome, "cmake ../", "make -j 4");
user.connection.performScript(repoSapforHome, "cmake ../", "make -j 4");
RemoteFile repoSapfor = new RemoteFile(repoSapforHome, "Sapfor_F");
result = Exists(repoSapfor);
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"));
tryMKDir(sapforHome);
user.connection.MKDIR(sapforHome);
RemoteFile sapforBin = new RemoteFile(sapforHome, "Sapfor_F");
copy(repo_bin, sapforBin);
user.connection.copy(repo_bin, sapforBin);
//-->>>
serverSapfor = new ServerSapfor();
serverSapfor.home_path = sapforHome.full_name;
@@ -79,9 +79,13 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
serverSapfor.languageName = LanguageName.fortran;
serverSapfor.buildDate = new Date().getTime();
///--->>
String raw = ShellCommand(serverSapfor.getVersionCommand());
String[] data = raw.split(" ");
if (data.length >= 4) serverSapfor.version = data[3].replace(",", "");
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(",", "");
}
//---
}
}

View File

@@ -5,7 +5,6 @@ import Common.Utils.Utils;
import GlobalData.User.User;
import GlobalData.User.UserState;
import Visual_DVM_2021.Passes.ProcessPass;
import files.ConnectionPass;
import org.apache.commons.io.FileUtils;
import java.io.File;
@@ -38,13 +37,13 @@ public class LocalInitaliseUser extends ProcessPass<User> {
PerformScript(
String.join("\n",
"cd " + Utils.DQuotes(target.getLocalModulesDir()),
"g++ " + ConnectionPass.starter_code + " -o " + ConnectionPass.starter,
"chmod 0777 " + ConnectionPass.starter
"g++ starter -o starter",
"chmod 0777 starter"
));
PerformScript(String.join("\n",
"cd " + Utils.DQuotes(target.getLocalModulesDir()),
"g++ " + ConnectionPass.launcher_code + " -o " + ConnectionPass.launcher,
"chmod 0777 " + ConnectionPass.launcher
"g++ launcher.cpp -o launcher",
"chmod 0777 launcher"
));
}
//-

View File

@@ -4,10 +4,10 @@ import Common.Current;
import Common.Utils.Utils;
import GlobalData.RemoteFile.RemoteFile;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.SSH.ConnectionPass_2023;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import java.util.Vector;
public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
public class RemoteInitialiseUser extends ConnectionPass<RemoteFile> {
RemoteFile modulesDirectory;
@Override
protected boolean needsAnimation() {

View File

@@ -1,4 +1,6 @@
package Visual_DVM_2021.Passes.All;
import Common.Utils.Utils;
import GlobalData.RemoteFile.RemoteFile;
import Visual_DVM_2021.Passes.SSH.CurrentConnectionPass;
public class RemoteSingleCommand extends CurrentConnectionPass<String> {
String command = "";
@@ -12,6 +14,10 @@ public class RemoteSingleCommand extends CurrentConnectionPass<String> {
}
@Override
protected void ServerAction() throws Exception {
target = ShellCommand(command);
RemoteFile file = new RemoteFile(user.connection.sftpChannel.getHome(), Utils.getDateName("out"));
user.connection.ShellCommand(command+" 1>"+Utils.DQuotes(file.full_name));
if (user.connection.Exists(file)){
target = user.connection.readFromFile(file);
}
}
}

View File

@@ -64,10 +64,13 @@ public class Run extends Pass_2021<db_project_info> {
subpass = passes.get(PassCode_2021.LinuxLocalRun);
break;
case Undefined:
case MVS_cluster:
throw new PassException("Запуск не реализован для типа машины " + Utils.DQuotes(Current.getMachine().type));
/*
case MVS_cluster:
subpass = passes.get(PassCode_2021.MVSRun);
break;
*/
default:
subpass = passes.get(PassCode_2021.ServerRun);
break;