我有一个安装脚本,用于安装特定的 github 存储库及其所有要求。
这是似乎不一致的安装程序 snipit:
@echo off
REM Check if Python 3.11 is installed
python --version 2>&1 | findstr /I "3.11"
if %ERRORLEVEL% NEQ 0 (
echo Python 3.11 is not installed. Please install Python 3.11 from the official website.
exit /b 1
)
REM Check if Git is installed
where git > nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo Git is not installed. Installing Git...
powershell -Command "Start-Process https://git-scm.com/download/win -Wait"
)
REM Check if Node.js and npm are installed
node --version 2>&1 | findstr /I "v"
if %ERRORLEVEL% NEQ 0 (
echo Node.js is not installed. Please install Node.js with npm from the official website.
exit /b 1
)
REM Check if Python requests library is installed
pip show requests | findstr /I "Name: requests"
if %ERRORLEVEL% NEQ 0 (
echo Installing requests...
pip install requests
)
REM Set the installation directory to the user's home directory
set "repo_dir=%USERPROFILE%\algorithm-trader-warframe"
mkdir "%repo_dir%" 2>nul
cd /d "%repo_dir%"
REM Clone the Git repository into the specified directory
if exist "%repo_dir%\Warframe-Algo-Trader" (
echo Repository is already cloned in %repo_dir%\Warframe-Algo-Trader.
) else (
echo Cloning the Git repository into %repo_dir%\Warframe-Algo-Trader...
git clone https://github.com/akmayer/Warframe-Algo-Trader
)
REM Install Python dependencies
pip install -r "%repo_dir%\Warframe-Algo-Trader\requirements.txt"
pip install uvicorn
REM Set the installation directory to the 'my-app' folder
cd /d "%repo_dir%\Warframe-Algo-Trader\my-app"
REM Check if Node.js dependencies are already installed
if exist "node_modules" (
echo Node.js dependencies are already installed.
) else (
echo Installing Node.js dependencies...
npm install --no-fund
REM Wait for npm installation to complete
:WAIT_NPM_INSTALL
if not exist "node_modules" (
timeout /t 5 /nobreak > nul
goto WAIT_NPM_INSTALL
)
)
REM Go back to the main 'Warframe-Algo-Trader' folder
cd /d "%repo_dir%\Warframe-Algo-Trader"
REM Remove the existing config.json file (if it exists)
if exist "config.json" del "config.json"
REM Initialize the tables and create a new config.json file
python init.py
当不继续执行 python init.py 和其他脚本时,该问题始终会发生。一致的解决方案是运行脚本两次。现在我有一个理论,这可能是由于时间不当造成的,但除此之外,我无法在网上或通过 GPT 找到任何表明问题原因及其解决方案的内容。
我已经尝试添加超时和等待循环,但它似乎不起作用。该脚本总是在第二次运行时起作用,我想将其最小化为仅一次,而无需将所有内容缝合在一起。