Skip to content
Merged
Changes from 1 commit
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
33 changes: 31 additions & 2 deletions installation_and_upgrade/ibex_install_utils/tasks/backup_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,43 @@
"""
for path in (EPICS_PATH, PYTHON_3_PATH, GUI_PATH):
path_to_backup = self._path_to_backup(path)
if not os.path.exists(os.path.join(path_to_backup, "VERSION.txt")):
backup_folder_exists = True
backup_zip_exists = False
file_to_check = 'VERSION.txt'
if not os.path.exists(os.path.join(path_to_backup, file_to_check)):
backup_folder_exists = False
if not backup_folder_exists:
backup_zip_exists = True
#The backup might be in the zip files instead of folders
backup_zip_file = os.path.join(path_to_backup + ".zip")
if os.path.exists(backup_zip_file):
#Extract the file name without extension.
backup_file_name = os.path.basename(path_to_backup)

Check failure on line 120 in installation_and_upgrade/ibex_install_utils/tasks/backup_tasks.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (F841)

installation_and_upgrade\ibex_install_utils\tasks\backup_tasks.py:120:21: F841 Local variable `backup_file_name` is assigned to but never used
with zipfile.ZipFile(backup_zip_file, 'r') as backup_ref:
if not file_to_check in backup_ref.namelist():

Check failure on line 122 in installation_and_upgrade/ibex_install_utils/tasks/backup_tasks.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (E713)

installation_and_upgrade\ibex_install_utils\tasks\backup_tasks.py:122:32: E713 Test for membership should be `not in`
backup_zip_exists = False
else:
backup_zip_exists = False

if not backup_folder_exists and not backup_zip_exists:
self.prompt.prompt_and_raise_if_not_yes(
f"Error found with backup. Backup failed at '{path_to_backup}'. "
"Please backup manually."
)

for path in (SETTINGS_DIR, AUTOSAVE, EPICS_UTILS_PATH):
if not os.path.exists(self._path_to_backup(path)):
#Either the folder or the corresponding .zip file should exist
if (not os.path.exists(self._path_to_backup(path))
and not os.path.exists(self._path_to_backup(path) + ".zip")):
self.prompt.prompt_and_raise_if_not_yes(
f"Error found with backup. '{path}' did not back up properly. "
"Please backup manually."
)

for path in (SETTINGS_DIR, AUTOSAVE, EPICS_UTILS_PATH):
#Either the folder or the corresponding .zip file should exist
if (not os.path.exists(self._path_to_backup(path))
and not os.path.exists(self._path_to_backup(path) + ".zip")):
self.prompt.prompt_and_raise_if_not_yes(
f"Error found with backup. '{path}' did not back up properly. "
"Please backup manually."
Expand Down
Loading