fenrir/src/fenrir-package/fenrir.py

71 lines
2.2 KiB
Python
Raw Normal View History

#!/bin/python
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
2016-07-07 17:59:21 -04:00
import os, sys, time
2016-07-07 15:40:10 -04:00
DEBUG = False
if not os.getcwd() in sys.path:
sys.path.append(os.getcwd())
2016-07-07 17:59:21 -04:00
from threading import Thread
from core import environment
2016-07-07 15:40:10 -04:00
from core import inputManager
from utils import debug
2016-07-07 15:40:10 -04:00
from speech import espeak as es
from speech import speechd as sd
from screen import linux as lx
class fenrir():
def __init__(self):
2016-07-07 17:59:21 -04:00
self.threadUpdateScreen = None
self.threadHandleInput = None
2016-07-07 18:07:03 -04:00
self.threadHandleCommandQueue = None
self.runtime = environment.runtime
2016-07-07 15:40:10 -04:00
self.runtime['inputManager'] = inputManager.inputManager()
if DEBUG:
self.runtime['debug'] = debug.debug()
2016-07-07 13:56:46 -04:00
self.settings = environment.settings
self.bindings = {}
self.autospeak = []
self.soundIcons = {}
2016-07-07 15:40:10 -04:00
# the following hard coded, in future we have a config loader
self.runtime['speechDriverString'] = 'speechd'
self.runtime['speechDriver'] = sd.speech()
self.runtime['screenDriverString'] = 'linux'
self.runtime['screenDriver'] = lx.screenManager()
def proceed(self):
2016-07-07 17:59:21 -04:00
self.threadUpdateScreen = Thread(target=self.updateScreen, args=())
self.threadHandleInput = Thread(target=self.handleInput, args=())
2016-07-07 18:07:03 -04:00
self.threadCommandQueue = Thread(target=self.handleCommandQueue, args=())
2016-07-07 17:59:21 -04:00
self.threadUpdateScreen.start()
self.threadHandleInput.start()
2016-07-07 18:07:03 -04:00
self.threadCommandQueue.start()
while(self.runtime['running']):
2016-07-07 17:59:21 -04:00
time.sleep(2)
2016-07-07 15:53:37 -04:00
self.shutdown()
2016-07-07 17:59:21 -04:00
def handleInput(self):
while(self.runtime['running']):
self.runtime = self.runtime['inputManager'].getKeyPressed(self.runtime)
def updateScreen(self):
while(self.runtime['running']):
self.runtime = self.runtime['screenDriver'].analyzeScreen(self.runtime)
2016-07-07 18:07:03 -04:00
def handleCommandQueue(self):
while(self.runtime['running']):
self.runtime = self.runtime # command queue here
2016-07-07 13:56:46 -04:00
def shutdown(self):
2016-07-07 17:59:21 -04:00
self.threadUpdateScreen.stop()
self.threadHandleInput.stop()
app = fenrir()
app.proceed()