BITWISE operators =/= LOGICAL operators
* Also fixed is_writable_dir()
This commit is contained in:
parent
d06f505a84
commit
385f4a1d15
6 changed files with 31 additions and 25 deletions
|
|
@ -32,8 +32,8 @@ def archive_all_users():
|
|||
user_path = os.path.join(users_root, user_name)
|
||||
appdata_local = os.path.join(user_path, r'AppData\Local')
|
||||
appdata_roaming = os.path.join(user_path, r'AppData\Roaming')
|
||||
valid_user &= os.path.exists(appdata_local)
|
||||
valid_user &= os.path.exists(appdata_roaming)
|
||||
valid_user = valid_user and os.path.exists(appdata_local)
|
||||
valid_user = valid_user and os.path.exists(appdata_roaming)
|
||||
if valid_user:
|
||||
user_envs.append({
|
||||
'USERNAME': user_name,
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ class RecoveryState():
|
|||
"""Checks if pass is done for all block-pairs, returns bool."""
|
||||
done = True
|
||||
for b_pair in self.block_pairs:
|
||||
done &= b_pair.pass_done[self.current_pass]
|
||||
done = done and b_pair.pass_done[self.current_pass]
|
||||
return done
|
||||
|
||||
def current_pass_min(self):
|
||||
|
|
@ -543,7 +543,8 @@ class RecoveryState():
|
|||
self.total_size = 0
|
||||
for b_pair in self.block_pairs:
|
||||
b_pair.self_check()
|
||||
self.resumed |= b_pair.resumed
|
||||
if b_pair.resumed:
|
||||
self.resumed = True
|
||||
self.total_size += b_pair.size
|
||||
|
||||
def set_pass_num(self):
|
||||
|
|
@ -553,7 +554,7 @@ class RecoveryState():
|
|||
# Iterate backwards through passes
|
||||
pass_done = True
|
||||
for b_pair in self.block_pairs:
|
||||
pass_done &= b_pair.pass_done[pass_num]
|
||||
pass_done = pass_done and b_pair.pass_done[pass_num]
|
||||
if pass_done:
|
||||
# All block-pairs reported being done
|
||||
# Set to next pass, unless we're on the last pass (2)
|
||||
|
|
@ -849,9 +850,9 @@ def is_writable_dir(dir_obj):
|
|||
"""Check if we have read-write-execute permissions, returns bool."""
|
||||
is_ok = True
|
||||
path_st_mode = os.stat(dir_obj.path).st_mode
|
||||
is_ok &= path_st_mode & stat.S_IRUSR
|
||||
is_ok &= path_st_mode & stat.S_IWUSR
|
||||
is_ok &= path_st_mode & stat.S_IXUSR
|
||||
is_ok = is_ok and path_st_mode & stat.S_IRUSR
|
||||
is_ok = is_ok and path_st_mode & stat.S_IWUSR
|
||||
is_ok = is_ok and path_st_mode & stat.S_IXUSR
|
||||
return is_ok
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ class DiskObj():
|
|||
disk_ok = False
|
||||
|
||||
# Disable override if necessary
|
||||
self.override_disabled |= ATTRIBUTES[attr_type][k].get(
|
||||
'Critical', False)
|
||||
if ATTRIBUTES[attr_type][k].get('Critical', False):
|
||||
self.override_disabled = True
|
||||
|
||||
# SMART overall assessment
|
||||
## NOTE: Only fail drives if the overall value exists and reports failed
|
||||
|
|
@ -441,7 +441,7 @@ class DiskObj():
|
|||
|
||||
# Check partitions
|
||||
for part in json_data.get('partitiontable', {}).get('partitions', []):
|
||||
aligned &= part.get('start', -1) % 4096 == 0
|
||||
aligned = aligned and part.get('start', -1) % 4096 == 0
|
||||
|
||||
# Done
|
||||
return aligned
|
||||
|
|
@ -875,7 +875,7 @@ def menu_diags(state, args):
|
|||
# If so, verify no other tests are enabled and set quick_mode
|
||||
state.quick_mode = True
|
||||
for opt in main_options[4:5] + main_options[6:]:
|
||||
state.quick_mode &= not opt['Enabled']
|
||||
state.quick_mode = state.quick_mode and not opt['Enabled']
|
||||
else:
|
||||
state.quick_mode = False
|
||||
|
||||
|
|
@ -1057,7 +1057,8 @@ def run_hw_tests(state):
|
|||
tests_enabled = False
|
||||
|
||||
# Disable osTicket Integration if necessary
|
||||
state.ost.disabled |= '--quick' in state.args
|
||||
if '--quick' in state.args:
|
||||
state.ost.disabled = True
|
||||
|
||||
# Build Panes
|
||||
update_progress_pane(state)
|
||||
|
|
@ -1104,7 +1105,8 @@ def run_hw_tests(state):
|
|||
# Run disk safety checks (if necessary)
|
||||
_disk_tests_enabled = False
|
||||
for k in TESTS_DISK:
|
||||
_disk_tests_enabled |= state.tests[k]['Enabled']
|
||||
if state.tests[k]['Enabled']:
|
||||
_disk_tests_enabled = True
|
||||
if _disk_tests_enabled:
|
||||
for disk in state.disks:
|
||||
try:
|
||||
|
|
@ -1176,8 +1178,8 @@ def run_hw_tests(state):
|
|||
# Aborted/Unknown/etc
|
||||
all_disks_passed = False
|
||||
else:
|
||||
all_disks_passed &= disk.checkbox
|
||||
disk_failures |= not disk.checkbox
|
||||
all_disks_passed = all_disks_passed and disk.checkbox
|
||||
disk_failures = disk_failures or not disk.checkbox
|
||||
|
||||
# Update checkbox if necessary
|
||||
if disk_failures:
|
||||
|
|
@ -1755,7 +1757,8 @@ def show_results(state):
|
|||
# CPU tests
|
||||
_enabled = False
|
||||
for k in TESTS_CPU:
|
||||
_enabled |= state.tests[k]['Enabled']
|
||||
if state.tests[k]['Enabled']:
|
||||
_enabled = True
|
||||
if _enabled:
|
||||
print_success('CPU:'.format(k))
|
||||
show_report(state.cpu.generate_cpu_report(), log_report=True)
|
||||
|
|
@ -1764,7 +1767,8 @@ def show_results(state):
|
|||
# Disk tests
|
||||
_enabled = False
|
||||
for k in TESTS_DISK:
|
||||
_enabled |= state.tests[k]['Enabled']
|
||||
if state.tests[k]['Enabled']:
|
||||
_enabled = True
|
||||
if _enabled:
|
||||
print_success('Disk{}:'.format(
|
||||
'' if len(state.disks) == 1 else 's'))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def check_4k_alignment(show_alert=False):
|
|||
continue
|
||||
|
||||
try:
|
||||
aligned &= int(off) % 4096 == 0
|
||||
aligned = aligned and int(off) % 4096 == 0
|
||||
except ValueError:
|
||||
# Ignore, this check is low priority
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -123,15 +123,15 @@ if __name__ == '__main__':
|
|||
result = try_and_print(
|
||||
message='CHKDSK ({SYSTEMDRIVE})...'.format(**global_vars['Env']),
|
||||
function=run_chkdsk, other_results=other_results)
|
||||
system_ok &= check_result(result, other_results)
|
||||
system_ok = system_ok and check_result(result, other_results)
|
||||
result = try_and_print(message='SFC scan...',
|
||||
function=run_sfc_scan, other_results=other_results)
|
||||
system_ok &= check_result(result, other_results)
|
||||
system_ok = system_ok and check_result(result, other_results)
|
||||
if D7_MODE:
|
||||
result = try_and_print(message='DISM RestoreHealth...',
|
||||
function=run_dism, other_results=other_results, repair=True)
|
||||
if global_vars['OS']['Version'] in ('8', '8.1', '10'):
|
||||
system_ok &= check_result(result, other_results)
|
||||
system_ok = system_ok and check_result(result, other_results)
|
||||
else:
|
||||
try_and_print(message='DISM CheckHealth...',
|
||||
function=run_dism, other_results=other_results, repair=False)
|
||||
|
|
|
|||
|
|
@ -177,11 +177,12 @@ def get_actions(setup_mode, answers):
|
|||
_win10_only = _val.get('Win10 only', False)
|
||||
|
||||
# Set enabled status
|
||||
_action['Enabled'] = _val.get(setup_mode, False)
|
||||
_enabled = _val.get(setup_mode, False)
|
||||
if _if_answer:
|
||||
_action['Enabled'] &= answers[_if_answer]
|
||||
_enabled = _enabled and answers[_if_answer]
|
||||
if _win10_only:
|
||||
_action['Enabled'] &= global_vars['OS']['Version'] == '10'
|
||||
_enabled = _enabled and global_vars['OS']['Version'] == '10'
|
||||
_action['Enabled'] = _enabled
|
||||
|
||||
# Set other keys
|
||||
for _sub_key in SETUP_ACTION_KEYS:
|
||||
|
|
|
|||
Loading…
Reference in a new issue