summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-08-12 08:39:17 +0300
committerLars Wirzenius <liw@liw.fi>2023-08-12 08:41:11 +0300
commite42ba37b63d1ca8b4d2a96e2d1b5f64316fb0b51 (patch)
tree23d91ebd4f66e20052e68b78bc8af198fe7f12ca /share
parentca29a91c1c867ff0c505db053c267c159268c19c (diff)
downloadsubplot-e42ba37b63d1ca8b4d2a96e2d1b5f64316fb0b51.tar.gz
feat: reduce repetitive logging of environment in Python runcmd
Every time runcmd.py runs a command, it uses the same environment. We only need to log it once. Sponsored-by: author
Diffstat (limited to 'share')
-rw-r--r--share/python/lib/runcmd.py1
-rw-r--r--share/python/template/scenarios.py10
2 files changed, 7 insertions, 4 deletions
diff --git a/share/python/lib/runcmd.py b/share/python/lib/runcmd.py
index c4a6a12..6a4965f 100644
--- a/share/python/lib/runcmd.py
+++ b/share/python/lib/runcmd.py
@@ -70,7 +70,6 @@ def runcmd_run(ctx, argv, **kwargs):
logging.debug("runcmd_run: running command")
log_value("argv", 1, dict(enumerate(argv)))
- log_value("env", 1, env)
log_value("kwargs:", 1, kwargs)
p = subprocess.Popen(argv, env=env, **kwargs)
diff --git a/share/python/template/scenarios.py b/share/python/template/scenarios.py
index b215133..a6aa9f4 100644
--- a/share/python/template/scenarios.py
+++ b/share/python/template/scenarios.py
@@ -42,12 +42,14 @@ class Step:
self._cleanup(ctx, **self._args)
+_logged_env = False
+
+
class Scenario:
def __init__(self, ctx):
self._title = None
self._steps = []
self._ctx = ctx
- self._logged_env = False
def get_title(self):
return self._title
@@ -91,7 +93,9 @@ class Scenario:
os.environ.update(overrides)
os.environ.update(extra_env)
- if not self._logged_env:
- self._logged_env = True
+ global _logged_env
+ if not _logged_env:
+ _logged_env = True
log_value("extra_env", 0, dict(extra_env))
+ log_value("overrides", 0, dict(overrides))
log_value("os.environ", 0, dict(os.environ))