Răsfoiți Sursa

better error message from python3 when not initialized

Bug: 414330998
Change-Id: I47fcd9571ba3de0a080e31624f9bdf0fa738914a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6498079
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Fumitoshi Ukai 3 luni în urmă
părinte
comite
e6596746dc
2 a modificat fișierele cu 16 adăugiri și 1 ștergeri
  1. 8 0
      python-bin/python3
  2. 8 1
      python-bin/python3.bat

+ 8 - 0
python-bin/python3

@@ -2,6 +2,14 @@
 
 
 DEPOT_TOOLS=$(dirname "$0")/..
 DEPOT_TOOLS=$(dirname "$0")/..
 
 
+if [[ ! -f "$DEPOT_TOOLS/python3_bin_reldir.txt" ]]; then
+  cat >&2 <<EOF
+python3_bin_reldir.txt not found. need to initialize depot_tools by
+running gclient, update_depot_tools or ensure_bootstrap.
+EOF
+  exit 1
+fi
+
 if [ "$OSTYPE" = "msys" ]
 if [ "$OSTYPE" = "msys" ]
 then
 then
   PYTHON3_BIN_DIR="$DEPOT_TOOLS/$(sed -e 's-\\-/-g' $DEPOT_TOOLS/python3_bin_reldir.txt)"
   PYTHON3_BIN_DIR="$DEPOT_TOOLS/$(sed -e 's-\\-/-g' $DEPOT_TOOLS/python3_bin_reldir.txt)"

+ 8 - 1
python-bin/python3.bat

@@ -6,6 +6,13 @@
 setlocal
 setlocal
 
 
 for %%d in (%~dp0..) do set PARENT_DIR=%%~fd
 for %%d in (%~dp0..) do set PARENT_DIR=%%~fd
+IF NOT EXIST "%PARENT_DIR%\python3_bin_reldir.txt" (
+  echo python3_bin_reldir.txt not found. need to initialize depot_tools by >&2
+  echo running gclient or update_depot_tools >&2
+  exit /b 1
+)
+
+:Initialized
 for /f %%i in (%PARENT_DIR%\python3_bin_reldir.txt) do set PYTHON_BIN_ABSDIR=%PARENT_DIR%\%%i
 for /f %%i in (%PARENT_DIR%\python3_bin_reldir.txt) do set PYTHON_BIN_ABSDIR=%PARENT_DIR%\%%i
 set PATH=%PYTHON_BIN_ABSDIR%;%PYTHON_BIN_ABSDIR%\Scripts;%PATH%
 set PATH=%PYTHON_BIN_ABSDIR%;%PYTHON_BIN_ABSDIR%\Scripts;%PATH%
-"%PYTHON_BIN_ABSDIR%\python3.exe" %*
+"%PYTHON_BIN_ABSDIR%\python3.exe" %*