77
88import aw_core
99
10+ from .config import QTSettings
11+
1012logger = logging .getLogger (__name__ )
1113
1214
@@ -126,22 +128,14 @@ def read_log(self) -> str:
126128
127129
128130class Manager :
129- def __init__ (self , testing : bool = False ) -> None :
130- # TODO: Fetch these from somewhere appropriate (auto detect or a config file)
131- # Save to config wether they should autostart or not.
132- _possible_modules = [
133- "aw-server" ,
134- "aw-server-rust" ,
135- "aw-watcher-afk" ,
136- "aw-watcher-window" ,
137- # "aw-watcher-spotify",
138- # "aw-watcher-network"
139- ]
140-
141- self .modules = []
142- for name in _possible_modules :
143- if not _locate_executable (name ):
144- self .modules .append (Module (name , testing = testing ))
131+ def __init__ (self , testing : bool = False ) -> None :
132+ self .settings = QTSettings (testing )
133+ self .modules = {}
134+ for name in self .settings .possible_modules :
135+ if _locate_executable (name ):
136+ self .modules [name ] = Module (name , testing = testing )
137+ else :
138+ print ("Module '{}' not found" .format (name ))
145139
146140 def get_unexpected_stops (self ):
147141 return list (filter (lambda x : x .started and not x .is_alive (), self .modules .values ()))
@@ -153,6 +147,11 @@ def start(self, module_name):
153147 logger .error ("Unable to start module '{}': No such module" .format (module_name ))
154148
155149 def autostart (self , autostart_modules ):
150+
151+ if autostart_modules is None :
152+ # Modules to start are not specified. Fallback on configuration.
153+ autostart_modules = self .settings .autostart_modules
154+
156155 # Always start aw-server first
157156 if "aw-server" in autostart_modules :
158157 self .start ("aw-server" )
0 commit comments