Skip to content

Commit

Permalink
fix autodeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
InzynierDomu committed Jun 12, 2024
1 parent 9377bd0 commit 31aa7d5
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions autodeploy.bat
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
)
Expand All @@ -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"
Expand All @@ -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%
Expand All @@ -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
)

Expand All @@ -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

0 comments on commit 31aa7d5

Please sign in to comment.