forked from enthought/comtypes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear_comtypes_cache.py
61 lines (48 loc) · 1.34 KB
/
clear_comtypes_cache.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
import os
import sys
import shutil
from ctypes import windll
def is_cache():
try:
import comtypes.gen
except ImportError:
return
return comtypes.gen.__path__[0]
def _remove(directory):
shutil.rmtree(directory)
print("Removed directory %s" % directory)
install_text = """\
When installing a new comtypes version, it is recommended to remove
the comtypes\gen directory and the automatically generated modules
it contains. This directory and the modules will be regenerated
on demand.
Should the installer delete all the files in this directory?"""
deinstall_text = """\
The comtypes\gen directory contains modules that comtypes
automatically generates.
Should this directory be removed?"""
if len(sys.argv) > 1 and "-install" in sys.argv[1:]:
title = "Install comtypes"
text = install_text
else:
title = "Remove comtypes"
text = deinstall_text
if len(sys.argv) > 1 and "-silent" in sys.argv[1:]:
silent = True
else:
silent = False
IDYES = 6
IDNO = 7
MB_YESNO = 4
MB_ICONWARNING = 48
directory = is_cache()
if directory:
if silent:
_remove(directory)
else:
res = windll.user32.MessageBoxA(0, text, title,
MB_YESNO|MB_ICONWARNING)
if res == IDYES:
_remove(directory)
else:
print("Directory %s NOT removed" % directory)