I'm trying to detect if a software version is up to date and I'm doing this by using the following code in Python 3.3:
if str(version) in str(buildno):
print("Your software version is up to date. \n")
else:
print("Your software is out of date. Updating your software. \n")
However, it keeps updating the software even when it is up to date. I've also tried the code variation:
if str(version) in str(buildno) == True:
print("Your software version is up to date. \n")
else:
print("Your software is out of date. Updating your software. \n")
if os == "Windows":
subprocess.call("windowsUpgrade.sh", shell=True)
which also does not work. Is the method I'm using workable or should I be taking another approach to this problem?
>>> print(version)
4.3.0-18107
>>> print(buildno)
('4.3.0-18107', 1)
Thank you for any answers provided.
buildnoandversionare. This code is fine.buildnois not inversion. :D The first version is fine.str(buildno[0]) in str(version)'4.3.0-1'is in'4.3.0-11', but presumably isn't up-to-date. Depending on your version numbering strategy, you might want to make a tuple of ints to compare.