Skip to content

Commit e6a11ad

Browse files
Handle improper path
1 parent 001f502 commit e6a11ad

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/navigate/controller/controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
verify_configuration,
8484
get_navigate_path,
8585
)
86-
from navigate.tools.file_functions import create_save_path, save_yaml_file, get_ram_info
86+
from navigate.tools.file_functions import save_yaml_file, get_ram_info
8787
from navigate.tools.common_dict_tools import update_stage_dict
8888
from navigate.tools.multipos_table_tools import update_table
8989
from navigate.tools.common_functions import combine_funcs
@@ -831,8 +831,8 @@ def execute(self, command, *args):
831831
if not self.prepare_acquire_data():
832832
self.acquire_bar_controller.stop_acquire()
833833
return
834-
saving_settings = self.configuration["experiment"]["Saving"]
835-
file_directory = create_save_path(saving_settings)
834+
835+
file_directory = args[0]
836836

837837
# Save the experiment.yaml file.
838838
save_yaml_file(

src/navigate/controller/sub_controllers/acquire_bar.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
# Local Imports
4242
from navigate.controller.sub_controllers.gui import GUIController
43+
from navigate.tools.file_functions import create_save_path
4344
from navigate.view.popups.acquire_popup import AcquirePopUp
4445
from navigate.view.main_window_content.acquire_notebook import AcquireBar
4546

@@ -404,12 +405,24 @@ def launch_acquisition(self, popup_window: AcquirePopUp) -> None:
404405
)
405406

406407
if is_valid:
408+
# Verify that the path is valid.
409+
try:
410+
file_directory = create_save_path(self.saving_settings)
411+
except Exception:
412+
messagebox.showwarning(
413+
title="Directory Not Found.",
414+
message="\r\n The directory specified is invalid. \r\n "
415+
"This commonly occurs when the Root Directory is "
416+
"improperly specified. \r\n "
417+
"Please double-check and try again.",
418+
parent=popup_window.popup,
419+
)
420+
return
421+
407422
self.is_acquiring = True
408423
self.view.acquire_btn.configure(state="disabled")
409-
# Close the window
410424
popup_window.popup.dismiss()
411-
# tell central controller, save the image/data
412-
self.parent_controller.execute("acquire_and_save")
425+
self.parent_controller.execute("acquire_and_save", file_directory)
413426

414427
def exit_program(self) -> None:
415428
"""Exit Button to close the program."""

0 commit comments

Comments
 (0)