Skip to content
Snippets Groups Projects
Commit 317ad36d authored by Lan Dam's avatar Lan Dam
Browse files

change dir_names to list_of_dir, current directory to gps dialog because...

 change dir_names to list_of_dir, current directory to gps dialog because there can be more than one folder loaded; change from read_from_file_list to get_file_list(); remove try catch in get_file_list() because it is catch at the call of this function
parent 44b2c105
No related branches found
No related tags found
1 merge request!122allow to select multi folder to load
Pipeline #2551 failed with stage
in 2 minutes and 35 seconds
......@@ -61,7 +61,7 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
"""
dir_names: list of absolute path of data set directory
"""
self.dir_names: List[Path] = []
self.list_of_dir: List[Path] = []
"""
current_dir: str - the current main data directory
"""
......@@ -261,12 +261,12 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
front.
"""
try:
self.read_from_file_list()
self.get_file_list()
except Exception as e:
QtWidgets.QMessageBox.warning(self, "Select directory", str(e))
return
try:
win = ChannelPreferDialog(self, self.dir_names)
win = ChannelPreferDialog(self, self.list_of_dir)
win.show()
except DialogAlreadyOpenedError:
ChannelPreferDialog.current_instance.activateWindow()
......@@ -448,13 +448,13 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
return (self.pref_soh_list
if not self.all_soh_chans_check_box.isChecked() else [])
def read_from_file_list(self):
def get_file_list(self):
"""
Read from self.open_files_list to identify
self.dir_names/self.selected_rt130_paths.
self.data_type is identified here too.
"""
self.dir_names = ['']
self.list_of_dir = ['']
self.selected_rt130_paths = []
root_dir = Path(self.curr_dir_line_edit.text())
if self.rt130_das_dict != {}:
......@@ -472,30 +472,28 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
# displayed in File List box. The current dir (root_dir) will be
# the only one of the selected dir for user to start processing
# from.
self.dir_names = [root_dir]
self.list_of_dir = [root_dir]
if self.data_radio_button.isEnabled():
# In case of Baler's data, there will be 2 data folders for
# user to select from, data/ and sdata/. The radio buttons
# data and sdata allow user to select from Main Window.
if self.data_radio_button.isChecked():
self.dir_names = [root_dir.joinpath('data')]
self.list_of_dir = [root_dir.joinpath('data')]
else:
self.dir_names = [root_dir.joinpath('sdata')]
self.list_of_dir = [root_dir.joinpath('sdata')]
else:
# When "From Data Card" checkbox is checked, sub directories of the
# current dir (root_dir) will be displayed in File List box.
# User can select one or more sub-directories to process from.
self.dir_names = [root_dir.joinpath(item.text())
for item in self.open_files_list.selectedItems()]
if self.dir_names == []:
self.list_of_dir = [
root_dir.joinpath(item.text())
for item in self.open_files_list.selectedItems()]
if self.list_of_dir == []:
msg = "No directories have been selected."
raise Exception(msg)
if self.rt130_das_dict == {}:
try:
self.data_type = detect_data_type(self.dir_names)
except Exception as e:
raise e
self.data_type = detect_data_type(self.list_of_dir)
def clear_plots(self):
self.plotting_widget.clear()
......@@ -560,12 +558,14 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
else [])
try:
self.read_from_file_list()
self.get_file_list()
except Exception as e:
QtWidgets.QMessageBox.warning(self, "Select directory", str(e))
QtWidgets.QMessageBox.warning(
self, "Directories",
f"Error in get_file_list:\n\n{str(e)}")
return
dir_size = sum(get_dir_size(str(dir))[0] for dir in self.dir_names)
dir_size = sum(get_dir_size(str(dir))[0] for dir in self.list_of_dir)
if dir_size > constants.BIG_FILE_SIZE:
data_too_big_dialog = QMessageBox()
data_too_big_dialog.setText('Chosen data set is very big. It '
......@@ -594,14 +594,14 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
self.end_tm = datetime.strptime(end_tm_str, TM_FORMAT).timestamp()
self.gps_dialog.clear_plot()
self.gps_dialog.data_path = self.dir_names[0]
self.gps_dialog.set_export_directory(str(self.dir_names[0]))
self.gps_dialog.data_path = self.curr_dir_line_edit.text()
self.gps_dialog.set_export_directory(self.curr_dir_line_edit.text())
self.gps_dialog.gps_points = []
self.data_loader.init_loader(
self.data_type,
self.tracking_info_text_browser,
self.dir_names,
self.list_of_dir,
self.selected_rt130_paths,
req_wf_chans=self.req_wf_chans,
req_soh_chans=self.req_soh_chans,
......@@ -754,7 +754,7 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
self.is_plotting_tps = True
peer_plotting_widgets.append(self.tps_dlg.plotting_widget)
self.tps_dlg.set_data(
self.data_type, ','.join([str(d) for d in self.dir_names]))
self.data_type, ','.join([str(d) for d in self.list_of_dir]))
self.tps_dlg.show()
# The waveform and TPS plots is being stopped at the same time, so
# we can't simply reset all flags. Instead, we use an intermediate
......@@ -775,7 +775,7 @@ class MainWindow(QtWidgets.QMainWindow, UIMainWindow):
# waveformPlot
peer_plotting_widgets.append(self.waveform_dlg.plotting_widget)
self.waveform_dlg.set_data(
self.data_type, ','.join([str(d) for d in self.dir_names]))
self.data_type, ','.join([str(d) for d in self.list_of_dir]))
self.waveform_dlg.show()
waveform_widget = self.waveform_dlg.plotting_widget
waveform_widget.stopped.connect(self.reset_is_plotting_waveform)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment