Skip to content

Commit

Permalink
Fix Codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed Apr 26, 2024
1 parent 943af54 commit 233fa78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"))
Expand All @@ -1769,16 +1770,16 @@ 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(".", "_")
),
"{}/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", "")
)
Expand All @@ -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
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions pyaedt/misc/toolkit_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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):
Expand All @@ -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()

Expand All @@ -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
)

Expand Down

0 comments on commit 233fa78

Please sign in to comment.