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

View file

@ -18,32 +18,6 @@ def assign_volume_letters():
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass 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(): def get_boot_mode():
boot_mode = 'Legacy' boot_mode = 'Legacy'
try: try:
@ -318,10 +292,30 @@ def remove_volume_letters(keep=None):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass pass
def select_disk(title='Which disk?'): def scan_disks():
"""Select a disk from the attached disks""" """Get details about the attached disks"""
disks = get_attached_disk_info() 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 # Build menu
disk_options = [] disk_options = []
for disk in disks: for disk in disks:

View file

@ -74,13 +74,21 @@ def menu_backup():
# Select destination # Select destination
destination = select_backup_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 # Select disk to backup
assign_volume_letters() disk = select_disk('For which drive are we creating backups?', disks)
disk = select_disk('For which drive are we creating backups?')
if not disk: if not disk:
raise GenericAbort raise GenericAbort
# "Prep" disk? # "Prep" disk
prep_disk_for_backup(destination, disk, ticket_number) prep_disk_for_backup(destination, disk, ticket_number)
# Display details for backup task # Display details for backup task
@ -205,9 +213,21 @@ def menu_setup():
# Find Windows image # Find Windows image
windows_image = find_windows_image(bin, windows_version) 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 # Select drive to use as the OS drive
assign_volume_letters() dest_disk = select_disk('To which drive are we installing Windows?', disks)
dest_disk = select_disk('To which drive are we installing Windows?') if not disk:
raise GenericAbort
# "Prep" disk
prep_disk_for_formatting(dest_disk) prep_disk_for_formatting(dest_disk)
# Display details for setup task # Display details for setup task