Allow BleachBit to be run more than once per day

This commit is contained in:
2Shirt 2018-08-30 11:27:47 -07:00
parent b043b63d2d
commit 7d1850a480
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -371,38 +371,35 @@ def run_aida64():
def run_bleachbit(cleaners=None, preview=True): def run_bleachbit(cleaners=None, preview=True):
"""Run BleachBit preview and save log. """Run BleachBit preview and save log.
This is a preview so no files should be deleted.""" If preview is True then no files should be deleted."""
if not os.path.exists(global_vars['LogDir']+r'\BleachBit.log'): error_path = r'{}\BleachBit.err'.format(global_vars['LogDir'])
debug_path = r'{}\BleachBit.debug'.format(global_vars['LogDir']) log_path = error_path.replace('err', 'log')
error_path = debug_path.replace('debug', 'err') extract_item('BleachBit', silent=True)
log_path = debug_path.replace('debug', 'log')
extract_item('BleachBit', silent=True)
# Safety check # Safety check
if not cleaners: if not cleaners:
# Disable cleaning and use preset config # Disable cleaning and use preset config
cleaners = ['--preset'] cleaners = ['--preset']
preview = True preview = True
# Run # Run
cmd = [ cmd = [
global_vars['Tools']['BleachBit'], global_vars['Tools']['BleachBit'],
'--preview' if preview else '--clean', '--preview' if preview else '--clean']
'--debug-log="{}"'.format(debug_path)] cmd.extend(cleaners)
cmd.extend(cleaners) out = run_program(cmd, check=False)
out = run_program(cmd, check=False)
# Save stderr # Save stderr
if out.stderr.decode().splitlines(): if out.stderr.decode().splitlines():
with open(error_path, 'a', encoding='utf-8') as f: with open(error_path, 'a', encoding='utf-8') as f:
for line in out.stderr.decode().splitlines(): for line in out.stderr.decode().splitlines():
f.write(line.strip() + '\n')
# Save stdout
with open(log_path, 'a', encoding='utf-8') as f:
for line in out.stdout.decode().splitlines():
f.write(line.strip() + '\n') f.write(line.strip() + '\n')
# Save stdout
with open(log_path, 'a', encoding='utf-8') as f:
for line in out.stdout.decode().splitlines():
f.write(line.strip() + '\n')
def show_disk_usage(disk): def show_disk_usage(disk):
"""Show free and used space for a specified disk.""" """Show free and used space for a specified disk."""
print_standard('{:5}'.format(disk.device.replace('/', ' ')), print_standard('{:5}'.format(disk.device.replace('/', ' ')),