2017-03: Retroactive Updates
Fixed using local windows images * Bugfix: remove_volume_letters() was not preserving the "keep" letter * First issue: if keep==None then it would crash * Second issue: The passed keep value was outdated (See bugfix below) * Bugfix: undesired call of assign_volume_letters() * prep_disk_for_formatting() resets the volume letters thus breaking local installs * By moving find_windows_image() to be called afterwards this is fixed but perhaps another refactor is in order?
This commit is contained in:
parent
1da75165f9
commit
827f9bce6a
4 changed files with 27 additions and 22 deletions
|
|
@ -116,8 +116,8 @@ def assign_volume_letters():
|
||||||
try:
|
try:
|
||||||
# Run script
|
# Run script
|
||||||
with open(diskpart_script, 'w') as script:
|
with open(diskpart_script, 'w') as script:
|
||||||
for vol in get_volume_numbers():
|
for vol in get_volumes():
|
||||||
script.write('select volume {number}\n'.format(number=vol))
|
script.write('select volume {Number}\n'.format(**vol))
|
||||||
script.write('assign\n')
|
script.write('assign\n')
|
||||||
run_program('diskpart /s {script}'.format(script=diskpart_script))
|
run_program('diskpart /s {script}'.format(script=diskpart_script))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
|
@ -543,8 +543,8 @@ def get_ticket_id():
|
||||||
|
|
||||||
return ticket_id
|
return ticket_id
|
||||||
|
|
||||||
def get_volume_numbers():
|
def get_volumes():
|
||||||
vol_nums = []
|
vols = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Run script
|
# Run script
|
||||||
|
|
@ -557,10 +557,9 @@ def get_volume_numbers():
|
||||||
else:
|
else:
|
||||||
# Append volume numbers
|
# Append volume numbers
|
||||||
for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', process_return):
|
for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', process_return):
|
||||||
if tmp[1] == '':
|
vols.append({'Number': tmp[0], 'Letter': tmp[1]})
|
||||||
vol_nums.append(tmp[0])
|
|
||||||
|
|
||||||
return vol_nums
|
return vols
|
||||||
|
|
||||||
def human_readable_size(size, decimals=0):
|
def human_readable_size(size, decimals=0):
|
||||||
# Prep string formatting
|
# Prep string formatting
|
||||||
|
|
@ -812,13 +811,16 @@ def print_success(message='Generic success', **kwargs):
|
||||||
def print_warning(message='Generic warning', **kwargs):
|
def print_warning(message='Generic warning', **kwargs):
|
||||||
print('{YELLOW}{message}{CLEAR}'.format(message=message, **COLORS, **kwargs))
|
print('{YELLOW}{message}{CLEAR}'.format(message=message, **COLORS, **kwargs))
|
||||||
|
|
||||||
def remove_volume_letters(keep=None):
|
def remove_volume_letters(keep=''):
|
||||||
|
if keep is None:
|
||||||
|
keep = ''
|
||||||
try:
|
try:
|
||||||
# Run script
|
# Run script
|
||||||
with open(diskpart_script, 'w') as script:
|
with open(diskpart_script, 'w') as script:
|
||||||
for vol in get_volume_numbers():
|
for vol in get_volumes():
|
||||||
script.write('select volume {number}\n'.format(number=vol))
|
if vol['Letter'].upper() != keep.upper():
|
||||||
script.write('remove\n')
|
script.write('select volume {Number}\n'.format(**vol))
|
||||||
|
script.write('remove noerr\n')
|
||||||
run_program('diskpart /s {script}'.format(script=diskpart_script))
|
run_program('diskpart /s {script}'.format(script=diskpart_script))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -92,13 +92,15 @@ def menu_windows_setup():
|
||||||
|
|
||||||
# Select the version of Windows to apply
|
# Select the version of Windows to apply
|
||||||
windows_version = select_windows_version()
|
windows_version = select_windows_version()
|
||||||
|
|
||||||
# Find Windows image
|
|
||||||
windows_image = find_windows_image(bin, windows_version)
|
|
||||||
|
|
||||||
# Select drive to use as the OS drive
|
# Select drive to use as the OS drive
|
||||||
dest_disk = select_disk('To which drive are we installing Windows?')
|
dest_disk = select_disk('To which drive are we installing Windows?')
|
||||||
prep_disk_for_formatting(dest_disk)
|
prep_disk_for_formatting(dest_disk)
|
||||||
|
|
||||||
|
# Find Windows image
|
||||||
|
## NOTE: Needs to happen AFTER select_disk() is called as there's a hidden assign_volume_letters().
|
||||||
|
## This changes the current letters thus preventing installing from a local source.
|
||||||
|
windows_image = find_windows_image(bin, windows_version)
|
||||||
|
|
||||||
# Display details for setup task
|
# Display details for setup task
|
||||||
os.system('cls')
|
os.system('cls')
|
||||||
|
|
@ -119,7 +121,8 @@ def menu_windows_setup():
|
||||||
# Safety check
|
# Safety check
|
||||||
print('\nSAFETY CHECK')
|
print('\nSAFETY CHECK')
|
||||||
print_warning('All data will be DELETED from the drive and partition(s) listed above.')
|
print_warning('All data will be DELETED from the drive and partition(s) listed above.')
|
||||||
print_error('This is irreversible and will lead to DATA LOSS.')
|
print_error('This is irreversible and will lead to ', end='', flush=True)
|
||||||
|
print('DATA LOSS.')
|
||||||
if (not ask('Asking again to confirm, is this correct?')):
|
if (not ask('Asking again to confirm, is this correct?')):
|
||||||
abort_to_main_menu('Aborting Windows setup')
|
abort_to_main_menu('Aborting Windows setup')
|
||||||
|
|
||||||
|
|
@ -127,7 +130,7 @@ def menu_windows_setup():
|
||||||
remove_volume_letters(keep=windows_image['Source'])
|
remove_volume_letters(keep=windows_image['Source'])
|
||||||
|
|
||||||
# Format and partition drive
|
# Format and partition drive
|
||||||
print('\n Formatting Drive...\t\t'.format(**par), end='', flush=True)
|
print('\n Formatting Drive... \t\t', end='', flush=True)
|
||||||
try:
|
try:
|
||||||
if (dest_disk['Use GPT']):
|
if (dest_disk['Use GPT']):
|
||||||
format_gpt(dest_disk, windows_version['Family'])
|
format_gpt(dest_disk, windows_version['Family'])
|
||||||
|
|
@ -140,7 +143,7 @@ def menu_windows_setup():
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Apply Image
|
# Apply Image
|
||||||
print(' Applying Image...\t\t'.format(**par), end='', flush=True)
|
print(' Applying Image... \t\t', end='', flush=True)
|
||||||
try:
|
try:
|
||||||
setup_windows(bin, windows_image, windows_version)
|
setup_windows(bin, windows_image, windows_version)
|
||||||
print_success('Complete.')
|
print_success('Complete.')
|
||||||
|
|
@ -153,7 +156,7 @@ def menu_windows_setup():
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Create Boot files
|
# Create Boot files
|
||||||
print(' Update Boot Partition...\t\t'.format(**par), end='', flush=True)
|
print(' Update Boot Partition...\t\t', end='', flush=True)
|
||||||
try:
|
try:
|
||||||
update_boot_partition()
|
update_boot_partition()
|
||||||
print_success('Complete.')
|
print_success('Complete.')
|
||||||
|
|
@ -166,12 +169,12 @@ def menu_windows_setup():
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Setup WinRE
|
# Setup WinRE
|
||||||
print(' Update Recovery Tools...\t\t'.format(**par), end='', flush=True)
|
print(' Update Recovery Tools...\t\t', end='', flush=True)
|
||||||
try:
|
try:
|
||||||
setup_windows_re(windows_version)
|
setup_windows_re(windows_version)
|
||||||
print_success('Complete.')
|
print_success('Complete.')
|
||||||
except SetupError:
|
except SetupError:
|
||||||
print_error('Skipped.')
|
print('Skipped.')
|
||||||
except:
|
except:
|
||||||
# Don't need to crash as this is (potentially) recoverable
|
# Don't need to crash as this is (potentially) recoverable
|
||||||
print_error('Failed.')
|
print_error('Failed.')
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@
|
||||||
<value name="CompressLongStrings" type="hex" data="01"/>
|
<value name="CompressLongStrings" type="hex" data="01"/>
|
||||||
<value name="BackGround Image show" type="hex" data="01"/>
|
<value name="BackGround Image show" type="hex" data="01"/>
|
||||||
<value name="BackGround Image" type="string" data="ConEmu.jpg"/>
|
<value name="BackGround Image" type="string" data="ConEmu.jpg"/>
|
||||||
<value name="bgImageDarker" type="hex" data="50"/>
|
<value name="bgImageDarker" type="hex" data="60"/>
|
||||||
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
||||||
<value name="bgOperation" type="hex" data="07"/>
|
<value name="bgOperation" type="hex" data="07"/>
|
||||||
<value name="bgPluginAllowed" type="hex" data="01"/>
|
<value name="bgPluginAllowed" type="hex" data="01"/>
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@
|
||||||
<value name="CompressLongStrings" type="hex" data="01"/>
|
<value name="CompressLongStrings" type="hex" data="01"/>
|
||||||
<value name="BackGround Image show" type="hex" data="01"/>
|
<value name="BackGround Image show" type="hex" data="01"/>
|
||||||
<value name="BackGround Image" type="string" data="ConEmu.jpg"/>
|
<value name="BackGround Image" type="string" data="ConEmu.jpg"/>
|
||||||
<value name="bgImageDarker" type="hex" data="50"/>
|
<value name="bgImageDarker" type="hex" data="60"/>
|
||||||
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
||||||
<value name="bgOperation" type="hex" data="07"/>
|
<value name="bgOperation" type="hex" data="07"/>
|
||||||
<value name="bgPluginAllowed" type="hex" data="01"/>
|
<value name="bgPluginAllowed" type="hex" data="01"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue