Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #158 from meshtastic/update_winapp
Browse files Browse the repository at this point in the history
update meshtastic WinApp to check for py; add icon; add metadata with…
  • Loading branch information
mkinney authored Mar 14, 2022
2 parents 5a2d830 + 33aba25 commit a62d4ab
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 8 deletions.
69 changes: 62 additions & 7 deletions winapp/meshtastic-flasher.au3
Original file line number Diff line number Diff line change
@@ -1,17 +1,72 @@
; meshtastic-flasher install
; meshtastic-flasher WinApp - create python virtual environment and run meshtastic-flasher

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=meshtastic.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#pragma compile(UPX, False)
#pragma compile(FileDescription, Meshtastic Flasher WinApp)
#pragma compile(ProductName, Meshtastic Flasher)
#pragma compile(ProductVersion, 1.0.2)
#pragma compile(FileVersion, 1.0.2.0)
#pragma compile(CompanyName, 'Meshtastic.org')

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

FileChangeDir(@HomePath)

If Not FileExists("meshtastic-flasher\") Then
MsgBox("", "test2", "creating dir")
MsgBox("", "Info", "creating dir")
DirCreate("meshtastic-flasher")
EndIf
FileChangeDir("meshtastic-flasher")

If Not FileExists("venv\") Then
$CMD = "py -m venv venv"
RunWait(@ComSpec & " /c " & $CMD)
; check if py is a valid command
Local $sPython = "py"
Local $CMD = $sPython & " --version"
Local $iPid = Run(@ComSpec & " /c " & $CMD, @TempDir, @SW_HIDE, $STDOUT_CHILD)

; wait until the process has closed
ProcessWaitClose($iPid)

; read the output from the first python check
Local $sOutput = StdoutRead($iPid)
;MsgBox($MB_SYSTEMMODAL, "Info", "output:" & $sOutput)

; see if we found a valid python3 version
Local $iPosition = StringInStr($sOutput, "Python 3.")
;MsgBox($MB_SYSTEMMODAL, "Info", "iPosition:" & $iPosition)

If $iPosition = 0 Then
; check if python3 is a valid command
$sPython = "python3"
$CMD = $sPython & " --version"
$iPid = Run(@ComSpec & " /c " & $CMD, @TempDir, @SW_HIDE, $STDOUT_CHILD)

; wait until the process has closed
ProcessWaitClose($iPid)

; read the output from the first python check
$sOutput = StdoutRead($iPid)
;MsgBox($MB_SYSTEMMODAL, "Info", "output:" & $sOutput)

$iPosition = StringInStr($sOutput, "Python 3.")
;MsgBox($MB_SYSTEMMODAL, "Info", "iPosition:" & $iPosition)

If $iPosition = 0 Then
MsgBox($MB_SYSTEMMODAL, "Warning", "Error: Could not find 'py' nor 'python3'. Please install Python3 before continuing.")
$sPython = ""
Endif
Endif

$CMD = "venv\Scripts\activate & py -m pip install --upgrade pip & pip install --upgrade meshtastic-flasher & meshtastic-flasher"
RunWait(@ComSpec & " /c " & $CMD)
; if we found a valid python
If $sPython <> "" Then
If Not FileExists("venv\") Then
$CMD = $sPython & " -m venv venv"
RunWait(@ComSpec & " /c " & $CMD)
Endif

$CMD = "venv\Scripts\activate & " & $sPython & " -m pip install --upgrade pip & pip install --upgrade meshtastic-flasher & meshtastic-flasher"
RunWait(@ComSpec & " /c " & $CMD)
EndIf
Binary file added winapp/meshtastic.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion winapp/readme.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Install AutoIt

Compile to x86 exe
Compile to x86 from the SciTE - Lite editor (right click on .au3 file and select "Edit")

0 comments on commit a62d4ab

Please sign in to comment.