(fname)
| 1004 | |
| 1005 | # http://stackoverflow.com/questions/580924/python-windows-file-version-attribute |
| 1006 | def win_get_file_properties(fname): |
| 1007 | propNames = ('Comments', 'InternalName', 'ProductName', |
| 1008 | 'CompanyName', 'LegalCopyright', 'ProductVersion', |
| 1009 | 'FileDescription', 'LegalTrademarks', 'PrivateBuild', |
| 1010 | 'FileVersion', 'OriginalFilename', 'SpecialBuild') |
| 1011 | |
| 1012 | props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None} |
| 1013 | |
| 1014 | import win32api |
| 1015 | # backslash as param returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struct |
| 1016 | fixedInfo = win32api.GetFileVersionInfo(fname, '\\') |
| 1017 | props['FixedFileInfo'] = fixedInfo |
| 1018 | props['FileVersion'] = "%d.%d.%d.%d" % (fixedInfo['FileVersionMS'] / 65536, |
| 1019 | fixedInfo['FileVersionMS'] % 65536, |
| 1020 | fixedInfo['FileVersionLS'] / 65536, |
| 1021 | fixedInfo['FileVersionLS'] % 65536) |
| 1022 | |
| 1023 | # \VarFileInfo\Translation returns list of available (language, codepage) |
| 1024 | # pairs that can be used to retrieve string info. We are using only the first pair. |
| 1025 | lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0] |
| 1026 | |
| 1027 | # any other must be of the form \StringfileInfo\%04X%04X\param_name, middle |
| 1028 | # two are language/codepage pair returned from above |
| 1029 | |
| 1030 | strInfo = {} |
| 1031 | for propName in propNames: |
| 1032 | strInfoPath = '\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName) |
| 1033 | # print str_info |
| 1034 | strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath) |
| 1035 | |
| 1036 | props['StringFileInfo'] = strInfo |
| 1037 | |
| 1038 | return props |
| 1039 | |
| 1040 | |
| 1041 | def get_computer_model(): |
no outgoing calls
no test coverage detected