updated select_backup_destination()
This commit is contained in:
parent
c043c3398d
commit
7133089d31
3 changed files with 21 additions and 20 deletions
|
|
@ -105,35 +105,37 @@ def prep_disk_for_backup(destination, disk, ticket_number):
|
||||||
COLORS['YELLOW'], COLORS['CLEAR'])
|
COLORS['YELLOW'], COLORS['CLEAR'])
|
||||||
disk['Backup Warnings'] = warnings
|
disk['Backup Warnings'] = warnings
|
||||||
|
|
||||||
def select_backup_destination():
|
def select_backup_destination(auto_select=True):
|
||||||
# Build menu
|
# Build menu
|
||||||
dests = []
|
destinations = [s for s in BACKUP_SERVERS if s['Mounted']]
|
||||||
for server in BACKUP_SERVERS:
|
|
||||||
if server['Mounted']:
|
|
||||||
dests.append(server)
|
|
||||||
actions = [
|
actions = [
|
||||||
{'Name': 'Main Menu', 'Letter': 'M'},
|
{'Name': 'Main Menu', 'Letter': 'M'},
|
||||||
]
|
]
|
||||||
|
|
||||||
# Size check
|
# Size check
|
||||||
for dest in dests:
|
for dest in destinations:
|
||||||
if 'IP' in dest:
|
if 'IP' in dest:
|
||||||
dest['Usage'] = shutil.disk_usage('\\\\{IP}\\{Share}'.format(**dest))
|
dest['Usage'] = shutil.disk_usage(r'\\{IP}\{Share}'.format(**dest))
|
||||||
else:
|
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['Free Space'] = human_readable_size(dest['Usage'].free)
|
||||||
dest['Display Name'] = '{Name} ({Free Space} available)'.format(**dest)
|
dest['Display Name'] = '{Name} ({Free Space} available)'.format(**dest)
|
||||||
|
|
||||||
# Show menu or bail
|
# Bail
|
||||||
if len(dests) > 0:
|
if not destinations:
|
||||||
selection = menu_select('Where are we backing up to?', dests, actions)
|
|
||||||
if selection == 'M':
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return dests[int(selection)-1]
|
|
||||||
else:
|
|
||||||
print_warning('No backup destinations found.')
|
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):
|
def verify_wim_backup(bin=None, par=None):
|
||||||
# Bail early
|
# Bail early
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,6 @@ def menu_backup():
|
||||||
|
|
||||||
# Select destination
|
# Select destination
|
||||||
destination = select_backup_destination()
|
destination = select_backup_destination()
|
||||||
if not destination:
|
|
||||||
raise GenericAbort
|
|
||||||
|
|
||||||
# Select disk to backup
|
# Select disk to backup
|
||||||
disk = select_disk('For which drive are we creating backups?')
|
disk = select_disk('For which drive are we creating backups?')
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
menu_root()
|
menu_root()
|
||||||
except GenericAbort:
|
except GenericAbort:
|
||||||
pause('Press Enter to return to main menu... ')
|
# pause('Press Enter to return to main menu... ')
|
||||||
|
pass
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue