1- from abc import ABCMeta , abstractmethod
2- from typing import List
3- import subprocess
41import logging
52import os
3+ import subprocess
4+ from abc import ABCMeta , abstractmethod
65
76from globals import UDEV_RULE_PATH , get_index , get_kernels
87
98
109class BaseBootService (metaclass = ABCMeta ):
1110 """Manage the boot service of linux-enable-ir-emitter"""
1211
13- def __init__ (self , devices : List [str ]) -> None :
14- """Create a boot service for run the drivers
12+ def __init__ (self , devices : list [str ]) -> None :
13+ """Create a boot service for run the drivers.
1514
1615 Args:
17- devices : devices for which a driver will be run
16+ devices (list[str]) : devices for which a driver will be run.
1817 """
19- self .devices = devices
18+ self .devices : list [ str ] = devices
2019
2120 @abstractmethod
2221 def _enable (self ) -> int :
23- """Enable the service
22+ """Enable the service.
2423
2524 Returns:
26- 0: the service have been enabled successfully
27- other value: Error with the boot service.
25+ int: 0 if the service have been enabled successfully.
26+ Otherwise, error with the boot service.
2827 """
2928
3029 @abstractmethod
3130 def _disable (self ) -> int :
32- """Disable the service
31+ """Disable the service.
3332
3433 Returns:
35- 0: the service have been disabled successfully
36- other value: The boot service does not exists .
34+ int: 0 if the service have been disabled successfully.
35+ Otherwise, error with the boot service.
3736 """
3837
3938 @abstractmethod
4039 def status (self ) -> int :
4140 """Print the service status
41+
4242 Returns:
43- 0: the service works fine
44- other value: error with the boot service
43+ int: 0 if the service works fine.
44+ Otherwise, error with the boot service.
4545 """
4646
4747 def enable (self ) -> int :
48+ """Enable the service.
49+
50+ Returns:
51+ int: 0 if the service have been enabled successfully.
52+ Otherwise, error with the boot service.
53+ """
4854 self ._create_udev ()
4955
50- exit_code = subprocess .run (
51- ["udevadm" , "control" , "--reload-rules" ], capture_output = True
52- ).returncode
53- exit_code += subprocess .run (
54- ["udevadm" , "trigger" ], capture_output = True
55- ).returncode
56+ exit_code = subprocess .call (
57+ ["udevadm" , "control" , "--reload-rules" ],
58+ stdout = subprocess .DEVNULL ,
59+ stderr = subprocess .DEVNULL ,
60+ )
61+ exit_code += subprocess .call (
62+ ["udevadm" , "trigger" ],
63+ stdout = subprocess .DEVNULL ,
64+ stderr = subprocess .DEVNULL ,
65+ )
5666
5767 if exit_code :
5868 logging .error ("Error with the udev boot service." )
@@ -61,6 +71,12 @@ def enable(self) -> int:
6171 return exit_code
6272
6373 def disable (self ) -> int :
74+ """Disable the service.
75+
76+ Returns:
77+ int: 0 if the service have been disabled successfully.
78+ Otherwise, error with the boot service.
79+ """
6480 try :
6581 os .remove (UDEV_RULE_PATH )
6682 exit_code = 0
0 commit comments