From 416bc3740c0a376b3854ff5af78cf689c75f2a44 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 00:49:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- socs/agents/scpi_psu/agent.py | 15 ++++++++------- socs/agents/scpi_psu/drivers.py | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/socs/agents/scpi_psu/agent.py b/socs/agents/scpi_psu/agent.py index 3440e4b18..88128c5e8 100644 --- a/socs/agents/scpi_psu/agent.py +++ b/socs/agents/scpi_psu/agent.py @@ -9,6 +9,7 @@ # from drivers import PsuInterface # import the local driver for testing purposes from socs.agents.scpi_psu.drivers import PsuInterface + class ScpiPsuAgent: def __init__(self, agent, ip_address, gpib_slot): self.agent = agent @@ -40,7 +41,7 @@ def init(self, session, params=None): """ if self.psu is not None: return True, "Already Initialized Module" - + with self.lock.acquire_timeout(0) as acquired: if not acquired: return False, "Could not acquire lock" @@ -52,14 +53,14 @@ def init(self, session, params=None): self.log.error(f"PSU timed out during connect: {e}") return False, "Timeout" self.log.info("Connected to psu: {}".format(self.idn)) - return True, 'Initialized PSU.' - + return True, 'Initialized PSU.' + def _initialize_module(self, session, params=None): """Initialize the ScpiPsu module.""" try: - self.psu = PsuInterface(self.ip_address, self.gpib_slot) #this is only necessary if the ip_address or gpib_slot has changed. I could declare a self.connected flag if this is uneeded. + self.psu = PsuInterface(self.ip_address, self.gpib_slot) # this is only necessary if the ip_address or gpib_slot has changed. I could declare a self.connected flag if this is uneeded. self.idn = self.psu.identify() - except Exception as e: #socket.tiout OR OSError 113 No route to host. + except Exception as e: # socket.tiout OR OSError 113 No route to host. self.log.info("Failed to reconnect, trying again") self.psu = None return False @@ -107,7 +108,7 @@ def monitor_output(self, session, params=None): self.psu = None break - if self.psu: #Check to make sure there weren't any timeout errors so we don't publish incomplete data and make block errors. + if self.psu: # Check to make sure there weren't any timeout errors so we don't publish incomplete data and make block errors. # self.log.info(str(data)) self.agent.publish_to_feed('psu_output', data) @@ -230,4 +231,4 @@ def main(args=None): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/socs/agents/scpi_psu/drivers.py b/socs/agents/scpi_psu/drivers.py index 073ae1135..34dd3850f 100644 --- a/socs/agents/scpi_psu/drivers.py +++ b/socs/agents/scpi_psu/drivers.py @@ -82,5 +82,5 @@ def get_curr(self, ch): return current def clear(self): - self.write('*CLS') #Clear all the event registers and error queue, using a querry such as *ESR? or MEAS:X? can confuse the PSU - return True \ No newline at end of file + self.write('*CLS') # Clear all the event registers and error queue, using a querry such as *ESR? or MEAS:X? can confuse the PSU + return True