BITWISE operators =/= LOGICAL operators

This commit is contained in:
2Shirt 2019-06-04 18:24:01 -06:00
parent 5ccd628259
commit 7ccd4c6055
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 18 additions and 14 deletions

View file

@ -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,

View file

@ -318,7 +318,7 @@ class RecoveryState():
"""Checks if pass is done for all block-pairs, returns bool."""
done = True
for bp in self.block_pairs:
done &= bp.pass_done[self.current_pass]
done = done and bp.pass_done[self.current_pass]
return done
def current_pass_min(self):
@ -376,7 +376,8 @@ class RecoveryState():
self.total_size = 0
for bp in self.block_pairs:
bp.self_check()
self.resumed |= bp.resumed
if bp.resumed:
self.resumed = True
self.total_size += bp.size
def set_pass_num(self):
@ -386,7 +387,7 @@ class RecoveryState():
# Iterate backwards through passes
pass_done = True
for bp in self.block_pairs:
pass_done &= bp.pass_done[pass_num]
pass_done = pass_done and bp.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)
@ -742,9 +743,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 == 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
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

View file

@ -186,8 +186,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
@ -788,7 +788,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[3:4] + main_options[5:]:
state.quick_mode &= not opt['Enabled']
state.quick_mode = state.quick_mode and not opt['Enabled']
else:
state.quick_mode = False
@ -1001,7 +1001,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:
@ -1611,7 +1612,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)
@ -1620,7 +1622,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'))