Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically update python script

TL;DR I need a module which will automatically update my script in the background, silently.

I'm have a Python script which I distribute to users. I frequently update this, and then ask them to update it (via PIP). Obviously, this isn't a high priority for users, who just want to use the app, not think about updating it.

I'd like it to update my app automatically, like Google Chrome does, silently, in the background, automatically. Is there a library that allows me to do this already? If not, is there a straightforward way to use the PIP/distribute module to do it?

like image 399
Paul Biggar Avatar asked Sep 12 '11 18:09

Paul Biggar


2 Answers

If pip install already works for you, why can't you just do os.system("pip install -U myscript") at script startup? This is kinda dirty, but so is distributing via pip for non-developers.

like image 99
letitbee Avatar answered Sep 22 '22 23:09

letitbee


The easiest way to do this is to set up a web service which the script pings when it is run. The web service can return a version number, which the script can check against its own version number. If the version number is higher, it can update itself and re-run.

like image 45
asthasr Avatar answered Sep 20 '22 23:09

asthasr