Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions ulc_mm_package/QtGUI/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,36 @@ def _init_sigslots(self):
self.acquisition.update_infopanel.connect(self.scopeop.update_infopanel)

def _init_ssd(self):
self.ext_dir = None

samsung_ext_dir = path.join(SSD_DIR, SSD_NAME)
if path.exists(samsung_ext_dir):
if path.exists(samsung_ext_dir) and DataStorage.is_there_sufficient_storage(
samsung_ext_dir
):
self.ext_dir = samsung_ext_dir + "/"
print(f"Saving data to {self.ext_dir}")
else:
print(
f"Could not find '{SSD_NAME}' in {SSD_DIR}. Searching for other folders in this directory."
)
if not path.exists(samsung_ext_dir):
print(
f"'Couldn't find {SSD_NAME}' in {SSD_DIR}. Searching for other folders in this directory."
)
elif not DataStorage.is_there_sufficient_storage(samsung_ext_dir):
print(
f"'{SSD_NAME}' in {SSD_DIR} is out of storage. Searching for other folders in this directory."
)

try:
self.ext_dir = SSD_DIR + listdir(SSD_DIR)[0] + "/"
candidates = listdir(SSD_DIR)
for candidate in candidates:
# Check the size of the candidate folder
candidate_path = path.join(SSD_DIR, candidate)

# Let's ignore the originally checked folder
if candidate_path != samsung_ext_dir and path.isdir(candidate_path):
if DataStorage.is_there_sufficient_storage(candidate_path):
self.ext_dir = candidate_path + "/"
print(f"Saving data to {self.ext_dir}")
break
except (FileNotFoundError, IndexError):
print(
f"Could not find any folders within {SSD_DIR}. Check that the SSD is plugged in."
Expand All @@ -348,20 +369,19 @@ def _init_ssd(self):
buttons=Buttons.OK,
)
sys.exit(1)
print(f"Saving data to {self.ext_dir}")

if not DataStorage.is_there_sufficient_storage(self.ext_dir):
if not self.ext_dir:
self.ssd_full_msg_and_exit()
sys.exit(1)

def ssd_full_msg_and_exit(self):
print(
"The SSD is full. Please eject and then replace the SSD with a new one. Thank you!"
"Couldn't find any folders in /media/pi with sufficient storage. Please eject and replace the SSD with a new one. Thank you!"
)
self.display_message(
QMessageBox.Icon.Critical,
"SSD is full",
"The SSD is full. Data cannot be saved if the SSD is full. Please eject and then replace the SSD with a new one. Thank you!"
"No available storage folders",
"Couldn't find any folders in /media/pi with sufficient storage. Please eject and replace the SSD with a new one. Thank you!"
+ _ERROR_MSG,
buttons=Buttons.OK,
)
Expand Down
Loading