-
Notifications
You must be signed in to change notification settings - Fork 5
Added vscode launch to Manage Python Environments tab #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
c727f92
fix style
anssakthi 157a87c
Update ci_cd.yml
anssakthi a2636c8
fix style
anssakthi e8a9691
Merge branch 'feature/remove-python-installations' of https://github.…
anssakthi 0247c26
adding warning/note for pre-compiled python version on linux
tusharbana-ansys e872bc0
minor
tusharbana-ansys 9c8d7ae
Merge remote-tracking branch 'origin/main' into feature/remove-python…
anssakthi 9b04cb8
fix style
anssakthi 6fdc0fe
centos & fedora specific changes
tusharbana-ansys 3763adb
fix style
anssakthi c95f96a
Merge branch 'main' into feature/remove-python-installations
anssakthi ad6fdfe
fix style
anssakthi 8fc406c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f0663ae
Update ci_cd.yml
anssakthi 1e0989b
fix style
anssakthi 3550842
Merge branch 'feature/remove-python-installations' of https://github.…
anssakthi 8b06509
fix style
anssakthi a355f70
centos/fedora uninstaller script fix
tusharbana-ansys 3156b72
fix style
tusharbana-ansys 85f4a84
fix style
tusharbana-ansys 70f7426
Update src/ansys/tools/installer/installed_table.py
RobPasMue 4b8eb06
Update src/ansys/tools/installer/main.py
RobPasMue 5d148df
Merge branch 'main' into feature/remove-python-installations
RobPasMue 5a6f3b7
fix style
anssakthi f57a2f4
Update ci_cd.yml
anssakthi 3ec3089
fix style
anssakthi 6298a11
fix style
anssakthi 26c8f83
fix style
anssakthi c75f8b7
fix style
anssakthi d55dfe2
Merge remote-tracking branch 'origin/main' into vcode-enablement
anssakthi 92a7c2f
fix style
anssakthi 11c4131
fix style
anssakthi 0c35e2a
fix style
anssakthi 7a492e8
fix style
anssakthi 6aa8c26
Update ci_cd.yml
anssakthi bcc25fa
Merge branch 'main' into vcode-enablement
anssakthi 63f2916
Update ci_cd.yml
anssakthi 4bba9c2
Update src/ansys/tools/installer/vscode.py
anssakthi b28d15b
Update doc/source/installer.rst
anssakthi 85f0ebb
Apply suggestions from code review
anssakthi f7b5228
wip
anssakthi 5911599
wip
anssakthi 3cb8a1d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 630ddc8
Merge branch 'main' into vcode-enablement
RobPasMue de72230
wip
anssakthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| # Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. | ||
|
|
||
| """VS code launch window.""" | ||
| import os | ||
|
|
||
| from PySide6 import QtCore, QtGui, QtWidgets | ||
|
|
||
| from ansys.tools.installer.constants import ANSYS_FAVICON, USER_PATH | ||
|
|
||
|
|
||
| class VSCode(QtWidgets.QWidget): | ||
| """VS code launch window.""" | ||
anssakthi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def __init__(self, parent): | ||
| """Initialize this class.""" | ||
| try: | ||
| super().__init__() | ||
| self._parent = parent | ||
| if self.is_vscode_installed(): | ||
| self._parent.vscode_window = QtWidgets.QWidget() | ||
| self._parent.vscode_window.move( | ||
| self._parent.vscode_window.frameGeometry().center() | ||
| ) | ||
| vscode_window_label = QtWidgets.QLabel() | ||
| vscode_window_label.setText("Configuration") | ||
| vscode_window_label.setTextFormat(QtCore.Qt.TextFormat.RichText) | ||
| vscode_window_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignJustify) | ||
| vscode_window_label.setWordWrap(True) | ||
|
|
||
| vscode_layout = QtWidgets.QVBoxLayout() | ||
|
|
||
| # Group 1: Configure default Virtual Environment creation path | ||
| vscode_window_path_config = QtWidgets.QGroupBox( | ||
| "VS Code open directory:" | ||
| ) | ||
| vscode_window_path_config_layout = QtWidgets.QVBoxLayout() | ||
| vscode_window_path_config_layout.setContentsMargins(10, 20, 10, 20) | ||
| vscode_window_path_config.setLayout(vscode_window_path_config_layout) | ||
|
|
||
| # ---> Add box | ||
| self.vscode_window_path_config_edit = QtWidgets.QLineEdit() | ||
| self.vscode_window_path_config_edit.setText(USER_PATH) | ||
| vscode_window_path_config_layout.addWidget( | ||
| self.vscode_window_path_config_edit | ||
| ) | ||
|
|
||
| self.vscode_warning_text = QtWidgets.QLabel() | ||
| self.vscode_warning_text.setAlignment( | ||
| QtCore.Qt.AlignmentFlag.AlignJustify | ||
| ) | ||
| self.vscode_warning_text.setWordWrap(True) | ||
| vscode_window_path_config_layout.addWidget(self.vscode_warning_text) | ||
|
|
||
| # Finally, add all the previous widgets to the global layout | ||
| vscode_layout.addWidget(vscode_window_path_config) | ||
|
|
||
| vscode_window_button_open = QtWidgets.QPushButton("Open") | ||
| vscode_window_button_open.clicked.connect( | ||
| lambda x: self._pop_up("Do you want to open?", self._open_vscode) | ||
| ) | ||
| vscode_window_button_close = QtWidgets.QPushButton("Close") | ||
| vscode_window_button_close.clicked.connect( | ||
| lambda x: self._pop_up("Do you want to close?", self._close_all) | ||
| ) | ||
|
|
||
| vscode_window_layout_1 = QtWidgets.QHBoxLayout() | ||
| vscode_window_layout_1.addWidget(vscode_window_label) | ||
| vscode_window_layout_2 = QtWidgets.QHBoxLayout() | ||
| vscode_window_layout_2.addWidget(vscode_window_button_open) | ||
| vscode_window_layout_2.addWidget(vscode_window_button_close) | ||
|
|
||
| vscode_window_layout = QtWidgets.QVBoxLayout() | ||
| vscode_window_layout.addLayout(vscode_window_layout_1) | ||
| vscode_window_layout.addLayout(vscode_layout) | ||
| vscode_window_layout.addLayout(vscode_window_layout_2) | ||
| self._parent.vscode_window.setLayout(vscode_window_layout) | ||
|
|
||
| self._parent.vscode_window.setWindowTitle("Configuration") | ||
| self._parent.vscode_window.setWindowIcon(QtGui.QIcon(ANSYS_FAVICON)) | ||
| self._parent.vscode_window.resize(500, 40) | ||
| self._parent.vscode_window.show() | ||
| else: | ||
| msg = QtWidgets.QMessageBox() | ||
| msg.setTextFormat(QtCore.Qt.TextFormat.RichText) | ||
| msg.warning( | ||
| self, | ||
| "VS Code Launch Error", | ||
| f"Failed to launch vscode. Try reinstalling code by following this <a href='https://code.visualstudio.com/download'>link</a>", | ||
| ) | ||
|
|
||
| except Exception as e: | ||
| self._parent.show_error(str(e)) | ||
|
|
||
| def _open_vscode(self): | ||
| """Open VS code from path.""" | ||
| # handle errors | ||
| path = self.vscode_window_path_config_edit.text().strip() | ||
| if os.path.exists(path): | ||
| error_msg = "echo Failed to launch vscode. Try reinstalling code by following this link https://code.visualstudio.com/download" | ||
| self._parent.launch_cmd(f"code {path} && exit 0 || {error_msg}") | ||
|
|
||
| self.user_confirmation_form.close() | ||
| self._parent.vscode_window.close() | ||
| else: | ||
| self.vscode_warning_text.setText( | ||
| f"""{path} does not exist. Provide a valid path.""" | ||
| ) | ||
| self.vscode_warning_text.setStyleSheet( | ||
| """ | ||
| color: rgb(255, 0, 0); | ||
| """ | ||
| ) | ||
| self.user_confirmation_form.close() | ||
|
|
||
| def _close_all(self): | ||
| """Close all the pop-up window.""" | ||
| self.user_confirmation_form.close() | ||
| self._parent.vscode_window.close() | ||
|
|
||
| def _pop_up(self, message, call_back): | ||
| """Launch the confirmation pop-up window.""" | ||
| self.user_confirmation_form = QtWidgets.QWidget() | ||
| self.user_confirmation_form.move( | ||
| self.user_confirmation_form.frameGeometry().center() | ||
| ) | ||
| user_confirmation_label = QtWidgets.QLabel() | ||
| user_confirmation_label.setText(message) | ||
| user_confirmation_label.setOpenExternalLinks(True) | ||
| user_confirmation_label.setTextFormat(QtCore.Qt.TextFormat.RichText) | ||
| user_confirmation_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignJustify) | ||
| user_confirmation_label.setWordWrap(True) | ||
|
|
||
| user_confirmation_layout_horizontal = QtWidgets.QHBoxLayout() | ||
| user_confirmation_yes_button = QtWidgets.QPushButton("Yes") | ||
| user_confirmation_yes_button.clicked.connect(call_back) | ||
| user_confirmation_no_button = QtWidgets.QPushButton("No") | ||
| user_confirmation_no_button.clicked.connect(self.user_confirmation_form.close) | ||
| user_confirmation_layout = QtWidgets.QVBoxLayout() | ||
| user_confirmation_layout.addWidget(user_confirmation_label) | ||
| user_confirmation_layout_horizontal.addWidget(user_confirmation_yes_button) | ||
| user_confirmation_layout_horizontal.addWidget(user_confirmation_no_button) | ||
| user_confirmation_layout.addLayout(user_confirmation_layout_horizontal) | ||
| self.user_confirmation_form.setLayout(user_confirmation_layout) | ||
| self.user_confirmation_form.setWindowTitle("Confirmation") | ||
| icon = QtGui.QIcon(ANSYS_FAVICON) | ||
| self.user_confirmation_form.setWindowIcon(icon) | ||
| self.user_confirmation_form.resize(400, 40) | ||
| self.user_confirmation_form.setWindowFlag( | ||
| QtCore.Qt.WindowCloseButtonHint, False | ||
| ) | ||
| self.user_confirmation_form.show() | ||
|
|
||
| def is_vscode_installed(self): | ||
| """Check if VSCode is installed or not. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| Whether VSCode is installed or not. | ||
| """ | ||
| try: | ||
| return_val = os.system("code --version") | ||
| if return_val == 0: | ||
| return True | ||
| else: | ||
| return False | ||
| except: | ||
| return False | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.