修复了路径不存在时无法正确创建文件夹的问题

This commit is contained in:
2025-05-29 14:05:52 +08:00
parent 6b7ba17c6a
commit b01e2f1161
13 changed files with 25 additions and 38 deletions

View File

@ -126,6 +126,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.approximately_align.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.approximately_align.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_preprocess__(self):
self.preprocess = MainWindow_preprocess()
@ -146,6 +147,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.preprocess.show(mode, root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.preprocess.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_detect_Jpeak__(self):
self.detect_Jpeak = MainWindow_detect_Jpeak()
@ -158,6 +160,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.detect_Jpeak.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.detect_Jpeak.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_detect_Rpeak__(self):
self.detect_Rpeak = MainWindow_detect_Rpeak()
@ -170,6 +173,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.detect_Rpeak.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.detect_Rpeak.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_label_check__(self):
self.label_check = MainWindow_label_check()
@ -192,6 +196,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.label_check.show(mode, root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.label_check.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_precisely_align__(self):
self.precisely_align = MainWindow_precisely_align()
@ -204,6 +209,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.precisely_align.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.precisely_align.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_cut_PSG__(self):
self.cut_PSG = MainWindow_cut_PSG()
@ -214,6 +220,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
if not self.check_sampID():
return
self.cut_PSG.show(root_path, int(sampID))
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_artifact_label__(self):
self.artifact_label = MainWindow_artifact_label()
@ -226,6 +233,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.artifact_label.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.artifact_label.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_bcg_quality_label__(self):
self.bcg_quality_label = MainWindow_bcg_quality_label()
@ -238,6 +246,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.bcg_quality_label.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.bcg_quality_label.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_resp_quality_label__(self):
self.resp_quality_label = MainWindow_resp_quality_label()
@ -250,6 +259,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.resp_quality_label.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.resp_quality_label.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def __slot_btn_SA_label__(self):
self.SA_label = MainWindow_SA_label()
@ -262,6 +272,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.SA_label.show(root_path, int(sampID))
# 默认最大化显示而非固定分辨率
self.SA_label.showMaximized()
self.check_save_path_and_mkdir(root_path, sampID)
def seek_sampID(self, path):
if not Path(path).exists():
@ -271,7 +282,6 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
sub_folders = [item.name for item in Path(path).iterdir() if item.is_dir()]
self.ui.comboBox_sampID.addItems(sub_folders)
def check_root_path(self):
if self.ui.plainTextEdit_root_path.toPlainText() == Constants.STRING_IS_EMPTY:
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_ROOT_PATH_NOT_EXIST, Constants.MSGBOX_TYPE_ERROR)
@ -283,3 +293,16 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_SAMPID_EMPTY, Constants.MSGBOX_TYPE_ERROR)
return False
return True
def check_save_path_and_mkdir(self, root_path, sampID):
path_Label = Path(root_path) / Path(Filename.PATH_LABEL) / Path(str(sampID))
path_OrgBCG_Aligned = Path(root_path) / Path(Filename.PATH_ORGBCG_ALIGNED) / Path(str(sampID))
path_PSG_Aligned = Path(root_path) / Path(Filename.PATH_PSG_ALIGNED) / Path(str(sampID))
path_OrgBCG_Text = Path(root_path) / Path(Filename.PATH_ORGBCG_TEXT) / Path(str(sampID))
path_PSG_Text = Path(root_path) / Path(Filename.PATH_PSG_TEXT) / Path(str(sampID))
path_list = [path_Label, path_OrgBCG_Aligned, path_PSG_Aligned, path_OrgBCG_Text, path_PSG_Text]
for path in path_list:
if not path.exists():
path.mkdir(parents=True, exist_ok=True)