mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:11:33 +00:00
Refactor for handling xmlrpc exceptiions
This commit is contained in:
parent
83b66c47b5
commit
c7bc588397
@ -1,5 +1,6 @@
|
|||||||
from shutil import copy, rmtree, copytree
|
from shutil import copy, rmtree, copytree
|
||||||
from os.path import splitext
|
from os.path import splitext
|
||||||
|
from xmlrpc.client import Fault as SupervisorFault
|
||||||
|
|
||||||
from util import SupervisorMixin
|
from util import SupervisorMixin
|
||||||
from config import LOGIN_APP_DIR
|
from config import LOGIN_APP_DIR
|
||||||
@ -26,7 +27,7 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
return data_json
|
return data_json
|
||||||
|
|
||||||
def handle_reset(self, data_json):
|
def handle_reset(self, data_json):
|
||||||
self.create_initial_state(process_is_running=True)
|
self.create_initial_state()
|
||||||
|
|
||||||
def read_file(self, data_json):
|
def read_file(self, data_json):
|
||||||
with open(self.file, 'r') as ifile:
|
with open(self.file, 'r') as ifile:
|
||||||
@ -44,9 +45,9 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
self.supervisor.stopProcess(self.process_name)
|
self.supervisor.stopProcess(self.process_name)
|
||||||
self.supervisor.startProcess(self.process_name)
|
self.supervisor.startProcess(self.process_name)
|
||||||
|
|
||||||
def create_initial_state(self, process_is_running=False):
|
def create_initial_state(self):
|
||||||
if process_is_running:
|
try: self.supervisor.stopProcess(self.process_name)
|
||||||
self.supervisor.stopProcess(self.process_name)
|
except SupervisorFault: pass
|
||||||
|
|
||||||
rmtree(self.working_directory, ignore_errors=True)
|
rmtree(self.working_directory, ignore_errors=True)
|
||||||
copytree('source_code_server/', self.working_directory)
|
copytree('source_code_server/', self.working_directory)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from shutil import rmtree, copytree
|
from shutil import rmtree, copytree
|
||||||
|
from xmlrpc.client import Fault as SupervisorFault
|
||||||
|
|
||||||
from event_handler_base import EventHandlerBase
|
from event_handler_base import EventHandlerBase
|
||||||
from util import SupervisorMixin
|
from util import SupervisorMixin
|
||||||
@ -19,3 +20,8 @@ class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
|
|
||||||
def handle_event(self, anchor, data_json):
|
def handle_event(self, anchor, data_json):
|
||||||
raise NotImplementedError # TODO: wat do?
|
raise NotImplementedError # TODO: wat do?
|
||||||
|
|
||||||
|
def handle_reset(self, data_json):
|
||||||
|
try: self.supervisor.stopProcess(self.process_name)
|
||||||
|
except SupervisorFault: pass
|
||||||
|
self.supervisor.startProcess(self.process_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user