mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:51:31 +00:00
Handling of xmlrpc exceptions is now done with contextlib.suppress()
This commit is contained in:
parent
ae4c27c0f5
commit
d7919255ec
@ -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 contextlib import suppress
|
||||||
from xmlrpc.client import Fault as SupervisorFault
|
from xmlrpc.client import Fault as SupervisorFault
|
||||||
|
|
||||||
from util import SupervisorMixin
|
from util import SupervisorMixin
|
||||||
@ -46,8 +47,8 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
self.supervisor.startProcess(self.process_name)
|
self.supervisor.startProcess(self.process_name)
|
||||||
|
|
||||||
def create_initial_state(self):
|
def create_initial_state(self):
|
||||||
try: self.supervisor.stopProcess(self.process_name)
|
with suppress(SupervisorFault):
|
||||||
except SupervisorFault: pass
|
self.supervisor.stopProcess(self.process_name)
|
||||||
|
|
||||||
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,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from shutil import rmtree, copytree
|
from shutil import rmtree, copytree
|
||||||
from xmlrpc.client import Fault as SupervisorFault
|
from xmlrpc.client import Fault as SupervisorFault
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
from event_handler_base import EventHandlerBase
|
from event_handler_base import EventHandlerBase
|
||||||
from util import SupervisorMixin
|
from util import SupervisorMixin
|
||||||
@ -24,6 +25,6 @@ class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
# TODO: wat do?
|
# TODO: wat do?
|
||||||
|
|
||||||
def handle_reset(self, data_json):
|
def handle_reset(self, data_json):
|
||||||
try: self.supervisor.stopProcess(self.process_name)
|
with suppress(SupervisorFault):
|
||||||
except SupervisorFault: pass
|
self.supervisor.stopProcess(self.process_name)
|
||||||
self.supervisor.startProcess(self.process_name)
|
self.supervisor.startProcess(self.process_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user