From 233fa787fbc0884c8b742a084dd4bde3fc875cb5 Mon Sep 17 00:00:00 2001 From: Samuelopez-ansys Date: Fri, 26 Apr 2024 14:33:27 +0200 Subject: [PATCH] Fix Codacy --- pyaedt/desktop.py | 19 ++++++++++--------- pyaedt/misc/toolkit_manager.py | 10 +++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index 7eb0df2e04b..2cbcd7ff8e9 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -1702,7 +1702,6 @@ def add_custom_toolkit(self, toolkit_name, wheel_toolkit=None, install=True): # ------- bool """ - from pyaedt import is_windows from pyaedt.misc.install_extra_toolkits import available_toolkits toolkit = available_toolkits[toolkit_name] @@ -1746,8 +1745,10 @@ def run_command(command): command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) # nosec else: - process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = process.communicate() + process = subprocess.Popen( + command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) # nosec + _, stderr = process.communicate() ret_code = process.returncode if ret_code != 0: print("Error occurred:", stderr.decode("utf-8")) @@ -1769,7 +1770,7 @@ def run_command(command): pip_exe = os.path.join(venv_dir, "bin", "pip") package_dir = os.path.join(venv_dir, "Lib", "site-packages") edt_root = os.path.normpath(self.odesktop.GetExeDir()) - os.environ["ANSYSEM_ROOT{}".format(args.version)] = edt_root + os.environ["ANSYSEM_ROOT{}".format(version)] = edt_root ld_library_path_dirs_to_add = [ "{}/commonfiles/CPython/{}/linx64/Release/python/lib".format( edt_root, python_version.replace(".", "_") @@ -1777,8 +1778,8 @@ def run_command(command): "{}/common/mono/Linux64/lib64".format(edt_root), "{}".format(edt_root), ] - if args.version < "232": - ld_library_path_dirs_to_add.append("{}/Delcross".format(args.edt_root)) + if version < "232": + ld_library_path_dirs_to_add.append("{}/Delcross".format(edt_root)) os.environ["LD_LIBRARY_PATH"] = ( ":".join(ld_library_path_dirs_to_add) + ":" + os.getenv("LD_LIBRARY_PATH", "") ) @@ -1796,9 +1797,9 @@ def run_command(command): is_installed = True if wheel_toolkit: wheel_toolkit = os.path.normpath(wheel_toolkit) - self.logger.info("Installing dependencies".format(toolkit_name)) + self.logger.info("Installing dependencies") if install and wheel_toolkit and os.path.exists(wheel_toolkit): - self.logger.info("Starting offline installation".format(toolkit_name)) + self.logger.info("Starting offline installation") if is_installed: run_command('"{}" uninstall --yes {}'.format(pip_exe, toolkit["pip"])) import zipfile @@ -1825,7 +1826,7 @@ def run_command(command): # Update toolkit run_command('"{}" --default-timeout=1000 install {} -U'.format(pip_exe, toolkit["pip"])) else: - self.logger.info("Incorrect input".format(toolkit_name)) + self.logger.info("Incorrect input") return toolkit_dir = os.path.join(self.personallib, "Toolkits") tool_dir = os.path.join(toolkit_dir, toolkit["installation_path"], toolkit_name) diff --git a/pyaedt/misc/toolkit_manager.py b/pyaedt/misc/toolkit_manager.py index 9feabf8b12f..1e4c26b7d83 100644 --- a/pyaedt/misc/toolkit_manager.py +++ b/pyaedt/misc/toolkit_manager.py @@ -23,7 +23,7 @@ package_dir = os.path.join(venv_dir, "Lib", "site-packages") else: - venv_dir = os.path.join(os.environ["HOME"], "{}_env_ide".format(button["text"])) + venv_dir = os.path.join(os.environ["HOME"], "pyaedt_env_ide", "toolkits_v{}".format(version)) python_exe = os.path.join(venv_dir, "bin", "python") package_dir = os.path.join(venv_dir, "Lib", "site-packages") @@ -103,7 +103,7 @@ def update_page(event=None): update_page() - return install_button, uninstall_button, installation_option_action, input_file, toolkits_combo, toolkit_name + return install_button, uninstall_button, input_file, toolkits_combo, toolkit_name def is_toolkit_installed(toolkit_name): @@ -118,11 +118,11 @@ def open_window(window, window_name, open_source_toolkits): if not hasattr(window, "opened"): window.opened = True window.title(window_name) - install_button, uninstall_button, option_action, input_file, toolkits_combo, toolkit_name = create_toolkit_page( + install_button, uninstall_button, input_file, toolkits_combo, toolkit_name = create_toolkit_page( window, open_source_toolkits ) root.minsize(500, 250) - return install_button, uninstall_button, option_action, input_file, toolkits_combo, toolkit_name + return install_button, uninstall_button, input_file, toolkits_combo, toolkit_name else: window.deiconify() @@ -143,7 +143,7 @@ def toolkit_window(toolkit_level="Project"): if toolkit_info["installation_path"].lower() == toolkit_level.lower(): open_source_toolkits.append(toolkit_name) toolkit_window_var.minsize(250, 150) - install_button, uninstall_button, option_action, input_file, toolkits_combo, toolkit_name = open_window( + install_button, uninstall_button, input_file, toolkits_combo, toolkit_name = open_window( toolkit_window_var, toolkit_level, open_source_toolkits )