2016-07-07 13:43:31 -04:00
|
|
|
#!/bin/python
|
2016-07-08 19:01:00 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
# Fenrir TTY screen reader
|
|
|
|
# By Chrys, Storm Dragon, and contributers.
|
|
|
|
|
2016-07-08 03:49:59 -04:00
|
|
|
import os, sys, time, signal
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
if not os.getcwd() in sys.path:
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
|
2016-07-07 17:59:21 -04:00
|
|
|
from threading import Thread
|
2016-07-07 13:43:31 -04:00
|
|
|
from core import environment
|
2016-07-11 05:40:09 -04:00
|
|
|
from core import settingsManager
|
2016-07-07 15:40:10 -04:00
|
|
|
|
2016-07-07 13:43:31 -04:00
|
|
|
class fenrir():
|
|
|
|
def __init__(self):
|
2016-07-16 18:56:18 -04:00
|
|
|
self.threadonInput = Thread(target=self.onInput, args=())
|
2016-07-14 17:00:02 -04:00
|
|
|
|
2016-07-14 16:15:10 -04:00
|
|
|
self.environment = settingsManager.settingsManager().initFenrirConfig()
|
2016-07-08 03:49:59 -04:00
|
|
|
signal.signal(signal.SIGINT, self.captureSignal)
|
2016-07-14 16:15:10 -04:00
|
|
|
|
2016-07-07 13:43:31 -04:00
|
|
|
def proceed(self):
|
2016-08-10 09:30:43 -04:00
|
|
|
self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
|
|
|
|
time.sleep(1)# we need a is presenting methot for exact waiting
|
2016-07-18 13:42:49 -04:00
|
|
|
#self.threadonInput.start()
|
2016-08-10 08:32:13 -04:00
|
|
|
while(self.environment['generalInformation']['running']):
|
|
|
|
self.onInput()
|
2016-07-07 15:53:37 -04:00
|
|
|
self.shutdown()
|
|
|
|
|
2016-07-16 18:56:18 -04:00
|
|
|
def onInput(self):
|
2016-08-10 08:32:13 -04:00
|
|
|
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
|
|
|
self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment)
|
|
|
|
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput')
|
|
|
|
if not timeout:
|
|
|
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
|
|
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
|
|
|
if self.environment['commandInfo']['currCommand'] != '':
|
|
|
|
self.handleCommands()
|
2016-07-07 17:59:21 -04:00
|
|
|
|
|
|
|
def updateScreen(self):
|
2016-07-16 18:56:18 -04:00
|
|
|
return
|
2016-07-15 10:31:19 -04:00
|
|
|
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
|
2016-07-12 17:09:11 -04:00
|
|
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
2016-07-12 10:51:26 -04:00
|
|
|
time.sleep(0.5)
|
2016-07-07 17:59:21 -04:00
|
|
|
|
2016-07-08 12:33:32 -04:00
|
|
|
def handleCommands(self):
|
2016-07-23 11:07:55 -04:00
|
|
|
if (self.environment['commandInfo']['currCommand'] != ''):
|
2016-07-10 17:02:17 -04:00
|
|
|
self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
|
2016-08-10 09:30:43 -04:00
|
|
|
def shutdownRequest(self):
|
|
|
|
self.environment['generalInformation']['running'] = False
|
|
|
|
def shutdown(self):
|
|
|
|
self.environment['runtime']['outputManager'].presentText(self.environment, "Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
|
2016-07-07 18:07:03 -04:00
|
|
|
|
2016-07-08 05:29:50 -04:00
|
|
|
if self.environment['runtime']['debug'] != None:
|
|
|
|
self.environment['runtime']['debug'].closeDebugFile()
|
2016-07-08 06:30:47 -04:00
|
|
|
if self.environment['runtime']['soundDriver'] != None:
|
|
|
|
self.environment['runtime']['soundDriver'].shutdown()
|
2016-08-10 09:30:43 -04:00
|
|
|
if self.environment['runtime']['speechDriver'] != None:
|
|
|
|
self.environment['runtime']['speechDriver'].shutdown()
|
2016-08-11 08:37:46 -04:00
|
|
|
self.environment['runtime']['inputManager'].freeDevices()
|
|
|
|
|
2016-07-08 03:49:59 -04:00
|
|
|
def captureSignal(self, siginit, frame):
|
2016-08-10 09:30:43 -04:00
|
|
|
self.shutdownRequest()
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
app = fenrir()
|
|
|
|
app.proceed()
|