cleanup import

This commit is contained in:
chrys 2016-08-21 22:23:53 +02:00
parent 33872c39d7
commit da5612f09a

View File

@ -4,19 +4,16 @@
# Fenrir TTY screen reader # Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributers.
import os, sys, time, signal import os, sys, signal
if not os.getcwd() in sys.path: if not os.getcwd() in sys.path:
sys.path.append(os.getcwd()) sys.path.append(os.getcwd())
from threading import Thread
from core import environment from core import environment
from core import settingsManager from core import settingsManager
class fenrir(): class fenrir():
def __init__(self): def __init__(self):
self.threadonInput = Thread(target=self.onInput, args=())
self.environment = settingsManager.settingsManager().initFenrirConfig() self.environment = settingsManager.settingsManager().initFenrirConfig()
signal.signal(signal.SIGINT, self.captureSignal) signal.signal(signal.SIGINT, self.captureSignal)
@ -24,12 +21,12 @@ class fenrir():
self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True) self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
#self.threadonInput.start() #self.threadonInput.start()
while(self.environment['generalInformation']['running']): while(self.environment['generalInformation']['running']):
self.onInput() self.handleProcess()
self.shutdown() self.shutdown()
def onInput(self): def handleProcess(self):
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment) self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment)
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput') self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment)
if not timeout: if not timeout:
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput') self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
@ -38,17 +35,16 @@ class fenrir():
if self.environment['commandInfo']['currCommand'] != '': if self.environment['commandInfo']['currCommand'] != '':
self.handleCommands() self.handleCommands()
def updateScreen(self):
return
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
time.sleep(0.5)
def handleCommands(self): def handleCommands(self):
if (self.environment['commandInfo']['currCommand'] != ''): if (self.environment['commandInfo']['currCommand'] != ''):
self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands') self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
def shutdownRequest(self): def shutdownRequest(self):
self.environment['generalInformation']['running'] = False self.environment['generalInformation']['running'] = False
def captureSignal(self, siginit, frame):
self.shutdownRequest()
def shutdown(self): def shutdown(self):
self.environment['runtime']['outputManager'].presentText(self.environment, "Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['outputManager'].presentText(self.environment, "Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
@ -60,8 +56,5 @@ class fenrir():
self.environment['runtime']['speechDriver'].shutdown() self.environment['runtime']['speechDriver'].shutdown()
self.environment['runtime']['inputManager'].freeDevices() self.environment['runtime']['inputManager'].freeDevices()
def captureSignal(self, siginit, frame):
self.shutdownRequest()
app = fenrir() app = fenrir()
app.proceed() app.proceed()