Reputation:
I'm making a game using the (very) old Python library, PyGame. But that's not what I'm here to ask about.
How do I make a code that would check the repositories in a server with the latest build, check if the build is newer or the same, and if newer prompt the user to download (or deny) the update of the game, as it will be developed in multiple versions and will allow players to gradually update as we make changes.
Like Minecraft does once an update comes out and it prompts you to update... But in Python
Upvotes: 1
Views: 443
Reputation: 7078
There are 3 things you need for this:
A server where you will store all the information about the updates and versions.
flask
, web.py
, django
, pylons
, etc., or PHP or whatever) which can have a single page.GET
/POST
requests) and output the updates available (in a format that can be parsed, JSON
preferably, or XML or just plain text).MySQL
, postgresql
, or any ORM that works with your choice of web server, sqlalchemy
)XXX-r24-20121224.tar.gz
and you'll check the list of files with glob
or something).A piece of code that will query the server every time you start your game to check with the web server if there are updates. You can use requests
or urllib2
for example.
A piece of code that will download and update your actual game.
requests
or urllib2
)zipfile
or tarfile
) and replace your actual files with that.zipfile
package and Python actually account for that, and they give you an option to only put the python files in the zip file and Python gives you an option to add said zip file to the PYTHONPATH
and import directly from there.py2exe
or anything, it'll be a different issue: you might be able to only update one zip file, or replace the actual DLLs and stuff, which might be a big mess.I hope this helps, even if it's very abstract. This had to be done :)
Now I'll give my own (biased) opinion: If you already have a website running, use that to add a single page for such a thing. Otherwise I'd recommend a free hosting that will allow you to set up a website using flask. I'd recommend that because it would be very easy to get it running in no time, plus it will allow you to use the great ORM sqlAlchemy. Also, I wouldn't bother with more than telling the user there is a new version and let them figure out where to get it. That's unless you are only distributing it in one standard way all over.
Upvotes: 1