[Major] fully tested new folder arrangement. the programSettings.txt will be saved on current directory, can run without analysis path

This commit is contained in:
Ryan Tang 2024-07-01 17:56:03 -04:00
parent cab61e0d61
commit 2e287f4496

View File

@ -2030,6 +2030,10 @@ void MainWindow::CreateNewExperiment(const QString newExpName){
runID = -1; runID = -1;
elogID = 0; elogID = 0;
expDataPath = masterExpDataPath + "/" + expName;
rawDataPath = expDataPath + "/data_raw/";
rootDataPath = expDataPath + "/root_data/";
CreateRawDataFolder(); CreateRawDataFolder();
WriteExpNameSh(); WriteExpNameSh();
@ -2051,6 +2055,19 @@ void MainWindow::CreateNewExperiment(const QString newExpName){
} }
} }
//check if .gitignore exist
QFile gitIgnore(analysisPath + "/.gitignore");
if( !gitIgnore.exists() ) {
if( gitIgnore.open(QIODevice::Text | QIODevice::WriteOnly) ){
gitIgnore.write("data_raw\n");
gitIgnore.write("root_data\n");
gitIgnore.write("*.root\n");
gitIgnore.write("*.d\n");
gitIgnore.write("*.so\n");
gitIgnore.close();
}
}
//----- create git branch //----- create git branch
if( useGit ){ if( useGit ){
QProcess git; QProcess git;
@ -2127,7 +2144,13 @@ void MainWindow::ChangeExperiment(const QString newExpName){
LogMsg("============================================="); LogMsg("=============================================");
LogMsg("Swicted to branch : <b>" + expName + "</b>"); LogMsg("Swicted to branch : <b>" + expName + "</b>");
expDataPath = masterExpDataPath + "/" + newExpName;
rawDataPath = expDataPath + "/data_raw/";
rootDataPath = expDataPath + "/root_data/";
CreateRawDataFolder(); CreateRawDataFolder();
CreateDataSymbolicLink();
SaveProgramSettings();
LoadExpNameSh(); LoadExpNameSh();
if( influx ){ if( influx ){
@ -2144,7 +2167,7 @@ void MainWindow::CreateRawDataFolder(){
//----- create data folder //----- create data folder
QDir dir(rawDataPath); QDir dir(rawDataPath);
if( !dir.exists()){ if( !dir.exists()){
if( dir.mkdir(rawDataPath)){ if( dir.mkpath(rawDataPath)){
LogMsg("Created folder <b>" + rawDataPath + "</b> for storing raw data." ); LogMsg("Created folder <b>" + rawDataPath + "</b> for storing raw data." );
}else{ }else{
LogMsg("<font style=\"color:red;\"><b>" + rawDataPath + "</b> cannot be created. Access right problem? </font>" ); LogMsg("<font style=\"color:red;\"><b>" + rawDataPath + "</b> cannot be created. Access right problem? </font>" );
@ -2156,7 +2179,7 @@ void MainWindow::CreateRawDataFolder(){
//----- create root data folder //----- create root data folder
QDir rootDir(rootDataPath); QDir rootDir(rootDataPath);
if( !rootDir.exists()) { if( !rootDir.exists()) {
if( rootDir.mkdir(rootDataPath) ){ if( rootDir.mkpath(rootDataPath) ){
LogMsg("Created folder <b>" + rootDataPath + "</b> for storing root files."); LogMsg("Created folder <b>" + rootDataPath + "</b> for storing root files.");
}else{ }else{
LogMsg("<font style=\"color:red;\"><b>" + rootDataPath + "</b> cannot be created. Access right problem? </font>" ); LogMsg("<font style=\"color:red;\"><b>" + rootDataPath + "</b> cannot be created. Access right problem? </font>" );
@ -2168,7 +2191,7 @@ void MainWindow::CreateRawDataFolder(){
//----- create analysis Folder //----- create analysis Folder
QDir anaDir; QDir anaDir;
if( !anaDir.exists(analysisPath)){ if( !anaDir.exists(analysisPath)){
if( anaDir.mkdir(analysisPath)){ if( anaDir.mkpath(analysisPath)){
LogMsg("<b>" + analysisPath + "</b> created." ); LogMsg("<b>" + analysisPath + "</b> created." );
}else{ }else{
LogMsg("<font style=\"color:red;\"><b>" + analysisPath + "</b> cannot be created. Access right problem?</font>" ); LogMsg("<font style=\"color:red;\"><b>" + analysisPath + "</b> cannot be created. Access right problem?</font>" );