(free) Version Check Script

Hello PythonHeads,

I’m unknown when it comes to programming so I’ll just give a short summary of what I’ve tried to do with Python already:

  • Make a small RPG game (Python console, no MMO offcourse)
  • Install the ‘Mouse Look’ script from the Blender documentation onto a camera, it didn’t work out that well but it worked!
  • Install and modify a re-written camera collision script based on a tutorial by Blending-Online.co.uk
  • Create a version check script!The script
    I’ve made the script using the Python IDLE and it’s not using Blender. I’ve used Tkinter for the interface/application window. Tkinter runs on almost all platforms (I read that) .
    I hope you like it.

    Download here


#Made using the Tkinter "Hello" tutorial and Introduction to Tkinter online version.
#modified by Christiaan "AniCator" Bakker
#version 0.8.2
#Do not change the version.txt file, if you do there is a lot of chance you can't connect to the server.

from urllib2 import Request, urlopen, URLError, HTTPError
from Tkinter import *
import os
import time

root = Tk()
frame = Frame(width=300, height=100, borderwidth=1)
print 'This version checker was programmed by Christiaan "AniCator" Bakker.'
print 'Version: 0.8.2'

#exit code
def exitnow():
#application code
class Application(Frame):
    def check(self):
        frame.checker = Label(frame, width=40, relief=SUNKEN)
        frame.checker["text"]='Downloading versionfile.txt'
        #request the file
        request = urlopen("http://uploader.polorix.net/files/114/versionfile.txt")
            #read the file
            readremote = request.read()
            print 'File downloaded.'
            print 'Remote version: ' ,readremote
            frame.checker["text"]= 'Remote version: ', readremote
        except URLError, e:
            #if an error occurs this code will be executed
            print e.code
            print e.read()
            print 'Unable to download file!'
            frame.checker["text"]='Unable to download the file.'
        frame.localcheck = Label(frame, width=40, relief=SUNKEN)
        print "Requesting local 'version.txt'"
        #request the local file
        requestlocal = open('version.txt', 'r')
        readlocal = requestlocal.read()
        print 'Local version: ', readlocal
        frame.localcheck["text"]='Local version: ', readlocal
        frame.matchcheck = Label(frame, width=45, relief=SUNKEN)
        if (readlocal==readremote):
            print "It's a MATCH!"
            frame.matchcheck["text"]='You have the right version!'
            print "Initiating the game!"
            print os.system('Area1_fix05.blend')
            print "You're game is old...zzz..or ur a hacker! that tried to change the version.txt, bad thing that is"
            frame.matchcheck["text"]='You got an older version.'
    def createWidget(self):
        #'Check and Play' button
        self.check1 = Button(frame, width=40, height=4)
        self.check1["text"] ='Check & Play'
        self.check1["command"] = self.check
        print 'Check button initiated.'
        self.check1.grid(row=0, columnspan=2)

    def __init__(self, master=None):
        #initiate the widget
        Frame.__init__(self, master)

#menu code
menu = Menu(root)

filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="Exit", command=exitnow)

#initialize the program
app = Application(master=root)
app.master.title("Kalith Version Checker v0.8.2")


I haven’t spend much time on optimizing. I’ve debugged a lot of my own mistakes but I haven’t encountered a lot of bugs since version 0.6. The only bug I noticed is that when you use the version checker to startup an application made with a certain line Python ‘quit code’, the application will startup everytime you quit it. I have tried to avoid this but the Python application runs on the process of the version checker. I almost forgot to mention that I couldn’t get the application to sleep for a few seconds so only the console shows the results but the Tkinter interface can’t keep up. It’s probably because of the line containing ‘time.sleep(5)’. Remove this line if possible. This script is still not complete but it’s almost done. It works! Partially.

This script was programmed by Christiaan “AniCator” Bakker, do not re-use this script.
You may only use this script when you’ve modified it. Do not remove the comments that exist in the script.

Have Fun!
- AniCator

No comments?