updated scan_disks()

* Renamed from get_attached_disk_info()
This commit is contained in:
Alan Mason 2017-11-30 22:10:45 -08:00
parent e9ff02375f
commit fbedd79aa3
3 changed files with 50 additions and 35 deletions

View file

@ -414,6 +414,7 @@ def try_and_print(message='Trying...',
and the result string will be printed in the correct color.
catch_all=False will result in unspecified exceptions being re-raised."""
err = None
out = None
w_exceptions = other_results.get('Warning', {}).keys()
w_exceptions = tuple(get_exception(e) for e in w_exceptions)
e_exceptions = other_results.get('Error', {}).keys()
@ -449,7 +450,7 @@ def try_and_print(message='Trying...',
if err and not catch_all:
raise
else:
return {'CS': not bool(err), 'Error': err}
return {'CS': not bool(err), 'Error': err, 'Out': out}
def upload_data(path, file):
"""Add CLIENT_INFO_SERVER to authorized connections and upload file."""

View file

@ -18,32 +18,6 @@ def assign_volume_letters():
except subprocess.CalledProcessError:
pass
def get_attached_disk_info():
"""Get details about the attached disks"""
disks = []
print_info('Getting drive info...')
# Get disks
disks = get_disks()
# Get disk details
for disk in disks:
# Get partition style
disk['Table'] = get_table_type(disk)
# Get disk name/model and physical details
disk.update(get_disk_details(disk))
# Get partition info for disk
disk['Partitions'] = get_partitions(disk)
for par in disk['Partitions']:
# Get partition details
par.update(get_partition_details(disk, par))
# Done
return disks
def get_boot_mode():
boot_mode = 'Legacy'
try:
@ -318,10 +292,30 @@ def remove_volume_letters(keep=None):
except subprocess.CalledProcessError:
pass
def select_disk(title='Which disk?'):
"""Select a disk from the attached disks"""
disks = get_attached_disk_info()
def scan_disks():
"""Get details about the attached disks"""
disks = get_disks()
# Get disk details
for disk in disks:
# Get partition style
disk['Table'] = get_table_type(disk)
# Get disk name/model and physical details
disk.update(get_disk_details(disk))
# Get partition info for disk
disk['Partitions'] = get_partitions(disk)
for par in disk['Partitions']:
# Get partition details
par.update(get_partition_details(disk, par))
# Done
return disks
def select_disk(title='Which disk?', disks):
"""Select a disk from the attached disks"""
# Build menu
disk_options = []
for disk in disks:

View file

@ -74,13 +74,21 @@ def menu_backup():
# Select destination
destination = select_backup_destination()
# Scan disks
try_and_print(message='Assigning letters...', function=assign_volume_letters, other_results=other_results)
result = try_and_print(message='Getting drive info...', function=scan_disks, other_results=other_results)
if result['CS']:
disks = result['Out']
else:
print_error('ERROR: No disks found.')
raise GenericAbort
# Select disk to backup
assign_volume_letters()
disk = select_disk('For which drive are we creating backups?')
disk = select_disk('For which drive are we creating backups?', disks)
if not disk:
raise GenericAbort
# "Prep" disk?
# "Prep" disk
prep_disk_for_backup(destination, disk, ticket_number)
# Display details for backup task
@ -205,9 +213,21 @@ def menu_setup():
# Find Windows image
windows_image = find_windows_image(bin, windows_version)
# Scan disks
try_and_print(message='Assigning letters...', function=assign_volume_letters, other_results=other_results)
result = try_and_print(message='Getting drive info...', function=scan_disks, other_results=other_results)
if result['CS']:
disks = result['Out']
else:
print_error('ERROR: No disks found.')
raise GenericAbort
# Select drive to use as the OS drive
assign_volume_letters()
dest_disk = select_disk('To which drive are we installing Windows?')
dest_disk = select_disk('To which drive are we installing Windows?', disks)
if not disk:
raise GenericAbort
# "Prep" disk
prep_disk_for_formatting(dest_disk)
# Display details for setup task