diff --git a/Scripts/functions/backup.py b/Scripts/functions/backup.py index 62e45d19..4ab89a43 100644 --- a/Scripts/functions/backup.py +++ b/Scripts/functions/backup.py @@ -105,35 +105,37 @@ def prep_disk_for_backup(destination, disk, ticket_number): COLORS['YELLOW'], COLORS['CLEAR']) disk['Backup Warnings'] = warnings -def select_backup_destination(): +def select_backup_destination(auto_select=True): # Build menu - dests = [] - for server in BACKUP_SERVERS: - if server['Mounted']: - dests.append(server) + destinations = [s for s in BACKUP_SERVERS if s['Mounted']] actions = [ {'Name': 'Main Menu', 'Letter': 'M'}, ] # Size check - for dest in dests: + for dest in destinations: if 'IP' in dest: - dest['Usage'] = shutil.disk_usage('\\\\{IP}\\{Share}'.format(**dest)) + dest['Usage'] = shutil.disk_usage(r'\\{IP}\{Share}'.format(**dest)) else: - dest['Usage'] = shutil.disk_usage('{Letter}:\\'.format(**dest)) + dest['Usage'] = shutil.disk_usage('{}:\\'.format(dest['Letter'])) dest['Free Space'] = human_readable_size(dest['Usage'].free) dest['Display Name'] = '{Name} ({Free Space} available)'.format(**dest) - # Show menu or bail - if len(dests) > 0: - selection = menu_select('Where are we backing up to?', dests, actions) - if selection == 'M': - return None - else: - return dests[int(selection)-1] - else: + # Bail + if not destinations: print_warning('No backup destinations found.') - return None + raise GenericAbort + + # Skip menu? + if len(destinations) == 1 and auto_select: + return destinations[0] + + selection = menu_select( + 'Where are we backing up to?', destinations, actions) + if selection == 'M': + raise GenericAbort + else: + return destinations[int(selection)-1] def verify_wim_backup(bin=None, par=None): # Bail early diff --git a/Scripts/functions/winpe_menus.py b/Scripts/functions/winpe_menus.py index ddbcc313..2f405325 100644 --- a/Scripts/functions/winpe_menus.py +++ b/Scripts/functions/winpe_menus.py @@ -71,8 +71,6 @@ def menu_backup(): # Select destination destination = select_backup_destination() - if not destination: - raise GenericAbort # Select disk to backup disk = select_disk('For which drive are we creating backups?') diff --git a/Scripts/winpe_root_menu.py b/Scripts/winpe_root_menu.py index 9ff1508d..ad19b34b 100644 --- a/Scripts/winpe_root_menu.py +++ b/Scripts/winpe_root_menu.py @@ -15,7 +15,8 @@ if __name__ == '__main__': try: menu_root() except GenericAbort: - pause('Press Enter to return to main menu... ') + # pause('Press Enter to return to main menu... ') + pass except SystemExit: pass except: