mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:41:20 +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 os.path import splitext
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from util import SupervisorMixin
|
||||
from config import LOGIN_APP_DIR
|
||||
@ -26,7 +27,7 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
return 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):
|
||||
with open(self.file, 'r') as ifile:
|
||||
@ -44,9 +45,9 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
self.supervisor.stopProcess(self.process_name)
|
||||
self.supervisor.startProcess(self.process_name)
|
||||
|
||||
def create_initial_state(self, process_is_running=False):
|
||||
if process_is_running:
|
||||
self.supervisor.stopProcess(self.process_name)
|
||||
def create_initial_state(self):
|
||||
try: self.supervisor.stopProcess(self.process_name)
|
||||
except SupervisorFault: pass
|
||||
|
||||
rmtree(self.working_directory, ignore_errors=True)
|
||||
copytree('source_code_server/', self.working_directory)
|
||||
|
@ -1,4 +1,5 @@
|
||||
from shutil import rmtree, copytree
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from event_handler_base import EventHandlerBase
|
||||
from util import SupervisorMixin
|
||||
@ -19,3 +20,8 @@ class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
|
||||
def handle_event(self, anchor, data_json):
|
||||
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