summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-01-22 09:10:30 +0200
committerLars Wirzenius <liw@liw.fi>2021-01-22 09:10:30 +0200
commit772580fd2f0e6d95ec68e88473b8365c7375798a (patch)
tree1795f35eca7d583df1f0960cb4cbc152d80d59d2 /share
parented76e372d2b5cb375f4cc44012a563d84d679c95 (diff)
downloadsubplot-772580fd2f0e6d95ec68e88473b8365c7375798a.tar.gz
feat! Python step cleanup functions now get step captures
Previously, step cleanup functions didn't get any step captures at all. This made it harder to do things like a step that starts a daemon: - when: I start {name} in the background function: start_daemon cleanup: stop_daemon The function to start the daemon gets the daemon name as an argument. The cleanup function doesn't. How is the cleanup function to know which daemon to stop? The workaround has been that the start function stores the name somewhere, but that gets tricky when a scenario may start several daemons. With this commit, the cleanup function gets the name as an argument, just like the start function, and knows what to clean up.
Diffstat (limited to 'share')
-rw-r--r--share/python/lib/daemon.py4
-rw-r--r--share/python/template/scenarios.py2
2 files changed, 3 insertions, 3 deletions
diff --git a/share/python/lib/daemon.py b/share/python/lib/daemon.py
index 160da0a..d436b4f 100644
--- a/share/python/lib/daemon.py
+++ b/share/python/lib/daemon.py
@@ -41,7 +41,7 @@ def _daemon_start_soonish(ctx, path=None, args=None, name=None, port=None):
logging.info("pgrep: %r", _daemon_pgrep(path))
-def _daemon_stop_soonish(ctx):
+def _daemon_stop_soonish(ctx, path=None, args=None, name=None, port=None):
ns = ctx.declare("_daemon")
pid = ns["_soonish"]
logging.debug(f"Stopping soonishly-started daemon, {pid}")
@@ -153,7 +153,7 @@ def daemon_wait_for_port(host, port, timeout=5.0):
# Stop a daemon.
-def daemon_stop(ctx, name=None):
+def daemon_stop(ctx, path=None, args=None, name=None):
logging.debug(f"Stopping daemon {name}")
ns = ctx.declare("_daemon")
diff --git a/share/python/template/scenarios.py b/share/python/template/scenarios.py
index e2703df..1e0ebf5 100644
--- a/share/python/template/scenarios.py
+++ b/share/python/template/scenarios.py
@@ -39,7 +39,7 @@ class Step:
if self._cleanup:
print(" cleanup: {} {}".format(self._kind, self._text))
logging.info(" cleanup: {} {}".format(self._kind, self._text))
- self._cleanup(ctx)
+ self._cleanup(ctx, **self._args)
else:
logging.info(" no cleanup defined: {} {}".format(self._kind, self._text))