Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddieAkeroyd committed Aug 28, 2024
1 parent 68daa9b commit cc4a8a7
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 64 deletions.
76 changes: 42 additions & 34 deletions installation_and_upgrade/ibex_install_utils/install_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
from ibex_install_utils.tasks.server_tasks import ServerTasks
from ibex_install_utils.tasks.system_tasks import SystemTasks
from ibex_install_utils.tasks.vhd_tasks import VHDTasks
from ibex_install_utils.user_prompt import UserPrompt


class UpgradeInstrument:
"""Class to upgrade the instrument installation to the given version of IBEX."""

def __init__(
self,
user_prompt,
server_source_dir,
client_source_dir,
genie_python3_dir,
ibex_version,
file_utils=FileUtils(),
):
user_prompt: UserPrompt,
server_source_dir: str,
client_source_dir: str,
genie_python3_dir: str,
ibex_version: str,
file_utils: FileUtils = FileUtils(),
) -> None:
"""Initializer.
Args:
Expand Down Expand Up @@ -111,14 +112,14 @@ def __init__(
)

@staticmethod
def icp_in_labview_modules():
def icp_in_labview_modules() -> bool:
"""Condition on which to install ICP_Binaries or
:return: True if the ICP is installed in labview modules, False otherwise
"""
return os.path.exists(LABVIEW_DAE_DIR)

def run_test_update(self):
def run_test_update(self) -> None:
"""Run a complete test upgrade on the current system"""
self._system_tasks.user_confirm_upgrade_type_on_machine("Training Machine")
self._system_tasks.install_or_upgrade_git()
Expand All @@ -136,10 +137,11 @@ def run_test_update(self):
self._system_tasks.upgrade_notepad_pp()
self._server_tasks.setup_log_rotation()

def remove_all_and_install_client_and_server(self):
def remove_all_and_install_client_and_server(self) -> None:
"""Either install or upgrade the ibex client and server"""
self._system_tasks.confirm(
"This script removes IBEX client and server and installs the latest build of both, and upgrade the "
"This script removes IBEX client and server and installs "
"the latest build of both, and upgrade the "
"config/schema without any extra steps. Proceed?"
)

Expand All @@ -153,13 +155,13 @@ def remove_all_and_install_client_and_server(self):
self._server_tasks.upgrade_instrument_configuration()
self._server_tasks.install_shared_scripts_repository()

def run_instrument_tests(self):
def run_instrument_tests(self) -> None:
"""Run through client and server tests once installation / deployment has completed."""
self._client_tasks.perform_client_tests()
self._server_tasks.perform_server_tests()
self._system_tasks.inform_instrument_scientists()

def run_instrument_install(self):
def run_instrument_install(self) -> None:
"""Do a first installation of IBEX on a new instrument."""
self._system_tasks.confirm(
"This script performs a first-time full installation of the IBEX server and client"
Expand Down Expand Up @@ -198,19 +200,20 @@ def run_instrument_install(self):
self._python_tasks.update_script_definitions()
self._server_tasks.setup_log_rotation()

def save_motor_params(self):
def save_motor_params(self) -> None:
self._server_tasks.save_motor_parameters_to_file()

def run_instrument_deploy(self):
def run_instrument_deploy(self) -> None:
"""Deploy a full IBEX upgrade on an existing instrument."""
self._system_tasks.confirm(
"This script performs a full upgrade of the IBEX server and client on an existing instrument. Proceed?"
"This script performs a full upgrade of the IBEX server "
"and client on an existing instrument. Proceed?"
)
self.run_instrument_deploy_pre_stop()
self.run_instrument_deploy_main()
self.run_instrument_deploy_post_start()

def run_instrument_deploy_post_start(self):
def run_instrument_deploy_post_start(self) -> None:
"""Upgrade an instrument. Steps to do after ibex has been started.
Current the server can not be started in this python script.
Expand All @@ -225,8 +228,9 @@ def run_instrument_deploy_post_start(self):
self._system_tasks.put_autostart_script_in_startup_area()
self._system_tasks.inform_instrument_scientists()

def run_instrument_deploy_main(self):
"""Upgrade an instrument. Steps to do after ibex has been stopped but before it is restarted.
def run_instrument_deploy_main(self) -> None:
"""Upgrade an instrument. Steps to do after ibex has been stopped
but before it is restarted.
Current the server can not be started or stopped in this python script.
"""
Expand All @@ -253,7 +257,7 @@ def run_instrument_deploy_main(self):
self._python_tasks.remove_instrument_script_githooks()
self._server_tasks.setup_log_rotation()

def run_instrument_deploy_pre_stop(self):
def run_instrument_deploy_pre_stop(self) -> None:
"""Upgrade an instrument. Steps to do before ibex is stopped.
Current the server can not be started or stopped in this python script.
Expand Down Expand Up @@ -284,18 +288,18 @@ def run_instrument_deploy_pre_stop(self):

self._server_tasks.save_motor_blocks_blockserver_to_file()

def run_truncate_database(self):
def run_truncate_database(self) -> None:
"""Backup and truncate databases only"""
self._mysql_tasks.backup_database()
self._mysql_tasks.truncate_database()

def run_force_upgrade_mysql(self):
def run_force_upgrade_mysql(self) -> None:
""":key
Do upgrade of mysql, with data dump.
"""
self._mysql_tasks.install_mysql(force=True)

def run_upgrade_mysql(self):
def run_upgrade_mysql(self) -> None:
""":key
Do upgrade of mysql with no table recreate.
"""
Expand All @@ -305,17 +309,17 @@ def run_update_calibrations_repository(self):
"""update_calibrations_repository"""
self._server_tasks.update_calibrations_repository()

def run_setup_log_rotation(self):
def run_setup_log_rotation(self) -> None:
"""setup_log_rotation"""
self._server_tasks.setup_log_rotation()

def run_developer_update(self):
def run_developer_update(self) -> None:
"""Update all the developer tools to latest version"""
self._mysql_tasks.install_mysql(force=False)
self._system_tasks.check_java_installation()
self._system_tasks.install_or_upgrade_git()

def run_vhd_creation(self):
def run_vhd_creation(self) -> None:
"""Automated job which creates a set of VHDs containing all IBEX components.
Note: this will run under jenkins, don't add interactive tasks to this list.
Expand Down Expand Up @@ -345,21 +349,23 @@ def run_vhd_creation(self):

self._vhd_tasks.deploy_vhds()

def mount_vhds(self):
def mount_vhds(self) -> None:
"""Task which actually mounts the VHDs (will be run as admin)"""
self._vhd_tasks.mount_vhds()

def dismount_vhds(self):
def dismount_vhds(self) -> None:
"""Task which actually dismounts the VHDs (will be run as admin)"""
self._vhd_tasks.dismount_vhds()

def request_dismount_vhds(self):
def request_dismount_vhds(self) -> None:
"""Standalone task to request VHDs to be dismounted"""
self._vhd_tasks.request_dismount_vhds()

def run_vhd_post_install(self):
"""This job is run by the MDT build system when it has built a windows image and mounted the VHDS
It will tidy up and remaining jobs that were not possible when the vdh was created e.g. register mysql service
def run_vhd_post_install(self) -> None:
"""This job is run by the MDT build system when it has built
a windows image and mounted the VHDS
It will tidy up and remaining jobs that were not possible when
the vdh was created e.g. register mysql service
"""
# self._server_tasks.update_icp(self.icp_in_labview_modules())
self._mysql_tasks.configure_mysql_for_vhd_post_install()
Expand Down Expand Up @@ -416,7 +422,8 @@ def run_vhd_post_install(self):
UpgradeInstrument.run_setup_log_rotation,
"setup log rotation",
),
"developer_update": (UpgradeInstrument.run_developer_update, "install latest developer tools"),
"developer_update": (UpgradeInstrument.run_developer_update,
"install latest developer tools"),
"create_vhds": (
UpgradeInstrument.run_vhd_creation,
"create a set of VHDS containing the latest IBEX release",
Expand All @@ -431,5 +438,6 @@ def run_vhd_post_install(self):
UpgradeInstrument.run_vhd_post_install,
"Run final task on system after VHD has been mounted locally",
),
"save_motor_params": (UpgradeInstrument.save_motor_params, "Save motor parameters to csv file"),
"save_motor_params": (UpgradeInstrument.save_motor_params,
"Save motor parameters to csv file"),
}
Loading

0 comments on commit cc4a8a7

Please sign in to comment.