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) user_path = os.path.join(users_root, user_name)
appdata_local = os.path.join(user_path, r'AppData\Local') appdata_local = os.path.join(user_path, r'AppData\Local')
appdata_roaming = os.path.join(user_path, r'AppData\Roaming') appdata_roaming = os.path.join(user_path, r'AppData\Roaming')
valid_user &= os.path.exists(appdata_local) valid_user = valid_user and os.path.exists(appdata_local)
valid_user &= os.path.exists(appdata_roaming) valid_user = valid_user and os.path.exists(appdata_roaming)
if valid_user: if valid_user:
user_envs.append({ user_envs.append({
'USERNAME': user_name, 'USERNAME': user_name,

View file

@ -318,7 +318,7 @@ class RecoveryState():
"""Checks if pass is done for all block-pairs, returns bool.""" """Checks if pass is done for all block-pairs, returns bool."""
done = True done = True
for bp in self.block_pairs: for bp in self.block_pairs:
done &= bp.pass_done[self.current_pass] done = done and bp.pass_done[self.current_pass]
return done return done
def current_pass_min(self): def current_pass_min(self):
@ -376,7 +376,8 @@ class RecoveryState():
self.total_size = 0 self.total_size = 0
for bp in self.block_pairs: for bp in self.block_pairs:
bp.self_check() bp.self_check()
self.resumed |= bp.resumed if bp.resumed:
self.resumed = True
self.total_size += bp.size self.total_size += bp.size
def set_pass_num(self): def set_pass_num(self):
@ -386,7 +387,7 @@ class RecoveryState():
# Iterate backwards through passes # Iterate backwards through passes
pass_done = True pass_done = True
for bp in self.block_pairs: 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: if pass_done:
# All block-pairs reported being done # All block-pairs reported being done
# Set to next pass, unless we're on the last pass (2) # 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.""" """Check if we have read-write-execute permissions, returns bool."""
is_ok = True is_ok = True
path_st_mode = os.stat(dir_obj.path).st_mode 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_IRUSR
is_ok == is_ok and path_st_mode & stat.S_IWUSR 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_IXUSR
return is_ok return is_ok

View file

@ -186,8 +186,8 @@ class DiskObj():
disk_ok = False disk_ok = False
# Disable override if necessary # Disable override if necessary
self.override_disabled |= ATTRIBUTES[attr_type][k].get( if ATTRIBUTES[attr_type][k].get('Critical', False):
'Critical', False) self.override_disabled = True
# SMART overall assessment # SMART overall assessment
## NOTE: Only fail drives if the overall value exists and reports failed ## 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 # If so, verify no other tests are enabled and set quick_mode
state.quick_mode = True state.quick_mode = True
for opt in main_options[3:4] + main_options[5:]: 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: else:
state.quick_mode = False state.quick_mode = False
@ -1001,7 +1001,8 @@ def run_hw_tests(state):
# Run disk safety checks (if necessary) # Run disk safety checks (if necessary)
_disk_tests_enabled = False _disk_tests_enabled = False
for k in TESTS_DISK: 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: if _disk_tests_enabled:
for disk in state.disks: for disk in state.disks:
try: try:
@ -1611,7 +1612,8 @@ def show_results(state):
# CPU tests # CPU tests
_enabled = False _enabled = False
for k in TESTS_CPU: for k in TESTS_CPU:
_enabled |= state.tests[k]['Enabled'] if state.tests[k]['Enabled']:
_enabled = True
if _enabled: if _enabled:
print_success('CPU:'.format(k)) print_success('CPU:'.format(k))
show_report(state.cpu.generate_cpu_report(), log_report=True) show_report(state.cpu.generate_cpu_report(), log_report=True)
@ -1620,7 +1622,8 @@ def show_results(state):
# Disk tests # Disk tests
_enabled = False _enabled = False
for k in TESTS_DISK: for k in TESTS_DISK:
_enabled |= state.tests[k]['Enabled'] if state.tests[k]['Enabled']:
_enabled = True
if _enabled: if _enabled:
print_success('Disk{}:'.format( print_success('Disk{}:'.format(
'' if len(state.disks) == 1 else 's')) '' if len(state.disks) == 1 else 's'))