This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ed3accb300 Handle FileNotFound Error returned by missing uv or pipx 
(#43714)
ed3accb300 is described below

commit ed3accb30086b9ed5eddcd12b17a5f7c8d52d53b
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Nov 5 19:06:58 2024 +0100

    Handle FileNotFound Error returned by missing uv or pipx (#43714)
    
    Subprocess.run raises FileNotFound when uv or pipx are not installed
    at all. This PR will handle it.
---
 dev/breeze/src/airflow_breeze/utils/reinstall.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/reinstall.py 
b/dev/breeze/src/airflow_breeze/utils/reinstall.py
index 6fdf994c6e..4030235e68 100644
--- a/dev/breeze/src/airflow_breeze/utils/reinstall.py
+++ b/dev/breeze/src/airflow_breeze/utils/reinstall.py
@@ -39,14 +39,20 @@ def reinstall_breeze(breeze_sources: Path, re_run: bool = 
True):
     get_console().print(f"\n[info]Reinstalling Breeze from {breeze_sources}\n")
     breeze_installed_with_uv = False
     breeze_installed_with_pipx = False
-    result_uv = subprocess.run(["uv", "tool", "list"], text=True, 
capture_output=True, check=False)
-    if result_uv.returncode == 0:
-        if "apache-airflow-breeze" in result_uv.stdout:
-            breeze_installed_with_uv = True
-    result_pipx = subprocess.run(["pipx", "list"], text=True, 
capture_output=True, check=False)
-    if result_pipx.returncode == 0:
-        if "apache-airflow-breeze" in result_pipx.stdout:
-            breeze_installed_with_pipx = True
+    try:
+        result_uv = subprocess.run(["uv", "tool", "list"], text=True, 
capture_output=True, check=False)
+        if result_uv.returncode == 0:
+            if "apache-airflow-breeze" in result_uv.stdout:
+                breeze_installed_with_uv = True
+    except FileNotFoundError:
+        pass
+    try:
+        result_pipx = subprocess.run(["pipx", "list"], text=True, 
capture_output=True, check=False)
+        if result_pipx.returncode == 0:
+            if "apache-airflow-breeze" in result_pipx.stdout:
+                breeze_installed_with_pipx = True
+    except FileNotFoundError:
+        pass
     if breeze_installed_with_uv and breeze_installed_with_pipx:
         get_console().print(
             "[error]Breeze is installed both with `uv` and `pipx`. This is not 
supported.[/]\n"

Reply via email to