Ideas on self updating software?

Jonathan Ellis jbellis at gmail.com
Sun Sep 12 07:12:03 CEST 2004


Tom Cocagne wrote:
>  You might want to consider using a hashing algorithm in your scheme.

This is what I do.

> It
> would be relatively simple to create a python script to recurse
through all
> of the directories of your project and generate an md5 or sha hash
for each
> file. The (file_name, hash) pairs for the most current release could
then
> be made available to the client in any number of forms, including a
static
> web page. Once the client obtained this file, it could run the same
hashing
> calculation on it's own files and determine which ones were out of
date.
> Then all that would remain would be to obtain copies of the updated
files
> and replace the existing system files with those. Any number of
mechanisms
> could be used to get the updated files; XML-RPC, plain-old html (if
you
> don't care too much about speed), anonymous FTP, even e-mail (for
those of
> us behind uber-firewalls at work ;-)

I do it the other way around: client checks its FS and sends server the
list of modules + hashes; server checks for out of date files, or files
the client doesn't have at all, and tells the client where to download
files it needs.

Doing it this way you don't need a database at all; you just need the
current files on the server so it can hash them.  This is a HUGE win
for simplicity.

>  One thing to keep in mind is that if you're not planning on shipping
the
> entire Python interpreter and/or 3rd-party extention modules with
your
> application, the entire project will likely be quite small when
> tar/gzipped. Why not bundle up the entire thing in a zip file, make
it
> available via anonymous FTP, and then write a small script to get the
new
> file, uninstall the old version, and install the new version?

In practice, even "small" applications have a pretty substantial amount
of code that goes along with them, e.g. all the stdlib files you use,
if you're packaging with py2exe.  My application is under 3k loc, but
the .zip py2exe generates is almost 1MB.  That's going to cause dialup
users enough pain to make it worth my while to be smart about the
updating process.

-Jonathan




More information about the Python-list mailing list