Simplified Windows share sections
This commit is contained in:
parent
520cc4bca0
commit
9a3234c822
2 changed files with 10 additions and 26 deletions
|
|
@ -174,7 +174,7 @@ def human_readable_size(size, decimals=0):
|
||||||
size = convert_to_bytes(size)
|
size = convert_to_bytes(size)
|
||||||
|
|
||||||
# Verify we have a valid size
|
# Verify we have a valid size
|
||||||
if size <= 0:
|
if size < 0:
|
||||||
return '{size:>{width}} b'.format(size='???', width=width)
|
return '{size:>{width}} b'.format(size='???', width=width)
|
||||||
|
|
||||||
# Convert to sensible units
|
# Convert to sensible units
|
||||||
|
|
|
||||||
|
|
@ -61,13 +61,9 @@ def is_index_in_image(bin=None, filename=None, imagename=None):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def find_windows_image(bin, windows_version=None):
|
def find_windows_image(bin, windows_version):
|
||||||
"""Search for a Windows source image file on local drives and network drives (in that order)"""
|
"""Search for a Windows source image file on local drives and network drives (in that order)"""
|
||||||
image = {}
|
image = {}
|
||||||
|
|
||||||
# Bail early
|
|
||||||
if windows_version is None:
|
|
||||||
raise Exception('Windows version not specified.')
|
|
||||||
imagefile = windows_version['Image File']
|
imagefile = windows_version['Image File']
|
||||||
|
|
||||||
# Search local source
|
# Search local source
|
||||||
|
|
@ -85,9 +81,10 @@ def find_windows_image(bin, windows_version=None):
|
||||||
break
|
break
|
||||||
|
|
||||||
# Check for network source (if necessary)
|
# Check for network source (if necessary)
|
||||||
if not any(image):
|
if not image:
|
||||||
if not WINDOWS_SERVER['Mounted']:
|
|
||||||
mount_windows_share()
|
mount_windows_share()
|
||||||
|
if not WINDOWS_SERVER['Mounted']:
|
||||||
|
return None
|
||||||
for ext in ['esd', 'wim', 'swm']:
|
for ext in ['esd', 'wim', 'swm']:
|
||||||
filename = '\\\\{IP}\\{Share}\\images\\{imagefile}'.format(imagefile=imagefile, **WINDOWS_SERVER)
|
filename = '\\\\{IP}\\{Share}\\images\\{imagefile}'.format(imagefile=imagefile, **WINDOWS_SERVER)
|
||||||
filename_ext = '{filename}.{ext}'.format(filename=filename, ext=ext)
|
filename_ext = '{filename}.{ext}'.format(filename=filename, ext=ext)
|
||||||
|
|
@ -202,25 +199,12 @@ def get_boot_mode():
|
||||||
return boot_mode
|
return boot_mode
|
||||||
|
|
||||||
def mount_windows_share():
|
def mount_windows_share():
|
||||||
"""Mount the Windows images share for use in Windows setup"""
|
"""Mount the Windows images share unless labeled as already mounted."""
|
||||||
|
|
||||||
# Blindly skip if we mounted earlier
|
|
||||||
if WINDOWS_SERVER['Mounted']:
|
if WINDOWS_SERVER['Mounted']:
|
||||||
return None
|
# Blindly skip if we mounted earlier
|
||||||
else:
|
continue
|
||||||
try:
|
|
||||||
# Test connection
|
mount_network_share(WINDOWS_SERVER)
|
||||||
run_program('ping -w 800 -n 2 {IP}'.format(**WINDOWS_SERVER))
|
|
||||||
# Mount
|
|
||||||
run_program('net use \\\\{IP}\\{Share} /user:{User} {Pass}'.format(**WINDOWS_SERVER))
|
|
||||||
print_info('Mounted {Name}'.format(**WINDOWS_SERVER))
|
|
||||||
WINDOWS_SERVER['Mounted'] = True
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
print_error('Failed to mount \\\\{Name}\\{Share}, {IP} unreachable.'.format(**WINDOWS_SERVER))
|
|
||||||
time.sleep(1)
|
|
||||||
except:
|
|
||||||
print_warning('Failed to mount \\\\{Name}\\{Share}'.format(**WINDOWS_SERVER))
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
def select_windows_version():
|
def select_windows_version():
|
||||||
actions = [{'Name': 'Main Menu', 'Letter': 'M'},]
|
actions = [{'Name': 'Main Menu', 'Letter': 'M'},]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue