OTA Update of Python Scripts?

7 thoughts on “OTA Update of Python Scripts?

  1. I am attempting to implement over-the-air update of python scripts.  The basic technique is:


    • download new script files and verify checksums
    • overwrite existing script files with downloaded files
    • reboot module 


    The problem is that the script that is running needs to overwrite itself (and any import files it uses) in NVM before rebooting.  I am NOT surprised that I get an IOError if I try to use in Python:

    open("<name-of-the-running-script.py or .pyo>", "w")


    I assume that the system locks out the file that is in use.  What is a technique that I can use to  update my scripts remotely?




      1. Thank you for pointing this out.  Is this script intended to run separately from the script to be updated?  My direct question is: can the currently running script modify its own file (py or pyo) and then reboot to have the new file take effect?


        I will try out the example code today. 

      2. What is the entry point for OTAFTP.py?  Is it updateManager()?

        Also,  the method ExtractCurrFile() will not work because "AT#ESCRIPT" is not a valid command.  Shoutd the command be "AT#ESCRIPT?" to get the active file?  


        Why does it look for "UPD" in the enabled script name? 


        Is there a description of  this example somewhere?

        1. Yes updateManager is the entry function.


          Note: issuing AT#ESCRIPT<CR> is the same as issuing the Read command.


           The script checks if the file version included in the file name is older  (coded after UPD char in the filename) than the file name received in the SMS, if yes proceeds with the upgrade.


          It doesn’t use the same file [name] to be run at startup, it advances the version number in the name and uses #ESCRIPT to enable the new file to be run at the next startup after reboot.

          1. Hmm… in my module, ESCRIPT does not behave that way:





            +CME ERROR: operation not supported 




            I can convert this to a read. 



          2. It works with #SELINT=0,1, newer modules have #SELINT=2 by default. Simply change the code to "AT#ESCRIPT?".