From 7ccd4c605599fc74868fa385c4c2ada95d06d935 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 4 Jun 2019 18:24:01 -0600 Subject: [PATCH] BITWISE operators =/= LOGICAL operators --- .bin/Scripts/functions/browsers.py | 4 ++-- .bin/Scripts/functions/ddrescue.py | 13 +++++++------ .bin/Scripts/functions/hw_diags.py | 15 +++++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.bin/Scripts/functions/browsers.py b/.bin/Scripts/functions/browsers.py index dcb0ed2f..c4d110f7 100644 --- a/.bin/Scripts/functions/browsers.py +++ b/.bin/Scripts/functions/browsers.py @@ -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, diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index 545d08e0..4e6f7809 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -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 diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index bea5e01e..c085a5ed 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -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'))