mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-26 02:18:21 -04:00
wrapper: move at_exit handling into wrap()
This commit is contained in:
parent
6961cb7f36
commit
cd1d0543fe
2 changed files with 6 additions and 8 deletions
|
@ -23,6 +23,7 @@ class DockerWrapper(Wrapper):
|
||||||
type: str = 'docker'
|
type: str = 'docker'
|
||||||
|
|
||||||
def wrap(self):
|
def wrap(self):
|
||||||
|
super().wrap()
|
||||||
script_path = config.runtime.script_source_dir
|
script_path = config.runtime.script_source_dir
|
||||||
assert script_path
|
assert script_path
|
||||||
with open(os.path.join(script_path, 'version.txt')) as version_file:
|
with open(os.path.join(script_path, 'version.txt')) as version_file:
|
||||||
|
|
|
@ -77,13 +77,6 @@ class Wrapper(WrapperProtocol):
|
||||||
) -> str:
|
) -> str:
|
||||||
wrapped_config = f'{target_path.rstrip("/")}/{self.identifier}_wrapped.toml'
|
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(
|
dump_config_file(
|
||||||
file_path=wrapped_config,
|
file_path=wrapped_config,
|
||||||
config=(config.file | {
|
config=(config.file | {
|
||||||
|
@ -93,8 +86,12 @@ class Wrapper(WrapperProtocol):
|
||||||
self.wrapped_config_path = wrapped_config
|
self.wrapped_config_path = wrapped_config
|
||||||
return wrapped_config
|
return wrapped_config
|
||||||
|
|
||||||
|
def at_exit(self):
|
||||||
|
os.remove(self.wrapped_config_path)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
def wrap(self):
|
def wrap(self):
|
||||||
raise NotImplementedError()
|
atexit.register(self.at_exit)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue