Removed whitespace from empty lines

This commit is contained in:
2Shirt 2018-11-23 18:01:03 -07:00
parent 63fcaed8cd
commit 8064fc4a17
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
18 changed files with 125 additions and 125 deletions

View file

@ -39,7 +39,7 @@ if __name__ == '__main__':
selection = menu_select( selection = menu_select(
'{}: Windows Activation Menu'.format(KIT_NAME_FULL), '{}: Windows Activation Menu'.format(KIT_NAME_FULL),
main_entries=activation_methods, action_entries=actions) main_entries=activation_methods, action_entries=actions)
if (selection.isnumeric()): if (selection.isnumeric()):
result = try_and_print( result = try_and_print(
message = activation_methods[int(selection)-1]['Name'], message = activation_methods[int(selection)-1]['Name'],

View file

@ -35,7 +35,7 @@ class feature(Structure):
_fields_ = [("name", c_char_p), _fields_ = [("name", c_char_p),
("number", c_int), ("number", c_int),
("type", c_int)] ("type", c_int)]
# sensors_feature_type # sensors_feature_type
IN = 0x00 IN = 0x00
FAN = 0x01 FAN = 0x01
@ -71,10 +71,10 @@ COMPUTE_MAPPING = 4
def init(cfg_file = None): def init(cfg_file = None):
file = _libc.fopen(cfg_file.encode("utf-8"), "r") if cfg_file is not None else None file = _libc.fopen(cfg_file.encode("utf-8"), "r") if cfg_file is not None else None
if _hdl.sensors_init(file) != 0: if _hdl.sensors_init(file) != 0:
raise Exception("sensors_init failed") raise Exception("sensors_init failed")
if file is not None: if file is not None:
_libc.fclose(file) _libc.fclose(file)
@ -84,10 +84,10 @@ def cleanup():
def parse_chip_name(orig_name): def parse_chip_name(orig_name):
ret = chip_name() ret = chip_name()
err= _hdl.sensors_parse_chip_name(orig_name.encode("utf-8"), byref(ret)) err= _hdl.sensors_parse_chip_name(orig_name.encode("utf-8"), byref(ret))
if err < 0: if err < 0:
raise Exception(strerror(err)) raise Exception(strerror(err))
return ret return ret
def strerror(errnum): def strerror(errnum):
@ -101,10 +101,10 @@ def get_detected_chips(match, nr):
@return: (chip, next nr to query) @return: (chip, next nr to query)
""" """
_nr = c_int(nr) _nr = c_int(nr)
if match is not None: if match is not None:
match = byref(match) match = byref(match)
chip = _hdl.sensors_get_detected_chips(match, byref(_nr)) chip = _hdl.sensors_get_detected_chips(match, byref(_nr))
chip = chip.contents if bool(chip) else None chip = chip.contents if bool(chip) else None
return chip, _nr.value return chip, _nr.value
@ -115,10 +115,10 @@ def chip_snprintf_name(chip, buffer_size=200):
""" """
ret = create_string_buffer(buffer_size) ret = create_string_buffer(buffer_size)
err = _hdl.sensors_snprintf_chip_name(ret, buffer_size, byref(chip)) err = _hdl.sensors_snprintf_chip_name(ret, buffer_size, byref(chip))
if err < 0: if err < 0:
raise Exception(strerror(err)) raise Exception(strerror(err))
return ret.value.decode("utf-8") return ret.value.decode("utf-8")
def do_chip_sets(chip): def do_chip_sets(chip):
@ -128,7 +128,7 @@ def do_chip_sets(chip):
err = _hdl.sensors_do_chip_sets(byref(chip)) err = _hdl.sensors_do_chip_sets(byref(chip))
if err < 0: if err < 0:
raise Exception(strerror(err)) raise Exception(strerror(err))
def get_adapter_name(bus): def get_adapter_name(bus):
return _hdl.sensors_get_adapter_name(byref(bus)).decode("utf-8") return _hdl.sensors_get_adapter_name(byref(bus)).decode("utf-8")
@ -177,60 +177,60 @@ class ChipIterator:
def __init__(self, match = None): def __init__(self, match = None):
self.match = parse_chip_name(match) if match is not None else None self.match = parse_chip_name(match) if match is not None else None
self.nr = 0 self.nr = 0
def __iter__(self): def __iter__(self):
return self return self
def __next__(self): def __next__(self):
chip, self.nr = get_detected_chips(self.match, self.nr) chip, self.nr = get_detected_chips(self.match, self.nr)
if chip is None: if chip is None:
raise StopIteration raise StopIteration
return chip return chip
def __del__(self): def __del__(self):
if self.match is not None: if self.match is not None:
free_chip_name(self.match) free_chip_name(self.match)
def next(self): # python2 compability def next(self): # python2 compability
return self.__next__() return self.__next__()
class FeatureIterator: class FeatureIterator:
def __init__(self, chip): def __init__(self, chip):
self.chip = chip self.chip = chip
self.nr = 0 self.nr = 0
def __iter__(self): def __iter__(self):
return self return self
def __next__(self): def __next__(self):
feature, self.nr = get_features(self.chip, self.nr) feature, self.nr = get_features(self.chip, self.nr)
if feature is None: if feature is None:
raise StopIteration raise StopIteration
return feature return feature
def next(self): # python2 compability def next(self): # python2 compability
return self.__next__() return self.__next__()
class SubFeatureIterator: class SubFeatureIterator:
def __init__(self, chip, feature): def __init__(self, chip, feature):
self.chip = chip self.chip = chip
self.feature = feature self.feature = feature
self.nr = 0 self.nr = 0
def __iter__(self): def __iter__(self):
return self return self
def __next__(self): def __next__(self):
subfeature, self.nr = get_all_subfeatures(self.chip, self.feature, self.nr) subfeature, self.nr = get_all_subfeatures(self.chip, self.feature, self.nr)
if subfeature is None: if subfeature is None:
raise StopIteration raise StopIteration
return subfeature return subfeature
def next(self): # python2 compability def next(self): # python2 compability
return self.__next__() return self.__next__()

View file

@ -10,7 +10,7 @@ from functions.cleanup import *
from functions.data import * from functions.data import *
init_global_vars() init_global_vars()
os.system('title {}: CBS Cleanup'.format(KIT_NAME_FULL)) os.system('title {}: CBS Cleanup'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\CBS Cleanup.log'.format(**global_vars) set_log_file('CBS Cleanup.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -20,18 +20,18 @@ if __name__ == '__main__':
folder_path = r'{}\Backups'.format(KIT_NAME_SHORT) folder_path = r'{}\Backups'.format(KIT_NAME_SHORT)
dest = select_destination(folder_path=folder_path, dest = select_destination(folder_path=folder_path,
prompt='Which disk are we using for temp data and backup?') prompt='Which disk are we using for temp data and backup?')
# Show details # Show details
print_info('{}: CBS Cleanup Tool\n'.format(KIT_NAME_FULL)) print_info('{}: CBS Cleanup Tool\n'.format(KIT_NAME_FULL))
show_data('Backup / Temp path:', dest) show_data('Backup / Temp path:', dest)
print_standard('\n') print_standard('\n')
if (not ask('Proceed with CBS cleanup?')): if (not ask('Proceed with CBS cleanup?')):
abort() abort()
# Run Cleanup # Run Cleanup
try_and_print(message='Running cleanup...', function=cleanup_cbs, try_and_print(message='Running cleanup...', function=cleanup_cbs,
cs='Done', dest_folder=dest) cs='Done', dest_folder=dest)
# Done # Done
print_standard('\nDone.') print_standard('\nDone.')
pause("Press Enter to exit...") pause("Press Enter to exit...")

View file

@ -9,7 +9,7 @@ sys.path.append(os.getcwd())
from functions.repairs import * from functions.repairs import *
init_global_vars() init_global_vars()
os.system('title {}: Check Disk Tool'.format(KIT_NAME_FULL)) os.system('title {}: Check Disk Tool'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\Check Disk.log'.format(**global_vars) set_log_file('Check Disk.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -45,7 +45,7 @@ if __name__ == '__main__':
cs=cs, other_results=other_results, repair=repair) cs=cs, other_results=other_results, repair=repair)
else: else:
abort() abort()
# Done # Done
print_success('Done.') print_success('Done.')
pause("Press Enter to exit...") pause("Press Enter to exit...")

View file

@ -9,7 +9,7 @@ sys.path.append(os.getcwd())
from functions.repairs import * from functions.repairs import *
init_global_vars() init_global_vars()
os.system('title {}: DISM helper Tool'.format(KIT_NAME_FULL)) os.system('title {}: DISM helper Tool'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\DISM helper tool.log'.format(**global_vars) set_log_file('DISM Helper.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -46,7 +46,7 @@ if __name__ == '__main__':
other_results=other_results, repair=repair) other_results=other_results, repair=repair)
else: else:
abort() abort()
# Done # Done
print_success('Done.') print_success('Done.')
pause("Press Enter to exit...") pause("Press Enter to exit...")

View file

@ -59,7 +59,7 @@ def windows_is_activated():
['cscript', '//nologo', SLMGR, '/xpr'], check=False, ['cscript', '//nologo', SLMGR, '/xpr'], check=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
activation_string = activation_string.stdout.decode() activation_string = activation_string.stdout.decode()
return bool(activation_string and 'permanent' in activation_string) return bool(activation_string and 'permanent' in activation_string)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -16,7 +16,7 @@ def backup_partition(disk, par):
"""Create a backup image of a partition.""" """Create a backup image of a partition."""
if par.get('Image Exists', False) or par['Number'] in disk['Bad Partitions']: if par.get('Image Exists', False) or par['Number'] in disk['Bad Partitions']:
raise GenericAbort raise GenericAbort
cmd = [ cmd = [
global_vars['Tools']['wimlib-imagex'], global_vars['Tools']['wimlib-imagex'],
'capture', 'capture',
@ -48,7 +48,7 @@ def get_volume_display_name(mountpoint):
serial_number = None serial_number = None
max_component_length = None max_component_length = None
file_system_flags = None file_system_flags = None
vol_info = kernel32.GetVolumeInformationW( vol_info = kernel32.GetVolumeInformationW(
ctypes.c_wchar_p(mountpoint), ctypes.c_wchar_p(mountpoint),
vol_name_buffer, vol_name_buffer,
@ -59,16 +59,16 @@ def get_volume_display_name(mountpoint):
fs_name_buffer, fs_name_buffer,
ctypes.sizeof(fs_name_buffer) ctypes.sizeof(fs_name_buffer)
) )
name = '{} "{}"'.format(name, vol_name_buffer.value) name = '{} "{}"'.format(name, vol_name_buffer.value)
except: except:
pass pass
return name return name
def prep_disk_for_backup(destination, disk, backup_prefix): def prep_disk_for_backup(destination, disk, backup_prefix):
"""Gather details about the disk and its partitions. """Gather details about the disk and its partitions.
This includes partitions that can't be backed up, This includes partitions that can't be backed up,
whether backups already exist on the BACKUP_SERVER, whether backups already exist on the BACKUP_SERVER,
partition names/sizes/used space, etc.""" partition names/sizes/used space, etc."""
@ -83,7 +83,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix):
if disk['Valid Partitions'] <= 0: if disk['Valid Partitions'] <= 0:
print_error('ERROR: No partitions can be backed up for this disk') print_error('ERROR: No partitions can be backed up for this disk')
raise GenericAbort raise GenericAbort
# Prep partitions # Prep partitions
for par in disk['Partitions']: for par in disk['Partitions']:
display = '{size} {fs}'.format( display = '{size} {fs}'.format(
@ -91,7 +91,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix):
width = width, width = width,
size = par['Size'], size = par['Size'],
fs = par['FileSystem']) fs = par['FileSystem'])
if par['Number'] in disk['Bad Partitions']: if par['Number'] in disk['Bad Partitions']:
# Set display string using partition description & OS type # Set display string using partition description & OS type
display = '* {display}\t\t{q}{name}{q}\t{desc} ({os})'.format( display = '* {display}\t\t{q}{name}{q}\t{desc} ({os})'.format(
@ -120,7 +120,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix):
display = '+ {}'.format(display) display = '+ {}'.format(display)
else: else:
display = ' {}'.format(display) display = ' {}'.format(display)
# Append rest of Display String for valid/clobber partitions # Append rest of Display String for valid/clobber partitions
display += ' (Used: {used})\t{q}{name}{q}'.format( display += ' (Used: {used})\t{q}{name}{q}'.format(
used = par['Used Space'], used = par['Used Space'],
@ -128,7 +128,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix):
name = par['Name']) name = par['Name'])
# For all partitions # For all partitions
par['Display String'] = display par['Display String'] = display
# Set description for bad partitions # Set description for bad partitions
warnings = '\n' warnings = '\n'
if disk['Bad Partitions']: if disk['Bad Partitions']:
@ -148,7 +148,7 @@ def select_backup_destination(auto_select=True):
actions = [ actions = [
{'Name': 'Main Menu', 'Letter': 'M'}, {'Name': 'Main Menu', 'Letter': 'M'},
] ]
# Add local disks # Add local disks
for d in psutil.disk_partitions(): for d in psutil.disk_partitions():
if re.search(r'^{}'.format(global_vars['Env']['SYSTEMDRIVE']), d.mountpoint, re.IGNORECASE): if re.search(r'^{}'.format(global_vars['Env']['SYSTEMDRIVE']), d.mountpoint, re.IGNORECASE):
@ -161,7 +161,7 @@ def select_backup_destination(auto_select=True):
get_volume_display_name(d.mountpoint)), get_volume_display_name(d.mountpoint)),
'Letter': re.sub(r'^(\w):\\.*$', r'\1', d.mountpoint), 'Letter': re.sub(r'^(\w):\\.*$', r'\1', d.mountpoint),
}) })
# Size check # Size check
for dest in destinations: for dest in destinations:
if 'IP' in dest: if 'IP' in dest:
@ -175,11 +175,11 @@ def select_backup_destination(auto_select=True):
if not destinations: if not destinations:
print_warning('No backup destinations found.') print_warning('No backup destinations found.')
raise GenericAbort raise GenericAbort
# Skip menu? # Skip menu?
if len(destinations) == 1 and auto_select: if len(destinations) == 1 and auto_select:
return destinations[0] return destinations[0]
selection = menu_select( selection = menu_select(
title = 'Where are we backing up to?', title = 'Where are we backing up to?',
main_entries = destinations, main_entries = destinations,

View file

@ -14,13 +14,13 @@ REGEX_DISK_RAW = re.compile(r'Disk ID: 00000000', re.IGNORECASE)
def assign_volume_letters(): def assign_volume_letters():
"""Assign a volume letter to all available volumes.""" """Assign a volume letter to all available volumes."""
remove_volume_letters() remove_volume_letters()
# Write script # Write script
script = [] script = []
for vol in get_volumes(): for vol in get_volumes():
script.append('select volume {}'.format(vol['Number'])) script.append('select volume {}'.format(vol['Number']))
script.append('assign') script.append('assign')
# Run # Run
run_diskpart(script) run_diskpart(script)
@ -35,7 +35,7 @@ def get_boot_mode():
boot_mode = 'UEFI' boot_mode = 'UEFI'
except: except:
boot_mode = 'Unknown' boot_mode = 'Unknown'
return boot_mode return boot_mode
def get_disk_details(disk): def get_disk_details(disk):
@ -44,7 +44,7 @@ def get_disk_details(disk):
script = [ script = [
'select disk {}'.format(disk['Number']), 'select disk {}'.format(disk['Number']),
'detail disk'] 'detail disk']
# Run # Run
try: try:
result = run_diskpart(script) result = run_diskpart(script)
@ -60,13 +60,13 @@ def get_disk_details(disk):
tmp = [s.split(':') for s in tmp if ':' in s] tmp = [s.split(':') for s in tmp if ':' in s]
# Add key/value pairs to the details variable and return dict # Add key/value pairs to the details variable and return dict
details.update({key.strip(): value.strip() for (key, value) in tmp}) details.update({key.strip(): value.strip() for (key, value) in tmp})
return details return details
def get_disks(): def get_disks():
"""Get list of attached disks using DiskPart.""" """Get list of attached disks using DiskPart."""
disks = [] disks = []
try: try:
# Run script # Run script
result = run_diskpart(['list disk']) result = run_diskpart(['list disk'])
@ -79,7 +79,7 @@ def get_disks():
num = tmp[0] num = tmp[0]
size = human_readable_size(tmp[1]) size = human_readable_size(tmp[1])
disks.append({'Number': num, 'Size': size}) disks.append({'Number': num, 'Size': size})
return disks return disks
def get_partition_details(disk, partition): def get_partition_details(disk, partition):
@ -89,7 +89,7 @@ def get_partition_details(disk, partition):
'select disk {}'.format(disk['Number']), 'select disk {}'.format(disk['Number']),
'select partition {}'.format(partition['Number']), 'select partition {}'.format(partition['Number']),
'detail partition'] 'detail partition']
# Diskpart details # Diskpart details
try: try:
# Run script # Run script
@ -111,14 +111,14 @@ def get_partition_details(disk, partition):
tmp = [s.split(':') for s in tmp if ':' in s] tmp = [s.split(':') for s in tmp if ':' in s]
# Add key/value pairs to the details variable and return dict # Add key/value pairs to the details variable and return dict
details.update({key.strip(): value.strip() for (key, value) in tmp}) details.update({key.strip(): value.strip() for (key, value) in tmp})
# Get MBR type / GPT GUID for extra details on "Unknown" partitions # Get MBR type / GPT GUID for extra details on "Unknown" partitions
guid = partition_uids.lookup_guid(details.get('Type')) guid = partition_uids.lookup_guid(details.get('Type'))
if guid: if guid:
details.update({ details.update({
'Description': guid.get('Description', '')[:29], 'Description': guid.get('Description', '')[:29],
'OS': guid.get('OS', 'Unknown')[:27]}) 'OS': guid.get('OS', 'Unknown')[:27]})
if 'Letter' in details: if 'Letter' in details:
# Disk usage # Disk usage
try: try:
@ -128,7 +128,7 @@ def get_partition_details(disk, partition):
details['Error'] = err.strerror details['Error'] = err.strerror
else: else:
details['Used Space'] = human_readable_size(tmp.used) details['Used Space'] = human_readable_size(tmp.used)
# fsutil details # fsutil details
cmd = [ cmd = [
'fsutil', 'fsutil',
@ -151,14 +151,14 @@ def get_partition_details(disk, partition):
tmp = [s.split(':') for s in tmp if ':' in s] tmp = [s.split(':') for s in tmp if ':' in s]
# Add key/value pairs to the details variable and return dict # Add key/value pairs to the details variable and return dict
details.update({key.strip(): value.strip() for (key, value) in tmp}) details.update({key.strip(): value.strip() for (key, value) in tmp})
# Set Volume Name # Set Volume Name
details['Name'] = details.get('Volume Name', '') details['Name'] = details.get('Volume Name', '')
# Set FileSystem Type # Set FileSystem Type
if details.get('FileSystem', '') not in ['RAW', 'Unknown']: if details.get('FileSystem', '') not in ['RAW', 'Unknown']:
details['FileSystem'] = details.get('File System Name', 'Unknown') details['FileSystem'] = details.get('File System Name', 'Unknown')
return details return details
def get_partitions(disk): def get_partitions(disk):
@ -167,7 +167,7 @@ def get_partitions(disk):
script = [ script = [
'select disk {}'.format(disk['Number']), 'select disk {}'.format(disk['Number']),
'list partition'] 'list partition']
try: try:
# Run script # Run script
result = run_diskpart(script) result = run_diskpart(script)
@ -181,7 +181,7 @@ def get_partitions(disk):
num = tmp[0] num = tmp[0]
size = human_readable_size(tmp[1]) size = human_readable_size(tmp[1])
partitions.append({'Number': num, 'Size': size}) partitions.append({'Number': num, 'Size': size})
return partitions return partitions
def get_table_type(disk): def get_table_type(disk):
@ -190,7 +190,7 @@ def get_table_type(disk):
script = [ script = [
'select disk {}'.format(disk['Number']), 'select disk {}'.format(disk['Number']),
'uniqueid disk'] 'uniqueid disk']
try: try:
result = run_diskpart(script) result = run_diskpart(script)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -203,7 +203,7 @@ def get_table_type(disk):
part_type = 'MBR' part_type = 'MBR'
elif REGEX_DISK_RAW.search(output): elif REGEX_DISK_RAW.search(output):
part_type = 'RAW' part_type = 'RAW'
return part_type return part_type
def get_volumes(): def get_volumes():
@ -218,7 +218,7 @@ def get_volumes():
output = result.stdout.decode().strip() output = result.stdout.decode().strip()
for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', output): for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', output):
vols.append({'Number': tmp[0], 'Letter': tmp[1]}) vols.append({'Number': tmp[0], 'Letter': tmp[1]})
return vols return vols
def is_bad_partition(par): def is_bad_partition(par):
@ -229,7 +229,7 @@ def prep_disk_for_formatting(disk=None):
"""Gather details about the disk and its partitions.""" """Gather details about the disk and its partitions."""
disk['Format Warnings'] = '\n' disk['Format Warnings'] = '\n'
width = len(str(len(disk['Partitions']))) width = len(str(len(disk['Partitions'])))
# Bail early # Bail early
if disk is None: if disk is None:
raise Exception('Disk not provided.') raise Exception('Disk not provided.')
@ -242,7 +242,7 @@ def prep_disk_for_formatting(disk=None):
else: else:
if (ask("Setup Windows to use BIOS/Legacy booting?")): if (ask("Setup Windows to use BIOS/Legacy booting?")):
disk['Use GPT'] = False disk['Use GPT'] = False
# Set Display and Warning Strings # Set Display and Warning Strings
if len(disk['Partitions']) == 0: if len(disk['Partitions']) == 0:
disk['Format Warnings'] += 'No partitions found\n' disk['Format Warnings'] += 'No partitions found\n'
@ -252,7 +252,7 @@ def prep_disk_for_formatting(disk=None):
width = width, width = width,
size = partition['Size'], size = partition['Size'],
fs = partition['FileSystem']) fs = partition['FileSystem'])
if is_bad_partition(partition): if is_bad_partition(partition):
# Set display string using partition description & OS type # Set display string using partition description & OS type
display += '\t\t{q}{name}{q}\t{desc} ({os})'.format( display += '\t\t{q}{name}{q}\t{desc} ({os})'.format(
@ -290,13 +290,13 @@ def remove_volume_letters(keep=None):
"""Remove all assigned volume letters using DiskPart.""" """Remove all assigned volume letters using DiskPart."""
if not keep: if not keep:
keep = '' keep = ''
script = [] script = []
for vol in get_volumes(): for vol in get_volumes():
if vol['Letter'].upper() != keep.upper(): if vol['Letter'].upper() != keep.upper():
script.append('select volume {}'.format(vol['Number'])) script.append('select volume {}'.format(vol['Number']))
script.append('remove noerr') script.append('remove noerr')
# Run script # Run script
try: try:
run_diskpart(script) run_diskpart(script)
@ -306,12 +306,12 @@ def remove_volume_letters(keep=None):
def run_diskpart(script): def run_diskpart(script):
"""Run DiskPart script.""" """Run DiskPart script."""
tempfile = r'{}\diskpart.script'.format(global_vars['Env']['TMP']) tempfile = r'{}\diskpart.script'.format(global_vars['Env']['TMP'])
# Write script # Write script
with open(tempfile, 'w') as f: with open(tempfile, 'w') as f:
for line in script: for line in script:
f.write('{}\n'.format(line)) f.write('{}\n'.format(line))
# Run script # Run script
cmd = [ cmd = [
r'{}\Windows\System32\diskpart.exe'.format( r'{}\Windows\System32\diskpart.exe'.format(
@ -335,7 +335,7 @@ def scan_disks():
# Get partition info for disk # Get partition info for disk
disk['Partitions'] = get_partitions(disk) disk['Partitions'] = get_partitions(disk)
for partition in disk['Partitions']: for partition in disk['Partitions']:
# Get partition details # Get partition details
partition.update(get_partition_details(disk, partition)) partition.update(get_partition_details(disk, partition))
@ -364,12 +364,12 @@ def select_disk(title='Which disk?', disks=[]):
fs = partition['FileSystem']) fs = partition['FileSystem'])
if partition['Name']: if partition['Name']:
p_name += '\t"{}"'.format(partition['Name']) p_name += '\t"{}"'.format(partition['Name'])
# Show unsupported partition(s) # Show unsupported partition(s)
if is_bad_partition(partition): if is_bad_partition(partition):
p_name = '{YELLOW}{p_name}{CLEAR}'.format( p_name = '{YELLOW}{p_name}{CLEAR}'.format(
p_name=p_name, **COLORS) p_name=p_name, **COLORS)
display_name += '\n\t\t\t{}'.format(p_name) display_name += '\n\t\t\t{}'.format(p_name)
if not disk['Partitions']: if not disk['Partitions']:
display_name += '\n\t\t\t{}No partitions found.{}'.format( display_name += '\n\t\t\t{}No partitions found.{}'.format(

View file

@ -26,7 +26,7 @@ def connect_to_network():
# Bail if currently connected # Bail if currently connected
if is_connected(): if is_connected():
return return
# WiFi # WiFi
if 'wl' in net_ifs: if 'wl' in net_ifs:
cmd = [ cmd = [
@ -37,7 +37,7 @@ def connect_to_network():
message = 'Connecting to {}...'.format(WIFI_SSID), message = 'Connecting to {}...'.format(WIFI_SSID),
function = run_program, function = run_program,
cmd = cmd) cmd = cmd)
def is_connected(): def is_connected():
"""Check for a valid private IP.""" """Check for a valid private IP."""
devs = psutil.net_if_addrs() devs = psutil.net_if_addrs()

View file

@ -39,7 +39,7 @@ def extract_keys():
keys[product] = [] keys[product] = []
if key not in keys[product]: if key not in keys[product]:
keys[product].append(key) keys[product].append(key)
# Done # Done
return keys return keys

View file

@ -17,7 +17,7 @@ WINDOWS_VERSIONS = [
{'Name': 'Windows 7 Ultimate', {'Name': 'Windows 7 Ultimate',
'Image File': 'Win7', 'Image File': 'Win7',
'Image Name': 'Windows 7 ULTIMATE'}, 'Image Name': 'Windows 7 ULTIMATE'},
{'Name': 'Windows 8.1', {'Name': 'Windows 8.1',
'Image File': 'Win8', 'Image File': 'Win8',
'Image Name': 'Windows 8.1', 'Image Name': 'Windows 8.1',
@ -25,7 +25,7 @@ WINDOWS_VERSIONS = [
{'Name': 'Windows 8.1 Pro', {'Name': 'Windows 8.1 Pro',
'Image File': 'Win8', 'Image File': 'Win8',
'Image Name': 'Windows 8.1 Pro'}, 'Image Name': 'Windows 8.1 Pro'},
{'Name': 'Windows 10 Home', {'Name': 'Windows 10 Home',
'Image File': 'Win10', 'Image File': 'Win10',
'Image Name': 'Windows 10 Home', 'Image Name': 'Windows 10 Home',
@ -75,7 +75,7 @@ def find_windows_image(windows_version):
image['Glob'] = '--ref="{}*.swm"'.format( image['Glob'] = '--ref="{}*.swm"'.format(
image['Path'][:-4]) image['Path'][:-4])
break break
# Display image to be used (if any) and return # Display image to be used (if any) and return
if image: if image:
print_info('Using image: {}'.format(image['Path'])) print_info('Using image: {}'.format(image['Path']))
@ -122,7 +122,7 @@ def format_gpt(disk):
'set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"', 'set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"',
'gpt attributes=0x8000000000000001', 'gpt attributes=0x8000000000000001',
] ]
# Run # Run
run_diskpart(script) run_diskpart(script)
@ -151,7 +151,7 @@ def format_mbr(disk):
'assign letter="T"', 'assign letter="T"',
'set id=27', 'set id=27',
] ]
# Run # Run
run_diskpart(script) run_diskpart(script)
@ -197,11 +197,11 @@ def setup_windows_re(windows_version, windows_letter='W', tools_letter='T'):
win = r'{}:\Windows'.format(windows_letter) win = r'{}:\Windows'.format(windows_letter)
winre = r'{}\System32\Recovery\WinRE.wim'.format(win) winre = r'{}\System32\Recovery\WinRE.wim'.format(win)
dest = r'{}:\Recovery\WindowsRE'.format(tools_letter) dest = r'{}:\Recovery\WindowsRE'.format(tools_letter)
# Copy WinRE.wim # Copy WinRE.wim
os.makedirs(dest, exist_ok=True) os.makedirs(dest, exist_ok=True)
shutil.copy(winre, r'{}\WinRE.wim'.format(dest)) shutil.copy(winre, r'{}\WinRE.wim'.format(dest))
# Set location # Set location
cmd = [ cmd = [
r'{}\System32\ReAgentc.exe'.format(win), r'{}\System32\ReAgentc.exe'.format(win),
@ -231,7 +231,7 @@ def wim_contains_image(filename, imagename):
run_program(cmd) run_program(cmd)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return False return False
return True return True
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -90,7 +90,7 @@ def menu_backup():
message = 'Assigning letters...', message = 'Assigning letters...',
function = assign_volume_letters, function = assign_volume_letters,
other_results = other_results) other_results = other_results)
# Mount backup shares # Mount backup shares
mount_backup_shares(read_write=True) mount_backup_shares(read_write=True)
@ -107,12 +107,12 @@ def menu_backup():
else: else:
print_error('ERROR: No disks found.') print_error('ERROR: No disks found.')
raise GenericAbort raise GenericAbort
# Select disk to backup # Select disk to backup
disk = select_disk('For which disk are we creating backups?', disks) disk = select_disk('For which disk are we creating backups?', disks)
if not disk: if not disk:
raise GenericAbort raise GenericAbort
# "Prep" disk # "Prep" disk
prep_disk_for_backup(destination, disk, backup_prefix) prep_disk_for_backup(destination, disk, backup_prefix)
@ -150,7 +150,7 @@ def menu_backup():
# Ask to proceed # Ask to proceed
if (not ask('Proceed with backup?')): if (not ask('Proceed with backup?')):
raise GenericAbort raise GenericAbort
# Backup partition(s) # Backup partition(s)
print_info('\n\nStarting task.\n') print_info('\n\nStarting task.\n')
for par in disk['Partitions']: for par in disk['Partitions']:
@ -163,7 +163,7 @@ def menu_backup():
if not result['CS'] and not isinstance(result['Error'], GenericAbort): if not result['CS'] and not isinstance(result['Error'], GenericAbort):
errors = True errors = True
par['Error'] = result['Error'] par['Error'] = result['Error']
# Verify backup(s) # Verify backup(s)
if disk['Valid Partitions']: if disk['Valid Partitions']:
print_info('\n\nVerifying backup images(s)\n') print_info('\n\nVerifying backup images(s)\n')
@ -270,7 +270,7 @@ def menu_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 # Find Windows image
# NOTE: Reassign volume letters to ensure all devices are scanned # NOTE: Reassign volume letters to ensure all devices are scanned
try_and_print( try_and_print(
@ -289,12 +289,12 @@ def menu_setup():
else: else:
print_error('ERROR: No disks found.') print_error('ERROR: No disks found.')
raise GenericAbort raise GenericAbort
# Select disk to use as the OS disk # Select disk to use as the OS disk
dest_disk = select_disk('To which disk are we installing Windows?', disks) dest_disk = select_disk('To which disk are we installing Windows?', disks)
if not dest_disk: if not dest_disk:
raise GenericAbort raise GenericAbort
# "Prep" disk # "Prep" disk
prep_disk_for_formatting(dest_disk) prep_disk_for_formatting(dest_disk)
@ -323,10 +323,10 @@ def menu_setup():
data = par['Display String'], data = par['Display String'],
warning = True) warning = True)
print_warning(dest_disk['Format Warnings']) print_warning(dest_disk['Format Warnings'])
if (not ask('Is this correct?')): if (not ask('Is this correct?')):
raise GenericAbort raise GenericAbort
# Safety check # Safety check
print_standard('\nSAFETY CHECK') print_standard('\nSAFETY CHECK')
print_warning('All data will be DELETED from the ' print_warning('All data will be DELETED from the '
@ -342,7 +342,7 @@ def menu_setup():
function = remove_volume_letters, function = remove_volume_letters,
other_results = other_results, other_results = other_results,
keep=windows_image['Letter']) keep=windows_image['Letter'])
# Assign new letter for local source if necessary # Assign new letter for local source if necessary
if windows_image['Local'] and windows_image['Letter'] in ['S', 'T', 'W']: if windows_image['Local'] and windows_image['Letter'] in ['S', 'T', 'W']:
new_letter = try_and_print( new_letter = try_and_print(
@ -377,13 +377,13 @@ def menu_setup():
# We need to crash as the disk is in an unknown state # We need to crash as the disk is in an unknown state
print_error('ERROR: Failed to apply image.') print_error('ERROR: Failed to apply image.')
raise GenericAbort raise GenericAbort
# Create Boot files # Create Boot files
try_and_print( try_and_print(
message = 'Updating boot files...', message = 'Updating boot files...',
function = update_boot_partition, function = update_boot_partition,
other_results = other_results) other_results = other_results)
# Setup WinRE # Setup WinRE
try_and_print( try_and_print(
message = 'Updating recovery tools...', message = 'Updating recovery tools...',
@ -392,8 +392,8 @@ def menu_setup():
windows_version = windows_version) windows_version = windows_version)
# Copy WinPE log(s) # Copy WinPE log(s)
source = r'{}\Info'.format(global_vars['ClientDir']) source = r'{}\Logs'.format(global_vars['ClientDir'])
dest = r'W:\{}\Info'.format(KIT_NAME_SHORT) dest = r'W:\{}\Logs\WinPE'.format(KIT_NAME_SHORT)
shutil.copytree(source, dest) shutil.copytree(source, dest)
# Print summary # Print summary

View file

@ -17,16 +17,16 @@ if __name__ == '__main__':
other_results = { other_results = {
'Error': {'CalledProcessError': 'Unknown Error'}, 'Error': {'CalledProcessError': 'Unknown Error'},
'Warning': {}} 'Warning': {}}
if not ask('Enable booting to SafeMode (with Networking)?'): if not ask('Enable booting to SafeMode (with Networking)?'):
abort() abort()
# Configure SafeMode # Configure SafeMode
try_and_print(message='Set BCD option...', try_and_print(message='Set BCD option...',
function=enable_safemode, other_results=other_results) function=enable_safemode, other_results=other_results)
try_and_print(message='Enable MSI in SafeMode...', try_and_print(message='Enable MSI in SafeMode...',
function=enable_safemode_msi, other_results=other_results) function=enable_safemode_msi, other_results=other_results)
# Done # Done
print_standard('\nDone.') print_standard('\nDone.')
pause('Press Enter to reboot...') pause('Press Enter to reboot...')

View file

@ -17,16 +17,16 @@ if __name__ == '__main__':
other_results = { other_results = {
'Error': {'CalledProcessError': 'Unknown Error'}, 'Error': {'CalledProcessError': 'Unknown Error'},
'Warning': {}} 'Warning': {}}
if not ask('Disable booting to SafeMode?'): if not ask('Disable booting to SafeMode?'):
abort() abort()
# Configure SafeMode # Configure SafeMode
try_and_print(message='Remove BCD option...', try_and_print(message='Remove BCD option...',
function=disable_safemode, other_results=other_results) function=disable_safemode, other_results=other_results)
try_and_print(message='Disable MSI in SafeMode...', try_and_print(message='Disable MSI in SafeMode...',
function=disable_safemode_msi, other_results=other_results) function=disable_safemode_msi, other_results=other_results)
# Done # Done
print_standard('\nDone.') print_standard('\nDone.')
pause('Press Enter to reboot...') pause('Press Enter to reboot...')

View file

@ -9,7 +9,7 @@ sys.path.append(os.getcwd())
from functions.repairs import * from functions.repairs import *
init_global_vars() init_global_vars()
os.system('title {}: SFC Tool'.format(KIT_NAME_FULL)) os.system('title {}: SFC Tool'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\SFC Tool.log'.format(**global_vars) set_log_file('SFC Tool.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -28,7 +28,7 @@ if __name__ == '__main__':
function=run_sfc_scan, other_results=other_results) function=run_sfc_scan, other_results=other_results)
else: else:
abort() abort()
# Done # Done
print_standard('\nDone.') print_standard('\nDone.')
pause('Press Enter to exit...') pause('Press Enter to exit...')

View file

@ -9,7 +9,7 @@ sys.path.append(os.getcwd())
from functions.product_keys import * from functions.product_keys import *
init_global_vars() init_global_vars()
os.system('title {}: Transferred Key Finder'.format(KIT_NAME_FULL)) os.system('title {}: Transferred Key Finder'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\Transferred Keys.log'.format(**global_vars) set_log_file('Transferred Keys.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -18,7 +18,7 @@ if __name__ == '__main__':
print_info('{}: Transferred Key Finder\n'.format(KIT_NAME_FULL)) print_info('{}: Transferred Key Finder\n'.format(KIT_NAME_FULL))
try_and_print(message='Searching for keys...', try_and_print(message='Searching for keys...',
function=list_clientdir_keys, print_return=True) function=list_clientdir_keys, print_return=True)
# Done # Done
print_standard('\nDone.') print_standard('\nDone.')
exit_script() exit_script()

View file

@ -10,7 +10,7 @@ from functions.data import *
from functions.repairs import * from functions.repairs import *
init_global_vars() init_global_vars()
os.system('title {}: User Data Transfer Tool'.format(KIT_NAME_FULL)) os.system('title {}: User Data Transfer Tool'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\User Data Transfer.log'.format(**global_vars) set_log_file('User Data Transfer.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -18,7 +18,7 @@ if __name__ == '__main__':
stay_awake() stay_awake()
clear_screen() clear_screen()
print_info('{}: User Data Transfer Tool\n'.format(KIT_NAME_FULL)) print_info('{}: User Data Transfer Tool\n'.format(KIT_NAME_FULL))
# Get backup name prefix # Get backup name prefix
ticket_number = get_ticket_number() ticket_number = get_ticket_number()
if ENABLED_TICKET_NUMBERS: if ENABLED_TICKET_NUMBERS:
@ -26,16 +26,16 @@ if __name__ == '__main__':
else: else:
backup_prefix = get_simple_string(prompt='Enter backup name prefix') backup_prefix = get_simple_string(prompt='Enter backup name prefix')
backup_prefix = backup_prefix.replace(' ', '_') backup_prefix = backup_prefix.replace(' ', '_')
# Set destination # Set destination
folder_path = r'{}\Transfer'.format(KIT_NAME_SHORT) folder_path = r'{}\Transfer'.format(KIT_NAME_SHORT)
dest = select_destination(folder_path=folder_path, dest = select_destination(folder_path=folder_path,
prompt='Which disk are we transferring to?') prompt='Which disk are we transferring to?')
# Set source items # Set source items
source = select_source(backup_prefix) source = select_source(backup_prefix)
items = scan_source(source, dest) items = scan_source(source, dest)
# Transfer # Transfer
clear_screen() clear_screen()
print_info('Transfer Details:\n') print_info('Transfer Details:\n')
@ -43,17 +43,17 @@ if __name__ == '__main__':
show_data('Ticket:', ticket_number) show_data('Ticket:', ticket_number)
show_data('Source:', source.path) show_data('Source:', source.path)
show_data('Destination:', dest) show_data('Destination:', dest)
if (not ask('Proceed with transfer?')): if (not ask('Proceed with transfer?')):
umount_backup_shares() umount_backup_shares()
abort() abort()
print_info('Transferring Data') print_info('Transferring Data')
transfer_source(source, dest, items) transfer_source(source, dest, items)
try_and_print(message='Removing extra files...', try_and_print(message='Removing extra files...',
function=cleanup_transfer, cs='Done', dest_path=dest) function=cleanup_transfer, cs='Done', dest_path=dest)
umount_backup_shares() umount_backup_shares()
# Done # Done
try_and_print(message='Running KVRT...', try_and_print(message='Running KVRT...',
function=run_kvrt, cs='Started') function=run_kvrt, cs='Started')

View file

@ -11,7 +11,7 @@ from functions.winpe_menus import *
TOOLS['SevenZip'].pop('64') TOOLS['SevenZip'].pop('64')
init_global_vars() init_global_vars()
set_title('{}: Root Menu'.format(KIT_NAME_FULL)) set_title('{}: Root Menu'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\WinPE.log'.format(**global_vars) set_log_file('WinPE.log')
if __name__ == '__main__': if __name__ == '__main__':
try: try: