]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2696] hammer.py: replace ~ with os.environ['HOME']
authorAndrei Pavel <andrei@isc.org>
Wed, 25 Jan 2023 20:38:59 +0000 (22:38 +0200)
committerAndrei Pavel <andrei@isc.org>
Fri, 3 Feb 2023 14:57:09 +0000 (16:57 +0200)
On rare occasion, the previously-used execute() would return
empty output, which would cause the path to change, often resulting
in a 'no such file or directory' error.

hammer.py

index b86a5a54b03472a887e3a08a5cb6e3cc2c1557fc..01eaf489be837d2ba52ef0f2793798c876aef9ab 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -335,7 +335,7 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
         quiet = True
     if cwd and "~/" in cwd:
         # replace relative home directory
-        cwd = cwd.replace('~', execute('cd ~ && pwd', capture=True, super_quiet=True)[1].rstrip())
+        cwd = cwd.replace('~', os.environ['HOME'])
     if not super_quiet:
         log.info('>>>>> Executing %s in %s', cmd, cwd if cwd else os.getcwd())
     if not check_times: