updated prep_disk_for_formatting()

This commit is contained in:
Alan Mason 2017-11-30 22:19:31 -08:00
parent fbedd79aa3
commit 6903078ee0

View file

@ -248,18 +248,28 @@ def prep_disk_for_formatting(disk=None):
if len(disk['Partitions']) == 0: if len(disk['Partitions']) == 0:
disk['Format Warnings'] += 'No partitions found\n' disk['Format Warnings'] += 'No partitions found\n'
for par in disk['Partitions']: for par in disk['Partitions']:
if 'Letter' not in par or re.search(r'(RAW|Unknown)', par['FileSystem'], re.IGNORECASE): display = ' Partition {num:>{width}}:\t{size} {fs}'.format(
# FileSystem not accessible to WinPE. List partition type / OS info for technician num = par['Number'],
par['Display String'] = ' Partition {Number:>{width}}:\t{Size} {FileSystem}\t\t{q}{Name}{q}\t{Description} ({OS})'.format( width = width,
width=width, size = par['Size'],
q='"' if par['Name'] != '' else '', fs = par['FileSystem'])
**par)
if 'Letter' not in par or REGEX_BAD_PARTITION.search(par['FileSystem']):
# Set display string using partition description & OS type
display += '\t\t{q}{name}{q}\t{desc} ({os})'.format(
display = display,
q = '"' if par['Name'] != '' else '',
name = par['Name'],
desc = par['Description'],
os = par['OS'])
else: else:
# FileSystem accessible to WinPE. List space used instead of partition type / OS info for technician # List space used instead of partition description & OS type
par['Display String'] = ' Partition {Number:>{width}}:\t{Size} {FileSystem} (Used: {Used Space})\t{q}{Name}{q}'.format( display += ' (Used: {used})\t{q}{name}{q}'.format(
width=width, used = par['Used Space'],
q='"' if par['Name'] != '' else '', q = '"' if par['Name'] != '' else '',
**par) name = par['Name'])
# For all partitions
par['Display String'] = display
def reassign_volume_letter(letter, new_letter='I'): def reassign_volume_letter(letter, new_letter='I'):
if not letter: if not letter:
@ -320,7 +330,7 @@ def select_disk(title='Which disk?', disks):
disk_options = [] disk_options = []
for disk in disks: for disk in disks:
display_name = '{Size}\t[{Table}] ({Type}) {Name}'.format(**disk) display_name = '{Size}\t[{Table}] ({Type}) {Name}'.format(**disk)
if len(disk['Partitions']) > 0: if disk['Partitions']:
pwidth=len(str(len(disk['Partitions']))) pwidth=len(str(len(disk['Partitions'])))
for par in disk['Partitions']: for par in disk['Partitions']:
# Show unsupported partition(s) in RED # Show unsupported partition(s) in RED