From 31aa7d5dc04042883e34c0e52d34c854599ba1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?In=C5=BCynier=20Domu?= Date: Wed, 12 Jun 2024 22:15:12 +0200 Subject: [PATCH] fix autodeploy --- autodeploy.bat | 51 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/autodeploy.bat b/autodeploy.bat index ef9e68e..d9e2a1b 100644 --- a/autodeploy.bat +++ b/autodeploy.bat @@ -1,8 +1,8 @@ @echo off set log_file=deploy.log +set current_datetime=%date% %time% ( - set current_datetime=%date% %time% echo Log started at: %current_datetime% ) > "%log_file%" 2>&1 @@ -14,7 +14,7 @@ echo check Python echo Python is not installed. Please install Python and try again. echo Press Enter to exit. pause >nul - exit /b %errorlevel% + exit ) else ( echo Python is already installed. ) @@ -23,37 +23,25 @@ echo check Python set file_path="pip_show_platformio_info.txt" :: Check if PlatformIO is installed echo check Platform IO -( - :: Check if PlatformIO is installed - echo Checking if PlatformIO is installed... - pip show platformio > %file_path% 2>&1 - - :: Display the content of the file - echo Displaying the content of the file %file_path%: - - findstr /C:"WARNING: Package(s) not found" %file_path% - if %errorlevel% equ 0 ( - echo PlatformIO is not installed. Proceeding with installation... - pip install platformio +pip show platformio > %file_path% 2>&1 +findstr /C:"WARNING: Package(s) not found" %file_path% > nul +if %errorlevel% neq 0 ( + echo PlatformIO is already installed. +) else ( + echo PlatformIO is not installed. Proceeding with installation... + pip install platformio if %errorlevel% neq 0 ( echo Error during PlatformIO installation. echo Press Enter to exit. pause >nul - exit /b %errorlevel% - ) else ( - echo PlatformIO has been successfully installed. - ) + exit ) else ( - echo PlatformIO is already installed. + echo PlatformIO has been successfully installed. + pip show platformio > %file_path% 2>&1 + type %file_path% ) - - type %file_path% )>> "%log_file%" 2>&1 - -:: Create a temporary file with the result of the pip show platformio command -pip show platformio > pip_show_platformio_info.txt - :: Search the text file for the line containing "Location:" for /f "delims=: tokens=1,*" %%A in ('findstr /n "Location:" "%file_path%"') do ( set "line_number=%%A" @@ -63,9 +51,6 @@ set "location=%%B" :: Remove leading and trailing spaces from the location set "location=%location:~10%" -:: Output everything after "Location:" -echo Everything after "Location:" in line %line_number%: %location% - :: Remove "lib\site-packages" from the location and add "Scripts\platformio.exe" set "platformio_exe_path=%location:lib\site-packages=Scripts\platformio.exe%" echo %platformio_exe_path% @@ -75,6 +60,8 @@ if exist "%platformio_exe_path%" ( echo Path to platformio.exe: %platformio_exe_path% ) else ( echo Unable to find platformio.exe file. Check the installation path. +echo Press Enter to exit. +pause >nul exit ) @@ -91,16 +78,16 @@ echo Configuring Arduino project and uploading ( :: Calling PlatformIO CLI to upload the project %platformio_exe_path% run --target upload -d %project_path% -e %board_type% - +)>> "%log_file%" 2>&1 :: Check if the operation was successful if %errorlevel% neq 0 ( echo Error uploading the project. -exit /b %errorlevel% +echo Press Enter to exit. +pause >nul +exit ) else ( echo The project has been successfully uploaded to Arduino. ) -)>> "%log_file%" 2>&1 echo Press Enter to exit. -:: Wait for user to press Enter before exiting pause >nul \ No newline at end of file