Jump to content

Recommended Posts

I've been working for quite a while on an automated installer for python3.8.3 and Thonny3.2.7 and encountered a pretty strange problem - automated python install work perfectly. However using pip to install esptool returns error code 1. The strange thing is if i manually install it after running the python installer it does indeed install correctly (returns 0 instead).

The code i was using:

Local Const $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"

Local $PythonResult = RunWait($sInstallerPath & " /quiet")

Local $ESPToolResult = RunWait(@ComSpec & " /c " & "pip install esptool")

MsgBox(0, "Installer returns", "Python result: " & $PythonResult & @CRLF & "esptool result: " & $ESPToolResult)

Than I thought that maybe python installer fires off multiple processes during installation and tried :

Local Const $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"

Local $iPID = Run($sInstallerPath & " /quiet")
Local $PythonResult = ProcessWaitClose($iPID)

Local $ESPToolResult = RunWait(@ComSpec & " /c " & "pip install esptool")

MsgBox(0, "Installer returns", "Python result: " & $PythonResult & @CRLF & "esptool result: " & $ESPToolResult)

However, The problem still remains. some-why esptool install refuses to be automated with python but if i comment out the python install part it does work ?! (note that i comment it out after the script already installed python and did not manually install it myself).

Any idea why this happens ?

NOTE: I added the unattend.xml file im using but python.exe was too big - I'm using python3.8.3 for compatibility with thonny and the unattend files makes a minimal install just for thonny to work (target platform esp32 with micopython)

unattend.xml

Share this post


Link to post
Share on other sites

Have you tried using #RequireAdmin also have you tried using the full path to pip in the command line, example: 

RunWait(@Comspec & ' /c "C:\Program Files\Python38\Scripts\pip.exe" install esptool')

 

Share this post


Link to post
Share on other sites

I did use RequireAdmin sorry for not adding it in the code above. Also if you look at the unattend.xml I added it does add python to path so there is no need to specify the path and I can simply call "pip install esptool" from cmd with no additional path so it does work.

Share this post


Link to post
Share on other sites

What I have found in the past is the script only recognizes environment variables that are available at the time of execution.  If you re-run the script it will recognize the updated environment variables.  I downloaded the latest Python-3.8.3.exe 32-bit and used the following which worked fine for me.

#RequireAdmin
Local $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"
RunWait($sInstallerPath & " /quiet")
RunWait(@ComSpec & ' /c "C:\Program Files (x86)\Python38-32\Scripts\pip.exe" install esptool')

 

Share this post


Link to post
Share on other sites

I can't currently test it. However, its strange because the python installer should use "add to path" making it available on execution because esptool is installed later.

I will try your solution. The only problem is its not portable for all users as some may choose a different install directory which is why I wanted to make use of the "add to path" feature in the execution which should work as its done with the python installer making it available in cmd straight after with pip.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By learner123
      Hi All,
       
      I am new to this AUTO IT and I have created a script that will open an app,enter pin and copy the code generated to clipboard. My java code call this autoIT script and use the copied generated code from clipboard.
      This works fine when server  window is on focus. My server is an windows server. 
      But when I minimize or disconnect the server, the script opens the app.exe but doesn't copy any value to clipboard.  
      Can anyone help me on this 😐
       
      Run("C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe")
      Local $hWnd=WinWait("abc - RSA SecurID Token") ; waits until the window is the active window
      $hWin = WinGetHandle("abc - RSA SecurID Token");
      ControlSend($hWnd,"","","1111") ; simulates pressing the Home key
      ControlSend($hWnd,"","","{ENTER}");
      ControlSend($hWnd,"","","^c");
      Sleep(1000) ;
      ControlSend($hWnd,"","","^c");
       
    • By somebadhat
      Restore blank Windows 10 start menu icons.
      ; RESTORE BLANK WINDOWS 10 START MENU ICONS. ; TOGGLE SETTINGS-START-"USE START FULL SCREEN" TWICE ; THIS WILL RESTORE SOME OF THE BLANK ICONS ; FOR THOSE THAT IT DOES NOT REDO "CHANGE ICON" FROM THE PROPERTIES DIALOG BOX FOR EACH MISSING ICON. ; "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "F:\MYAPPS\WINDOWS\StartMenu1.au3" ; windows 10 and autoit3 ; begin restore blank icons on start menu Run(@ComSpec & " /c start ms-settings:personalization-start", "", @SW_SHOWMINIMIZED) Sleep(500) WinWaitActive("Settings") Sleep(1000) ; WinWaitActive ("[CLASS:ApplicationFrameInputSinkWindow]", "") ; ; BEGIN https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ $Computer = "8.8.8.8" AutoItSetOption ("SendKeyDelay" , "125") ;was 55, 500 If RunWait("ping.exe -n 1 " & $Computer, "", @SW_HIDE) == 0 Then WinActivate("Settings") send("{tab}{down 5}{tab 6}") sleep(500) send("{space}{tab 10}") ; if online. Move to "use start full screen", toggle it and (improves reliability) return cursor to "find a setting" search box. Else WinActivate("Settings") send("{tab}{down 5}{tab 6}") sleep(500) send("{space}{tab 6}") ; if offline. Move to "use start full screen", toggle it and (improves reliability) return cursor to "find a setting" search box. EndIf ; END https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ ; ; MouseClick("left", 379, 490, 1, 0) ; Toggle "use start full screen". Autoitv3 Window Info MouseClick Coords are 23px north. If y=467 use y=490 Sleep(500) ; Msgbox(0,"Operation halted","Continue?") ; PAUSE FOR DEBUG ; WinClose("[CLASS:ApplicationFrameWindow]", "") ; Send("{LWIN 2}") ; OPEN AND CLOSE THE START MENU Send("{LWIN}") ; OPEN START MENU sleep(500) Send("{LWIN}") ; CLOSE START MENU Sleep(1000) ; Run(@ComSpec & " /c start ms-settings:personalization-start", "", @SW_SHOWMINIMIZED) ; Sleep(500) ; WinWaitActive ("Settings") ; WinWaitActive ("[CLASS:ApplicationFrameInputSinkWindow]", "") ; ; BEGIN https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ $Computer = "8.8.8.8" AutoItSetOption ("SendKeyDelay" , "125") ;was 125, 55, 500 If RunWait("ping.exe -n 1 " & $Computer, "", @SW_HIDE) == 0 Then WinActivate("Settings") sleep(500) send("{tab 7}") ; if online. Move to "use start full screen", sleep(500) send("{space}{tab 10}") ; if online. Toggle "use start full screen" and (improves reliability) return cursor to "find a setting" search box. Else WinActivate("Settings") sleep(500) send("{tab 7}") ; if offline. Move to "use start full screen", sleep(500) send("{space}{tab 6}") ; if offline. Toggle "use start full screen" and (improves reliability) return cursor to "find a setting" search box. EndIf ; END https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ ; ; MouseClick("left", 379, 490, 1, 0) ; Toggle "use start full screen". Autoitv3 Window Info MouseClick Coords are 23px north. If y=467 use y=490 Sleep(500) ; Msgbox(0,"Operation halted","Continue?") ; PAUSE FOR DEBUG WinClose("[CLASS:ApplicationFrameWindow]", "") ; end restore blank icons on start menu Exit
    • By pete_wilde
      Hi Guys,
      I am trying to convert a python script to AutoIT, but it is not returning any data.

      My aim is to eventually have a script which sends me an email whenever a goal is scored in the English Premiership.
      Is there any guru who can have a quick look over the below script and see if there are any obvious errors?
      To use a football analogy, I think that I have hit the bar a couple of times, but not yet found the back of the net! 
      #cs ---------------------------------------------------------------------------- PYTHON CODE: import requests import json endpoint = "https://api.betfair.com/exchange/betting/rest/v1.0/" header = { 'X-Application' : 'APP_KEY_HERE', 'X-Authentication' : 'SESSION_TOKEN_HERE' ,'content-type' : 'application/json' } json_req='{"filter":{ }}' url = endpoint + "listEventTypes/" response = requests.post(url, data=json_req, headers=header) print json.dumps(json.loads(response.text), indent=3) #ce ---------------------------------------------------------------------------- #include <WinHttp.au3> Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) Global $sAddress = 'https://api.betfair.com/exchange/betting/json-rpc/v1/' Global $sPostData = 'https://api.betfair.com/exchange/betting/json-rpc/v1/listEventTypes/' Global $sAppKey = '4YpsEhdsgtedjd' Global $sSession_key = 'BhKl7Ijdu4E3pzHhKu7K5fQrvzf9p3wq/diRMt7bZka7' Global $sjson_req = '{"filter":{ }}' Global $hOpen = _WinHttpOpen() ; Get Session handle ; ##### CHECKED AND VALID HANDLE IS RETURNED ##### Global $hConnect = _WinHttpConnect($hOpen, $sAddress) ; Get connection handle ; ##### CHECKED AND VALID HANDLE IS RETURNED ##### Global $hRequest = _WinHttpOpenRequest($hConnect, 'POST') ; Make a request ; ##### CHECKED AND VALID HANDLE IS RETURNED ##### ; Add header fields to the request _WinHttpAddRequestHeaders($hRequest, 'X-Application: ' & $sAppKey) _WinHttpAddRequestHeaders($hRequest, 'X-Authentication: ' & $sSession_key) _WinHttpAddRequestHeaders($hRequest, 'Accept: application/json') _WinHttpAddRequestHeaders($hRequest, 'Content-Type: application/json') _WinHttpSendRequest($sPostData, 'Data=' & $sjson_req, $hRequest) ; Send it _WinHttpReceiveResponse($hRequest) ; Wait for the response ; Check if there is a response Global $sHeader, $sReturned If _WinHttpQueryDataAvailable($hRequest) Then $sHeader = _WinHttpQueryHeaders($hRequest) MsgBox(64, 'Header', $sHeader) Do $sReturned &= _WinHttpReadData($hRequest) Until @error ConsoleWrite($sReturned) ; Print returned Else ConsoleWriteError('!No data available.' & @CRLF) MsgBox(48, 'Failure', 'No data available.') ;##### <==== ALWAYS FAILS HERE! ##### EndIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I am sure that I have probably missed out a vital line, but for the life of me I can't see the wood for the trees anymore.
      Anyone got any suggestions?
      Many thanks,
      Pete
    • By NSUSpray
      - file scope in AutoIt programs
      - module-private functions and variables
      - python-like import operator
      Code is 10% lighter!
      This inconspicuous wrapper complements the AutoIt language with
      preprocessor keyword #import in addition to #include similar to import in Python Python-like blocking by lines indentation (without endfunc, wend etc.) dim and const outside of functions means global and global const respectively, inside of functions means local and local const arguments of function are const by default, but with dim prefix it becomes variable short synonyms for functions as a rule using in large projects: for arrays, files and strings no “$”-prefix in variable names ; file “mylib.aup” dim bar, _bar func foo() bar = _foo() func _foo(dim str="word/number/space") _bar = Sort(Split(str, "/", @NoCount)) ; file “main.aup” #import "mylib.aup" In this example variable _bar and function _foo() are private for module mylib.aup (names begin with an underscore) and not visible in main.aup. Variable bar and function foo() will be visible with the “mylib:” prefix:
      ; file “main.aup” #import "mylib.aup" bar = foo() ; error: no bar and foo() in this scope mylib:bar = mylib:foo() ; OK: bar and foo() are public in “mylib” scope mylib:_bar = mylib:_foo() ; error: _bar and _foo() are private in “mylib” scope Sort is synonym for _ArraySort, Split is synonym for StringSplit, @NoCount is synonym for $STR_NOCOUNT.
      All synonyms
      How to use this wrapper
      Place the “plys.au3” file in the “Include” folder (C:\Program Files (x86)\AutoIt3\Include\). Make in your project folder au3-file with this content #include <plys.au3> #plys "MainFileOfMyProject.aup" ; run me!  
      Then, if you have the files module1.aup and module2.au3 with the same names ; module1.aup dim bar, _bar func foo() ; instructions ; module2.au3 global $bar func foo() ; instructions endfunc func _foo() ; instructions endfunc you can write in your program like this ; MainFileOfMyProject.aup #import "module1.aup" #import "module2.au3" module1:bar = module2:foo() ;module1:_bar = module2:_foo() ; error because _bar and _foo() are private (with underscore prefix) #import "module2.au3" ; re-importing files without "#include-once" will not lead to errors  
      You can turn off data exchange through standard input/output streams, then the shell process will not hang in memory, but then you will not be able to observe the output of your program in the output window of your development environment. You can do this by adding a line to the main file of your program
      #plys nostdio You can disable autorun of your program altogether, keeping only the generation of executable files, for example, for further compilation, adding the line to the main file of your program
      #plys norun Then you can compile the program, specifying to the compiler the resulting file main.aup.au3, if the main file of your program is called main.aup.
      File processing is pretty dumb, so bugs are possible.
      How it works
      The plys.au3 file contains the code that is run immediately after the launch of your program: files are automatically processed, after which the new AutoIt process interprets the already converted code, and the current process remains cycle to continue data exchange with the new process via standard streams. This handler replaces all #import with #include. The processed files get the extension .aup.au3 and are placed in the folder of the original script with hidden attribute.
      One more example
      TODO
      #import from "filename.aup" #import from "mylib.aup" bar = foo() ; bar and foo will be taken from the "mylib.aup" #import "filename.aup" as alias #import "mylib.aup" as ml ml:bar = ml:foo() ; bar and foo will be taken from the "mylib.aup" Optimize translation speed Download
      Current version https://github.com/NSUSpray/plys
      Old version (import only): import
    • By gahhon
      I only found that AutoIt can actually execute the entire python script or execute the .exe (converted to .exe from .py)
      But what if I just want call the particular function? If that possible to do so?
      This is because python can't create fancy GUI like AutoIT does. So my plan is use AutoIT to have fancy GUI.
      Then each buttons will trigger specific function in the python script or .exe file.
      For instances:
      btnSum - trigger function in python script or .exe file (funcSum)
      btnMinus - trigger function in python script or .exe file (funcMinus)
       
      Thanks for advance information.
×
×
  • Create New...