Skip to content

Commit 19cc3ff

Browse files
author
cfarrow
committed
Adding a '-silent' mode that does not throw up a dialog.
--HG-- extra : convert_revision : svn%3Aa2f44796-8cc0-49ac-b43f-6a96d556d52d/trunk%40583
1 parent 2afbd30 commit 19cc3ff

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

clear_comtypes_cache.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ def is_cache():
1010
return
1111
return comtypes.gen.__path__[0]
1212

13+
14+
def _remove(directory):
15+
shutil.rmtree(directory)
16+
print("Removed directory %s" % directory)
17+
18+
1319
install_text = """\
1420
When installing a new comtypes version, it is recommended to remove
1521
the comtypes\gen directory and the automatically generated modules
@@ -24,23 +30,32 @@ def is_cache():
2430
2531
Should this directory be removed?"""
2632

27-
if len(sys.argv) > 1 and sys.argv[1] == "-install":
33+
if len(sys.argv) > 1 and "-install" in sys.argv[1:]:
2834
title = "Install comtypes"
2935
text = install_text
3036
else:
3137
title = "Remove comtypes"
3238
text = deinstall_text
3339

40+
if len(sys.argv) > 1 and "-silent" in sys.argv[1:]:
41+
silent = True
42+
else:
43+
silent = False
44+
45+
3446

3547
IDYES = 6
3648
IDNO = 7
3749
MB_YESNO = 4
3850
MB_ICONWARNING = 48
3951
directory = is_cache()
4052
if directory:
41-
res = windll.user32.MessageBoxA(0, text, title, MB_YESNO|MB_ICONWARNING)
42-
if res == IDYES:
43-
shutil.rmtree(directory)
44-
print("Removed directory %s" % directory)
53+
if silent:
54+
_remove(directory)
4555
else:
46-
print("Directory %s NOT removed" % directory)
56+
res = windll.user32.MessageBoxA(0, text, title,
57+
MB_YESNO|MB_ICONWARNING)
58+
if res == IDYES:
59+
_remove(directory)
60+
else:
61+
print("Directory %s NOT removed" % directory)

0 commit comments

Comments
 (0)