33from time import sleep
44import logging
55import subprocess
6- from typing import Optional , List
6+ from typing import Optional , List , Dict , Set
77
88import aw_core
99
@@ -129,27 +129,30 @@ def read_log(self) -> str:
129129
130130class Manager :
131131 def __init__ (self , testing : bool = False ) -> None :
132- self .settings = AwQtSettings (testing )
133- self .modules = {}
132+ self .settings : AwQtSettings = AwQtSettings (testing )
133+ self .modules : Dict [str , Module ] = {}
134+ self .autostart_modules : Set [str ] = set (self .settings .autostart_modules )
135+
134136 for name in self .settings .possible_modules :
135137 if _locate_executable (name ):
136138 self .modules [name ] = Module (name , testing = testing )
137139 else :
138- logger .warning ("Module '{}' not found" .format (name ))
140+ logger .warning ("Module '{}' not found but was in possible modules " .format (name ))
139141
140142 def get_unexpected_stops (self ):
141- return list (filter (lambda x : x .started and not x .is_alive (), self .modules ))
143+ return list (filter (lambda x : x .started and not x .is_alive (), self .modules . values () ))
142144
143145 def start (self , module_name ):
144- if module_name in self .modules :
146+ if module_name in self .modules . keys () :
145147 self .modules [module_name ].start ()
146148
147149 def autostart (self , autostart_modules ):
148-
149150 if autostart_modules is None :
150- # Modules to start are not specified. Fallback on configuration.
151+ logger . info ( " Modules to start weren't specified in CLI arguments. Falling back to configuration." )
151152 autostart_modules = self .settings .autostart_modules
152153
154+ # We only want to autostart modules that are both in found modules and are asked to autostart.
155+ autostart_modules = autostart_modules .intersection (set (self .modules .keys ()))
153156 # Always start aw-server first
154157 if "aw-server" in autostart_modules :
155158 self .start ("aw-server" )
@@ -161,7 +164,7 @@ def autostart(self, autostart_modules):
161164 self .start (module_name )
162165
163166 def stop_all (self ):
164- for module in filter (lambda m : m .is_alive (), self .modules ):
167+ for module in filter (lambda m : m .is_alive (), self .modules . values () ):
165168 module .stop ()
166169
167170
0 commit comments