From dd27e08a98c1564431d5464bc52687935b897474 Mon Sep 17 00:00:00 2001 From: Yogesh Mahajan Date: Fri, 24 Jul 2020 12:15:29 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20code=20smell=C2=A0'Unused=20local=20var?= =?UTF-8?q?iables=20should=20be=20removed'.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/copyright_updater.py | 2 +- tools/dependency_inventory.py | 2 +- tools/get_chromedriver.py | 4 ++-- web/pgadmin/browser/__init__.py | 2 +- .../browser/server_groups/servers/databases/__init__.py | 1 - web/pgadmin/browser/utils.py | 2 +- web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py | 2 +- web/pgadmin/feature_tests/query_tool_tests.py | 2 +- .../feature_tests/xss_checks_panels_and_query_tool_test.py | 2 +- web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py | 2 +- web/pgadmin/utils/csv.py | 2 +- web/regression/feature_utils/app_starter.py | 2 +- web/regression/feature_utils/pgadmin_page.py | 4 ++-- web/regression/python_test_utils/test_utils.py | 3 ++- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/copyright_updater.py b/tools/copyright_updater.py index 3b67ce7fe..b7d99d3a2 100644 --- a/tools/copyright_updater.py +++ b/tools/copyright_updater.py @@ -72,7 +72,7 @@ def find_replace(directory, find, replace): print("Done") else: print("N/A") - except Exception as e: + except Exception: failed.append(current_file) print("FAILED") diff --git a/tools/dependency_inventory.py b/tools/dependency_inventory.py index 30b37788b..36479a024 100644 --- a/tools/dependency_inventory.py +++ b/tools/dependency_inventory.py @@ -65,7 +65,7 @@ def get_python_deps(): try: distribution = pkg_resources.get_distribution(pkg) - except IndexError as e: + except IndexError: # The package probably isn't required on this version of Python, # thus we have no info about it. have_unknowns = True diff --git a/tools/get_chromedriver.py b/tools/get_chromedriver.py index 01bfff306..5f33136af 100644 --- a/tools/get_chromedriver.py +++ b/tools/get_chromedriver.py @@ -61,11 +61,11 @@ def get_chrome_version(args): def _read_registry(root, key, value): try: hkey = winreg.OpenKey(root, key) - except Exception as e: + except Exception: return None try: (val, typ) = winreg.QueryValueEx(hkey, value) - except Exception as e: + except Exception: winreg.CloseKey(hkey) return None diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py index b4b721b54..99c9bbec0 100644 --- a/web/pgadmin/browser/__init__.py +++ b/web/pgadmin/browser/__init__.py @@ -718,7 +718,7 @@ def utils(): from pgadmin.utils.driver import get_driver driver = get_driver(PG_DEFAULT_DRIVER) pg_libpq_version = driver.libpq_version() - except Exception as e: + except Exception: pg_libpq_version = 0 for submodule in current_blueprint.submodules: diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py index 35f32208d..6c6472583 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py @@ -232,7 +232,6 @@ class DatabaseView(PGChildNodeView): if self.manager.db == row['name']: row['canDrop'] = False else: - conn = self.manager.connection(row['name'], did=row['did']) row['canDrop'] = True return ajax_response( diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py index 122cf1f10..ab0e86a02 100644 --- a/web/pgadmin/browser/utils.py +++ b/web/pgadmin/browser/utils.py @@ -428,7 +428,7 @@ class PGChildNodeView(NodeView): return internal_server_error(errormsg=msg) except (ConnectionLost, SSHTunnelConnectionLost, CryptKeyMissing): raise - except Exception as e: + except Exception: return precondition_required( gettext( "Connection to the server has been lost." diff --git a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py index 9cb92c253..91b514fe2 100644 --- a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py +++ b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py @@ -104,7 +104,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest): lambda driver: driver.find_element_by_name( NavMenuLocators.backup_filename_txt_box_name)): click = False - except Exception as e: + except Exception: pass # Wait for the backup status alertfier diff --git a/web/pgadmin/feature_tests/query_tool_tests.py b/web/pgadmin/feature_tests/query_tool_tests.py index 213a8bcd9..6c4826994 100644 --- a/web/pgadmin/feature_tests/query_tool_tests.py +++ b/web/pgadmin/feature_tests/query_tool_tests.py @@ -674,7 +674,7 @@ SELECT 1, pg_sleep(300)""" show_jit = pg_cursor.fetchone() if show_jit[0] == 'on': jit_enabled = True - except Exception as e: + except Exception: pass connection.close() diff --git a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py index 38e24db15..d2f10a40e 100644 --- a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py +++ b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py @@ -314,7 +314,7 @@ class CheckForXssFeatureTest(BaseFeatureTest): ) ).perform() break - except Exception as e: + except Exception: if idx != 2: continue else: diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py index fa5028b82..3becd1539 100644 --- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py +++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py @@ -88,7 +88,7 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest): "contains(@class,'ajs-header')]") )) - except TimeoutException as e: + except TimeoutException: is_error = None # If debugger plugin is not found diff --git a/web/pgadmin/utils/csv.py b/web/pgadmin/utils/csv.py index 0a9edffa6..a29eb9aa9 100644 --- a/web/pgadmin/utils/csv.py +++ b/web/pgadmin/utils/csv.py @@ -485,7 +485,7 @@ def register_dialect(name, dialect='excel', **fmtparams): try: Dialect.validate(dialect) - except Exception as e: + except Exception: raise TypeError('dialect is invalid') assert name not in _dialect_registry diff --git a/web/regression/feature_utils/app_starter.py b/web/regression/feature_utils/app_starter.py index 7de10b25c..cf418b67b 100644 --- a/web/regression/feature_utils/app_starter.py +++ b/web/regression/feature_utils/app_starter.py @@ -49,7 +49,7 @@ class AppStarter: random_server_port ) - except WebDriverException as e: + except WebDriverException: # In case of WebDriverException sleep for 1 second and retry # again. Retry 10 times and if still app will not start then # raise exception. diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py index 4462a366d..4c2628fc0 100644 --- a/web/regression/feature_utils/pgadmin_page.py +++ b/web/regression/feature_utils/pgadmin_page.py @@ -1020,7 +1020,7 @@ class PgadminPage: WebDriverWait(self.driver, timeout, .01).until( EC.visibility_of_element_located((By.XPATH, xpath))) element_found = True - except Exception as e: + except Exception: pass return element_found @@ -1141,7 +1141,7 @@ class PgadminPage: EC.visibility_of_any_elements_located(( By.XPATH, locator))): elements_located_status = True - except Exception as e: + except Exception: pass return elements_located_status diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py index 9e251e3b1..d137ffcde 100644 --- a/web/regression/python_test_utils/test_utils.py +++ b/web/regression/python_test_utils/test_utils.py @@ -1331,6 +1331,7 @@ def launch_url_in_browser(driver_instance, url, title='pgAdmin 4', timeout=50): time.sleep(6) count -= 1 if count == 0: + print(str(e)) exception_msg = 'Web-page title did not match to {0}. ' \ 'Please check url {1} accessible on ' \ 'internet.'.format(title, url) @@ -1475,7 +1476,7 @@ def get_selenium_grid_status_json(selenoid_url): selenoid_status = json.load(selenoid_status) if isinstance(selenoid_status, dict): return selenoid_status - except Exception as e: + except Exception: print("Unable to find Selenoid Status.Kindly check url passed -'{0}'." "Check parsing errors in test_config.json".format(selenoid_url)) return None