Pārlūkot izejas kodu

BugFix: output=all results in exception

master
Dirk Alders 2 gadus atpakaļ
vecāks
revīzija
7bc7c42d7f
1 mainītis faili ar 7 papildinājumiem un 4 dzēšanām
  1. 7
    4
      powerplug.py

+ 7
- 4
powerplug.py Parādīt failu

35
             return output
35
             return output
36
 
36
 
37
     def set_out_state(self, output, state):
37
     def set_out_state(self, output, state):
38
-        output = self.__filter_output_parameter__(output)
39
         if output == "all":
38
         if output == "all":
40
-            state = [state, state, state, state]
39
+            if self.__state__ != [state, state, state, state]:
40
+                self.__set_out_state__(output, state)
41
+        else:
42
+            if self.__state__[int(output) - 1] != state:
43
+                self.__set_out_state__(output, state)            
41
 
44
 
42
-        if self.__state__[output - 1] != state:
45
+    def __set_out_state__(self, output, state):
43
             try:
46
             try:
44
-                out_txt = subprocess.check_output(["sudo", "sispmctl", "-o" if state == True or state == [True, True, True, True] else "-f", str(output)]).decode('UTF-8')
47
+                out_txt = subprocess.check_output(["sudo", "sispmctl", "-o" if state == True else "-f", output]).decode('UTF-8')
45
             except subprocess.CalledProcessError as grepexc:                                                                                                   
48
             except subprocess.CalledProcessError as grepexc:                                                                                                   
46
                 logger.error("sispm error code %d", grepexc.returncode)
49
                 logger.error("sispm error code %d", grepexc.returncode)
47
             else:
50
             else:

Notiek ielāde…
Atcelt
Saglabāt