From 7bc7c42d7f394180bbe182a417ce74f2fa97e480 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Mon, 25 Jul 2022 16:12:24 +0200 Subject: [PATCH] BugFix: output=all results in exception --- powerplug.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/powerplug.py b/powerplug.py index 4d76f61..241cacf 100644 --- a/powerplug.py +++ b/powerplug.py @@ -35,13 +35,16 @@ class sispmctl(object): return output def set_out_state(self, output, state): - output = self.__filter_output_parameter__(output) if output == "all": - state = [state, state, state, state] + if self.__state__ != [state, state, state, state]: + self.__set_out_state__(output, state) + else: + if self.__state__[int(output) - 1] != state: + self.__set_out_state__(output, state) - if self.__state__[output - 1] != state: + def __set_out_state__(self, output, state): try: - out_txt = subprocess.check_output(["sudo", "sispmctl", "-o" if state == True or state == [True, True, True, True] else "-f", str(output)]).decode('UTF-8') + out_txt = subprocess.check_output(["sudo", "sispmctl", "-o" if state == True else "-f", output]).decode('UTF-8') except subprocess.CalledProcessError as grepexc: logger.error("sispm error code %d", grepexc.returncode) else: