Skip to content

Commit 5469980

Browse files
authored
Os arquivos das funções
1 parent d22733f commit 5469980

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

checkprocess.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import psutil
2+
3+
def checkprocess(targetname):
4+
for proc in psutil.process_iter():
5+
try:
6+
if targetname.lower() in proc.name().lower():
7+
return True
8+
except (psutil.NoSuchProcess, psutil.AccessDenied,
9+
psutil.ZombieProcess):
10+
pass
11+
return False

getfileprops.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import win32api
2+
3+
def get_file_properties(fname):
4+
prop_names = ('Comments', 'InternalName', 'ProductName',
5+
'CompanyName', 'LegalCopyright', 'ProductVersion',
6+
'FileDescription', 'LegalTrademarks', 'PrivateBuild',
7+
'FileVersion', 'OriginalFilename', 'SpecialBuild')
8+
9+
props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None, 'FileDescription': None}
10+
11+
fixed_info = win32api.GetFileVersionInfo(fname, '\\')
12+
props['FixedFileInfo'] = fixed_info
13+
props['FileVersion'] = "%d.%d.%d.%d" % (fixed_info['FileVersionMS'] / 65536,
14+
fixed_info['FileVersionMS'] % 65536,
15+
fixed_info['FileVersionLS'] / 65536,
16+
fixed_info['FileVersionLS'] % 65536)
17+
18+
# \VarFileInfo\Translation returns list of available (language, codepage)
19+
# pairs that can be used to retreive string info. We are using only the first pair.
20+
lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]
21+
22+
# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
23+
# two are language/codepage pair returned from above
24+
25+
str_info = {}
26+
for propName in prop_names:
27+
str_info_path = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
28+
str_info[propName] = win32api.GetFileVersionInfo(fname, str_info_path)
29+
30+
props['StringFileInfo'] = str_info
31+
# except:
32+
# pass
33+
34+
return props

0 commit comments

Comments
 (0)