[feature] new 'restore' custom action

This commit is contained in:
Vinícius Moreira
2020-05-09 14:52:01 -03:00
parent 4bc4481e00
commit 7f4f2c805c
17 changed files with 106 additions and 27 deletions

View File

@@ -56,20 +56,28 @@ def get_distro():
return 'unknown'
def clean_app_files(managers: List[SoftwareManager]):
print('[bauh] Cleaning configuration and cache files')
def clean_app_files(managers: List[SoftwareManager], logs: bool = True):
if logs:
print('[bauh] Cleaning configuration and cache files')
for path in (CACHE_PATH, CONFIG_PATH):
print('[bauh] Deleting directory {}'.format(path))
if logs:
print('[bauh] Deleting directory {}'.format(path))
if os.path.exists(path):
try:
shutil.rmtree(path)
print('{}[bauh] Directory {} deleted{}'.format(Fore.YELLOW, path, Fore.RESET))
if logs:
print('{}[bauh] Directory {} deleted{}'.format(Fore.YELLOW, path, Fore.RESET))
except:
print('{}[bauh] An exception has happened when deleting {}{}'.format(Fore.RED, path, Fore.RESET))
traceback.print_exc()
if logs:
print('{}[bauh] An exception has happened when deleting {}{}'.format(Fore.RED, path, Fore.RESET))
traceback.print_exc()
if managers:
for m in managers:
m.clear_data()
print('[bauh] Cleaning finished')
if logs:
print('[bauh] Cleaning finished')