I'm developing a script in Python 2.7. I want to make sure that the script is always up to date via github. What I've tried is to create a file on github where I put the latest version number in and then in the python script I download that file and compare it with the version number of the program. This is my current script but it doesn't really work:
import sys
import os
import urllib
current_version = """1.4"""
print ("\a")
print ("Checking for latest verion..")
urllib.urlretrieve ("https://raw.githubusercontent.com/[myname]/[myproject]/master/version_latest", "version_latest")
version = open('version_latest', 'r').read()
if version == current_version:
vlatest = "1"
else:
vlatest = "2"
if vlatest == 2:
print ("Please get the latest version of this program here:")
print ("https://github.com/[myname]/[myproject]")
print ("You can't use the program without it!")
print ("\a")
os.system("start https://github.com/[myname]/[myproject]")
raw_input("Press enter to exit")
sys.exit()
else:
print ("You have the latest verion! Program will start automaticly!")
Thanks for the help!
vlatest(which is a string) to the number2. Yourifwill always enter theelsebranch.