Skip to content

Commit

Permalink
Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddieAkeroyd committed Feb 26, 2025
1 parent b47abaa commit ba1387a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions BlockServer/core/ioc_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
class IocControl:
"""A class for starting, stopping and restarting IOCs"""

def __init__(self, prefix):
def __init__(self, prefix: str) -> None:
"""Constructor.
Args:
prefix (string): The PV prefix for the instrument
"""
self._proc = ProcServWrapper(prefix)

def start_ioc(self, ioc: str, restart_alarm_server: bool = True):
def start_ioc(self, ioc: str, restart_alarm_server: bool = True) -> None:
"""Start an IOC.
Args:
Expand All @@ -48,11 +48,11 @@ def start_ioc(self, ioc: str, restart_alarm_server: bool = True):
except Exception as err:
print_and_log(f"Could not start IOC {ioc}: {err}", "MAJOR")

def restart_ioc(self, ioc: str, force: bool = False, restart_alarm_server: bool = True):
def restart_ioc(self, ioc: str, force: bool = False, restart_alarm_server: bool = True) -> None:
"""Restart an IOC.
Note: restarting an IOC automatically sets the IOC to auto-restart, so it is neccessary to reapply the
previous auto-restart setting
Note: restarting an IOC automatically sets the IOC to auto-restart,
so it is neccessary to reapply the previous auto-restart setting
Args:
ioc (string): The name of the IOC
Expand All @@ -69,7 +69,7 @@ def restart_ioc(self, ioc: str, force: bool = False, restart_alarm_server: bool
except Exception as err:
print_and_log(f"Could not restart IOC {ioc}: {err}", "MAJOR")

def stop_ioc(self, ioc: str, force: bool = False):
def stop_ioc(self, ioc: str, force: bool = False) -> None:
"""Stop an IOC.
Args:
Expand All @@ -86,7 +86,7 @@ def stop_ioc(self, ioc: str, force: bool = False):
except Exception as err:
print_and_log(f"Could not stop IOC {ioc}: {err}", "MAJOR")

def get_ioc_status(self, ioc: str):
def get_ioc_status(self, ioc: str) -> str:
"""Get the running status of an IOC.
Args:
Expand All @@ -97,7 +97,7 @@ def get_ioc_status(self, ioc: str):
"""
return self._proc.get_ioc_status(ioc)

def ioc_restart_pending(self, ioc: str):
def ioc_restart_pending(self, ioc: str) -> bool:
"""Tests if the IOC has a pending restart
Args:
Expand All @@ -108,7 +108,7 @@ def ioc_restart_pending(self, ioc: str):
"""
return self._proc.ioc_restart_pending(ioc)

def start_iocs(self, iocs: List[str]):
def start_iocs(self, iocs: List[str]) -> None:
"""Start a number of IOCs.
Args:
Expand All @@ -117,7 +117,7 @@ def start_iocs(self, iocs: List[str]):
for ioc in iocs:
self.start_ioc(ioc)

def restart_iocs(self, iocs: List[str], reapply_auto: bool = False):
def restart_iocs(self, iocs: List[str], reapply_auto: bool = False) -> None:
"""Restart a number of IOCs.
Args:
Expand All @@ -135,7 +135,7 @@ def restart_iocs(self, iocs: List[str], reapply_auto: bool = False):
self.waitfor_running(ioc)
self.set_autorestart(ioc, auto[ioc])

def stop_iocs(self, iocs: List[str]):
def stop_iocs(self, iocs: List[str]) -> None:
"""Stop a number of IOCs.
Args:
Expand All @@ -156,10 +156,10 @@ def ioc_exists(self, ioc: str) -> bool:
try:
self.get_ioc_status(ioc)
return True
except:
except Exception:
return False

def set_autorestart(self, ioc: str, enable: bool):
def set_autorestart(self, ioc: str, enable: bool) -> None:
"""Used to set the auto-restart property.
Args:
Expand All @@ -172,7 +172,7 @@ def set_autorestart(self, ioc: str, enable: bool):
curr = self._proc.get_autorestart(ioc)
if curr != enable:
# If different to requested then change it
print_and_log(f"Auto-restart for IOC {ioc} is not {enable}")
print_and_log(f"Auto-restart for IOC {ioc} not set to {enable}")
self._proc.toggle_autorestart(ioc)
return
print_and_log(f"Auto-restart for IOC {ioc} is already {enable}")
Expand All @@ -195,7 +195,7 @@ def get_autorestart(self, ioc: str) -> bool:
except Exception as err:
print_and_log(f"Could not get auto-restart setting for IOC {ioc}: {err}", "MAJOR")

def waitfor_running(self, ioc: str, timeout: int = 5):
def waitfor_running(self, ioc: str, timeout: int = 5) -> None:
"""Waits for the IOC to start running.
Args:
Expand Down

0 comments on commit ba1387a

Please sign in to comment.