restructure init

This commit is contained in:
chrys 2016-07-14 22:15:10 +02:00
parent c7facb9de6
commit 86ff160846
2 changed files with 29 additions and 23 deletions

View File

@ -1,8 +1,12 @@
#!/bin/python
from configparser import ConfigParser
from core.settings import settings
import evdev
import importlib.util
from configparser import ConfigParser
from core import inputManager
from core import commandManager
from core import environment
from core.settings import settings
from utils import debug
class settingsManager():
def __init__(self):
@ -105,5 +109,26 @@ class settingsManager():
spec.loader.exec_module(driver_mod)
environment['runtime']['screenDriver'] = driver_mod.screen()
return environment
def initFenrirConfig(self):
return self.reInitFenrirConfig(environment.environment)
def reInitFenrirConfig(self, environment):
environment['runtime']['settingsManager'] = self
environment['runtime']['inputManager'] = inputManager.inputManager()
environment = environment['runtime']['settingsManager'].loadShortcuts(environment)
environment = environment['runtime']['settingsManager'].loadSettings(environment)
environment['runtime']['commandManager'] = commandManager.commandManager()
environment = environment['runtime']['commandManager'].loadCommands(environment,'commands')
environment = environment['runtime']['commandManager'].loadCommands(environment,'onInput')
environment = environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged')
environment['runtime']['debug'] = debug.debug()
environment = environment['runtime']['settingsManager'].loadSpeechDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'speech', 'driver'))
environment = environment['runtime']['settingsManager'].loadScreenDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'))
environment = environment['runtime']['settingsManager'].loadSoundDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'))
return environment

View File

@ -11,32 +11,13 @@ if not os.getcwd() in sys.path:
from threading import Thread
from core import environment
from core import inputManager
from core import commandManager
from core import settingsManager
from utils import debug
class fenrir():
def __init__(self):
self.threadHandleInput = None
self.environment = environment.environment
self.environment['runtime']['inputManager'] = inputManager.inputManager()
self.environment['runtime']['settingsManager'] = settingsManager.settingsManager()
self.environment = self.environment['runtime']['settingsManager'].loadShortcuts(self.environment)
self.environment = self.environment['runtime']['settingsManager'].loadSettings(self.environment)
self.environment['runtime']['commandManager'] = commandManager.commandManager()
self.environment = self.environment['runtime']['commandManager'].loadCommands(self.environment,'commands')
self.environment = self.environment['runtime']['commandManager'].loadCommands(self.environment,'onInput')
self.environment = self.environment['runtime']['commandManager'].loadCommands(self.environment,'onScreenChanged')
self.environment['runtime']['debug'] = debug.debug()
self.environment = settingsManager.settingsManager().initFenrirConfig()
signal.signal(signal.SIGINT, self.captureSignal)
self.environment = self.environment['runtime']['settingsManager'].loadSpeechDriver(self.environment,\
self.environment['runtime']['settingsManager'].getSetting(self.environment,'speech', 'driver'))
self.environment = self.environment['runtime']['settingsManager'].loadScreenDriver(self.environment,\
self.environment['runtime']['settingsManager'].getSetting(self.environment,'screen', 'driver'))
self.environment = self.environment['runtime']['settingsManager'].loadSoundDriver(self.environment,\
self.environment['runtime']['settingsManager'].getSetting(self.environment,'sound', 'driver'))
def proceed(self):
self.threadHandleInput = Thread(target=self.handleInput, args=())