mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 13:31:21 +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 os.path import splitext
|
||||
from contextlib import suppress
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from util import SupervisorMixin
|
||||
@ -46,8 +47,8 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
self.supervisor.startProcess(self.process_name)
|
||||
|
||||
def create_initial_state(self):
|
||||
try: self.supervisor.stopProcess(self.process_name)
|
||||
except SupervisorFault: pass
|
||||
with suppress(SupervisorFault):
|
||||
self.supervisor.stopProcess(self.process_name)
|
||||
|
||||
rmtree(self.working_directory, ignore_errors=True)
|
||||
copytree('source_code_server/', self.working_directory)
|
||||
|
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
from shutil import rmtree, copytree
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
from contextlib import suppress
|
||||
|
||||
from event_handler_base import EventHandlerBase
|
||||
from util import SupervisorMixin
|
||||
@ -24,6 +25,6 @@ class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
# TODO: wat do?
|
||||
|
||||
def handle_reset(self, data_json):
|
||||
try: self.supervisor.stopProcess(self.process_name)
|
||||
except SupervisorFault: pass
|
||||
with suppress(SupervisorFault):
|
||||
self.supervisor.stopProcess(self.process_name)
|
||||
self.supervisor.startProcess(self.process_name)
|
||||
|
Loading…
Reference in New Issue
Block a user