2018-01-24 14:10:59 +00:00
|
|
|
from shutil import rmtree, copytree
|
2018-01-17 15:33:34 +00:00
|
|
|
|
2018-01-31 14:50:52 +00:00
|
|
|
from tfw.event_handler_base import EventHandlerBase
|
|
|
|
from tfw.util import SupervisorMixin
|
|
|
|
from tfw.config import TERMINADO_DIR
|
|
|
|
from tfw.config.logs import logging
|
2018-01-29 17:36:29 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2018-01-17 15:33:34 +00:00
|
|
|
|
|
|
|
|
2018-01-24 14:10:59 +00:00
|
|
|
class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
2018-01-25 14:24:42 +00:00
|
|
|
def __init__(self, anchor, process_name):
|
|
|
|
super().__init__(anchor)
|
2018-01-24 14:10:59 +00:00
|
|
|
self.working_directory = TERMINADO_DIR
|
|
|
|
self.process_name = process_name
|
|
|
|
self.setup_terminado_server()
|
|
|
|
|
|
|
|
def setup_terminado_server(self):
|
|
|
|
rmtree(self.working_directory, ignore_errors=True)
|
|
|
|
copytree('terminado_server/', self.working_directory)
|
|
|
|
self.supervisor.startProcess(self.process_name)
|
2018-01-17 15:33:34 +00:00
|
|
|
|
|
|
|
def handle_event(self, anchor, data_json):
|
2018-01-29 17:36:29 +00:00
|
|
|
log.debug('TerminadoEventHandler received event for anchor {}'.format(anchor))
|
2018-01-24 15:36:32 +00:00
|
|
|
# TODO: wat do?
|