Show volume usage for all devices
* Don't CoreStorage scans for failed devices * Fixes issue #25
This commit is contained in:
parent
3216c2f46b
commit
f0179ec962
2 changed files with 42 additions and 40 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue