wrapper: move at_exit handling into wrap()

This commit is contained in:
InsanePrawn 2023-04-16 05:22:17 +02:00
parent 6961cb7f36
commit cd1d0543fe
2 changed files with 6 additions and 8 deletions

View file

@ -23,6 +23,7 @@ class DockerWrapper(Wrapper):
type: str = 'docker'
def wrap(self):
super().wrap()
script_path = config.runtime.script_source_dir
assert script_path
with open(os.path.join(script_path, 'version.txt')) as version_file:

View file

@ -77,13 +77,6 @@ class Wrapper(WrapperProtocol):
) -> str:
wrapped_config = f'{target_path.rstrip("/")}/{self.identifier}_wrapped.toml'
# FIXME: these at_exit hooks should go and be called from somewhere better suited
def at_exit():
self.stop()
os.remove(wrapped_config)
atexit.register(at_exit)
dump_config_file(
file_path=wrapped_config,
config=(config.file | {
@ -93,8 +86,12 @@ class Wrapper(WrapperProtocol):
self.wrapped_config_path = wrapped_config
return wrapped_config
def at_exit(self):
os.remove(self.wrapped_config_path)
self.stop()
def wrap(self):
raise NotImplementedError()
atexit.register(self.at_exit)
def stop(self):
raise NotImplementedError()