mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 15:47:17 +00:00
Merge pull request #3 from avatao-content/terminalcommands
Terminalcommands
This commit is contained in:
commit
01eaf08f73
@ -1,9 +1,11 @@
|
|||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from tfw.components import WebideEventHandler, TerminadoEventHandler, ProcessManagingEventHandler, BashMonitor
|
from tfw.components import WebideEventHandler, TerminadoEventHandler, ProcessManagingEventHandler, BashMonitor
|
||||||
|
from tfw.components import TerminalCommands
|
||||||
from tfw.networking import MessageSender, TFWServerConnector
|
from tfw.networking import MessageSender, TFWServerConnector
|
||||||
from tfw.config import TFWENV
|
from tfw.config import TFWENV
|
||||||
from tfw.config.logs import logging
|
from tfw.config.logs import logging
|
||||||
|
from tao.config import TAOENV
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -13,28 +15,23 @@ def cenator(history):
|
|||||||
MessageSender().send('JOHN CENA', 'You\'ve executed "{}"'.format(history[-1]))
|
MessageSender().send('JOHN CENA', 'You\'ve executed "{}"'.format(history[-1]))
|
||||||
|
|
||||||
|
|
||||||
def selectdir(history):
|
class TestCommands(TerminalCommands):
|
||||||
try:
|
def command_selectdir(self, *args):
|
||||||
cmd = history[-1].split()
|
|
||||||
if cmd[0] == 'selectdir':
|
|
||||||
TFWServerConnector().send_to_eventhandler('webide',
|
TFWServerConnector().send_to_eventhandler('webide',
|
||||||
{'data': {'command': 'selectdir',
|
{'data': {'command': 'selectdir',
|
||||||
'directory': cmd[1]}})
|
'directory': args[0]}})
|
||||||
except IndexError:
|
|
||||||
LOG.exception('Selectdir failed!')
|
|
||||||
|
|
||||||
|
def command_trigger(self, *args):
|
||||||
|
TFWServerConnector().send('selectdir_needs_no_key',
|
||||||
|
{'trigger': args[0]})
|
||||||
|
|
||||||
def toggle_next(history):
|
def command_togglenext(self, *args):
|
||||||
toggle_next.button_state = not toggle_next.button_state
|
if not hasattr(self, 'togglenext_visible'):
|
||||||
try:
|
self.togglenext_visible = True
|
||||||
cmd = history[-1].split()
|
|
||||||
if cmd[0] == 'togglenext':
|
|
||||||
TFWServerConnector().send('messagecontrol',
|
TFWServerConnector().send('messagecontrol',
|
||||||
{'data': {'command': 'showbutton',
|
{'data': {'command': 'showbutton',
|
||||||
'next_visibility': toggle_next.button_state}})
|
'next_visibility': self.togglenext_visible}})
|
||||||
except IndexError:
|
self.togglenext_visible = not self.togglenext_visible
|
||||||
LOG.exception('Togglenext failed!')
|
|
||||||
toggle_next.button_state = False
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -43,8 +40,8 @@ if __name__ == '__main__':
|
|||||||
directory=TFWENV.WEBIDE_WD, exclude=['*.pyc'])
|
directory=TFWENV.WEBIDE_WD, exclude=['*.pyc'])
|
||||||
terminado = TerminadoEventHandler(key='shell', monitor=BashMonitor(TFWENV.HISTFILE))
|
terminado = TerminadoEventHandler(key='shell', monitor=BashMonitor(TFWENV.HISTFILE))
|
||||||
terminado.historymonitor.subscribe_callback(cenator)
|
terminado.historymonitor.subscribe_callback(cenator)
|
||||||
terminado.historymonitor.subscribe_callback(selectdir)
|
commands = TestCommands(bashrc=f'/home/{TAOENV.USER}/.bashrc')
|
||||||
terminado.historymonitor.subscribe_callback(toggle_next)
|
terminado.historymonitor.subscribe_callback(commands.callback)
|
||||||
processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor)
|
processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor)
|
||||||
|
|
||||||
eventhandlers = {ide, terminado, processmanager}
|
eventhandlers = {ide, terminado, processmanager}
|
||||||
|
Loading…
Reference in New Issue
Block a user