]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't assume FileNotFoundError from run() is about the executable
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Oct 2023 10:26:34 +0000 (12:26 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Oct 2023 10:26:34 +0000 (12:26 +0200)
It could also be about e.g. the working directory, so let's make sure
we log about it correctly.

mkosi/run.py

index 6eccccf759280a15382929481d7320a745a81258..16f51f00d4e070193108c2a17a87fee23412c808 100644 (file)
@@ -215,8 +215,8 @@ def run(
             cwd=cwd,
             preexec_fn=make_foreground_process,
         )
-    except FileNotFoundError:
-        die(f"{cmdline[0]} not found in PATH.")
+    except FileNotFoundError as e:
+        die(f"{e.filename} not found.")
     except subprocess.CalledProcessError as e:
         if log:
             logging.error(f"\"{shlex.join(cmdline)}\" returned non-zero exit code {e.returncode}.")
@@ -263,8 +263,8 @@ def spawn(
             preexec_fn=make_foreground_process if foreground else None,
         ) as proc:
             yield proc
-    except FileNotFoundError:
-        die(f"{cmdline[0]} not found in PATH.")
+    except FileNotFoundError as e:
+        die(f"{e.filename} not found.")
     except subprocess.CalledProcessError as e:
         if log:
             logging.error(f"\"{shlex.join(cmdline)}\" returned non-zero exit code {e.returncode}.")