Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Willemsen committed Aug 15, 2024
1 parent be07c9d commit 95be9f5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions installation_and_upgrade/ibex_install_utils/tasks/mysql_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MysqlTasks(BaseTasks):
Tasks relating to installing or maintaining an installation of MySQL on a machine.
"""

def _get_mysql_dir(self):
def _get_mysql_dir(self) -> str:
"""
Returns the mysql 8 default install directory if it exists, else 5.7.
Expand All @@ -76,7 +76,7 @@ def _get_mysql_dir(self):

return mysql_bin_dir

def _get_mysql_backup_dir(self):
def _get_mysql_backup_dir(self) -> str:
mysql_backup_dir = os.path.join(
STAGE_DELETED,
self._get_machine_name(),
Expand All @@ -87,14 +87,16 @@ def _get_mysql_backup_dir(self):
return mysql_backup_dir

@task("Truncate database")
def truncate_database(self):
def truncate_database(self) -> None:
"""
Truncate the message log, sample and alarms tables
"""
try:
mysql_bin_dir = self._get_mysql_dir()

sql_command = "truncate table msg_log.message;truncate table archive.sample;truncate table alarm.pv"
sql_command = ("truncate table msg_log.message;"
"truncate table archive.sample;"
"truncate table alarm.pv")

RunProcess(
MYSQL_FILES_DIR,
Expand All @@ -110,7 +112,7 @@ def truncate_database(self):
f"Error is {ex}"
)

def _configure_mysql(self):
def _configure_mysql(self) -> None:
"""
Copy mysql settings and run the MySQL configuration script
"""
Expand All @@ -131,7 +133,7 @@ def _configure_mysql(self):
admin_commands.add_command("sc", "start MYSQL80", expected_return_val=None)
admin_commands.run_all()

def _remove_old_versions_of_mysql8(self, clean_install):
def _remove_old_versions_of_mysql8(self, clean_install: bool) -> None:
if clean_install:
self.prompt.prompt_and_raise_if_not_yes(
"Warning: this will erase all data held in the MySQL database. "
Expand All @@ -151,11 +153,11 @@ def _remove_old_versions_of_mysql8(self, clean_install):
if clean_install:
self._remove_old_mysql_data_dir()

def _remove_old_mysql_data_dir(self):
def _remove_old_mysql_data_dir(self) -> None:
if os.path.exists(MYSQL_FILES_DIR):
shutil.rmtree(MYSQL_FILES_DIR)

def _create_mysql_binaries(self):
def _create_mysql_binaries(self) -> None:
os.makedirs(MYSQL8_INSTALL_DIR)

mysql_unzip_temp = os.path.join(APPS_BASE_DIR, "temp-mysql-unzip")
Expand All @@ -171,7 +173,7 @@ def _create_mysql_binaries(self):

shutil.rmtree(mysql_unzip_temp)

def _initialize_mysql_data_area_for_vhd(self):
def _initialize_mysql_data_area_for_vhd(self) -> None:
os.makedirs(os.path.join(MYSQL_FILES_DIR, "data"))

RunProcess(
Expand Down

0 comments on commit 95be9f5

Please sign in to comment.