30 lines
822 B
Python
30 lines
822 B
Python
|
import tempfile
|
||
|
import platform
|
||
|
import shutil
|
||
|
import glob
|
||
|
import os
|
||
|
|
||
|
|
||
|
def clear_selenium():
|
||
|
if platform.uname().system == 'Windows':
|
||
|
user_home = [os.environ.get('HOMEDRIVE'), os.environ.get('HOMEPATH')]
|
||
|
if user_home[0] and user_home[1]:
|
||
|
try:
|
||
|
shutil.rmtree('%s%s/.cache/selenium' % (user_home[0], user_home[1]))
|
||
|
except FileNotFoundError:
|
||
|
pass
|
||
|
|
||
|
def clear_driver_cache():
|
||
|
for cache in ['scoped_dir*', 'chrome_BITS*', 'chrome_url_fetcher*']:
|
||
|
for i in glob.glob('%s/%s' % (tempfile.gettempdir(), cache)):
|
||
|
try:
|
||
|
shutil.rmtree(i)
|
||
|
except (FileNotFoundError, PermissionError, WindowsError):
|
||
|
pass
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
# e.g. Clear
|
||
|
clear_selenium()
|
||
|
clear_driver_cache()
|