From f0179ec96264c1c674a471a36ad585330b502562 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 11 Oct 2018 14:54:13 -0600 Subject: [PATCH] Show volume usage for all devices * Don't CoreStorage scans for failed devices * Fixes issue #25 --- .bin/Scripts/functions/data.py | 7 ++- .bin/Scripts/functions/hw_diags.py | 75 +++++++++++++++--------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/.bin/Scripts/functions/data.py b/.bin/Scripts/functions/data.py index 26f61645..029c674b 100644 --- a/.bin/Scripts/functions/data.py +++ b/.bin/Scripts/functions/data.py @@ -250,7 +250,9 @@ def get_mounted_volumes(): mounted_volumes.extend(item.get('children', [])) return {item['source']: item for item in mounted_volumes} -def mount_volumes(all_devices=True, device_path=None, read_write=False): +def mount_volumes( + all_devices=True, device_path=None, + read_write=False, core_storage=True): """Mount all detected filesystems.""" report = {} cmd = [ @@ -261,7 +263,8 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False): cmd.append(device_path) # Check for Apple CoreStorage volumes first - find_core_storage_volumes(device_path) + if core_storage: + find_core_storage_volumes(device_path) # Get list of block devices result = run_program(cmd) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 93b73bdb..4012cf2f 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -668,44 +668,43 @@ def post_drive_results(ticket_number): # Used space report.append('') report.append('Volumes:') - if dev_failed or dev_unknown: - report.append('Skipped due to error(s) above.') - else: - volume_report = mount_volumes( - all_devices=False, - device_path='/dev/{}'.format(name)) - for vol_path, vol_data in sorted(volume_report.items()): - vol_report = [ - vol_path, - '{q}{label}{q}'.format( - label=vol_data.get('label', ''), - q='"' if vol_data.get('label', '') else ''), - '{}'.format( - vol_data.get('size', 'UNKNOWN').upper()), - '{}'.format( - vol_data.get('size_used', 'UNKNOWN').upper()), - '{}'.format( - vol_data.get('size_avail', 'UNKNOWN').upper()), - ] - if vol_report[2][-1:] != 'N': - vol_report[2] = '{} {}B'.format( - vol_report[2][:-1], - vol_report[2][-1:]) - vol_report = [v.strip().replace(' ', '_') for v in vol_report] - for i in range(5): - pad = 8 - if i < 2: - pad += 4 * (2 - i) - vol_report[i] = pad_with_dots( - left_pad=False, - s='{s:<{p}}'.format( - s=vol_report[i], - p=pad)) - vol_report[-1] = re.sub(r'\.*$', '', vol_report[-1]) - vol_report = [v.replace('_', ' ') for v in vol_report] - line = '{}..{}..Total..{}..(Used..{}..Free..{})'.format( - *vol_report) - report.append(line) + core_storage = dev_passed and not dev_failed and not dev_unknown + volume_report = mount_volumes( + all_devices=False, + device_path='/dev/{}'.format(name), + core_storage=core_storage) + for vol_path, vol_data in sorted(volume_report.items()): + vol_report = [ + vol_path, + '{q}{label}{q}'.format( + label=vol_data.get('label', ''), + q='"' if vol_data.get('label', '') else ''), + '{}'.format( + vol_data.get('size', 'UNKNOWN').upper()), + '{}'.format( + vol_data.get('size_used', 'UNKNOWN').upper()), + '{}'.format( + vol_data.get('size_avail', 'UNKNOWN').upper()), + ] + if vol_report[2][-1:] != 'N': + vol_report[2] = '{} {}B'.format( + vol_report[2][:-1], + vol_report[2][-1:]) + vol_report = [v.strip().replace(' ', '_') for v in vol_report] + for i in range(5): + pad = 8 + if i < 2: + pad += 4 * (2 - i) + vol_report[i] = pad_with_dots( + left_pad=False, + s='{s:<{p}}'.format( + s=vol_report[i], + p=pad)) + vol_report[-1] = re.sub(r'\.*$', '', vol_report[-1]) + vol_report = [v.replace('_', ' ') for v in vol_report] + line = '{}..{}..Total..{}..(Used..{}..Free..{})'.format( + *vol_report) + report.append(line) # Post reply for drive osticket_post_reply(