-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChromeVersion.py
74 lines (57 loc) · 2.26 KB
/
ChromeVersion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from win32 import win32api
def getFileProperties(fname):
"""
Read all properties of the given file return them as a dictionary.
"""
propNames = (
"Comments",
"InternalName",
"ProductName",
"CompanyName",
"LegalCopyright",
"ProductVersion",
"FileDescription",
"LegalTrademarks",
"PrivateBuild",
"FileVersion",
"OriginalFilename",
"SpecialBuild",
)
props = {"FixedFileInfo": None, "StringFileInfo": None, "FileVersion": None}
try:
# backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
fixedInfo = win32api.GetFileVersionInfo(fname, "\\")
props["FixedFileInfo"] = fixedInfo
props["FileVersion"] = "%d.%d.%d.%d" % (
fixedInfo["FileVersionMS"] / 65536,
fixedInfo["FileVersionMS"] % 65536,
fixedInfo["FileVersionLS"] / 65536,
fixedInfo["FileVersionLS"] % 65536,
)
# \VarFileInfo\Translation returns list of available (language, codepage)
# pairs that can be used to retreive string info. We are using only the first pair.
lang, codepage = win32api.GetFileVersionInfo(
fname, "\\VarFileInfo\\Translation"
)[0]
# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
# two are language/codepage pair returned from above
strInfo = {}
for propName in propNames:
strInfoPath = u"\\StringFileInfo\\%04X%04X\\%s" % (lang, codepage, propName)
## print str_info
strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)
props["StringFileInfo"] = strInfo
except:
pass
return props
chrome_browser = (
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
) # -- ENTER YOUR Chrome.exe filepath
# returns whole string of version
cb_dictionary = getFileProperties(chrome_browser)
# substring version to capabable version
chrome_browser_version = cb_dictionary["FileVersion"][:2]
# grabs the next version of the chrome browser
nextVersion = str(int(chrome_browser_version) + 1)
# grabs the last version of the chrome browser
lastVersion = str(int(chrome_browser_version) - 1)