support launching pywb on linux#209
Conversation
| # 'wmi' cannot be imported | ||
| self._wmi = None | ||
|
|
||
| if not self._wmi: |
There was a problem hiding this comment.
this line will be run also on Windows when it fails to load the wmi.
I think we should raise an exception after line 54 to clearly state the issue.
The current message at line 64 is confusing.
There was a problem hiding this comment.
Good point. Adjusted the code so it branches based on platform. @asawas
| ): | ||
| raise Exception("Invalid ANSYS version: " + version) | ||
|
|
||
| if host and not self._wmi: |
There was a problem hiding this comment.
The host could be the "localhost" or "127.0.0.1" which should be valid on Linux, right?
There was a problem hiding this comment.
@asawas User is required to not specify the host argument if launching wb on local machine. So we are good here.
There was a problem hiding this comment.
The parameter description does not clearly state that. Users may make such mistake since using "localhost" or "127.0.0.1" is a common practice to specify the local machine.
There was a problem hiding this comment.
we could include the host value in the error message for easier troubleshooting.
There was a problem hiding this comment.
Yes, that makes sense. Added host value in the message for failed connection to the host.
|
|
||
| ## Connect to a remote Workbench server | ||
|
|
||
| Execute the steps below to link PyWorkbench with a remote session: |
There was a problem hiding this comment.
| Execute the steps below to link PyWorkbench with a remote session: | |
| Execute the following steps to link PyWorkbench with a remote session: |
Google dev doc style guide says not to use placement locators like above and below but rather use preceding and following.
| workbench.download_file("*.out") | ||
| ``` | ||
|
|
||
| Use the ``{download_project_archive()}`` function to save, archive, and download the current Workbench project from the server to the client: |
There was a problem hiding this comment.
Should the brackets be in the function tagged entity? I've never seen this before.
|
|
||
| self._wmi = wmi | ||
| if not self._wmi: | ||
| raise Exception("Required Python module WMI does not exist or not loading properly") |
There was a problem hiding this comment.
| raise Exception("Required Python module WMI does not exist or not loading properly") | |
| raise Exception("Required Python module WMI does not exist or is not loading properly.") |
Messages should be complete sentences and concluding punctuation.
| self._libc = None | ||
| if not self._libc: | ||
| raise Exception( | ||
| "Required Python module ctypes does not exist or not loading libc.so.6 properly" |
There was a problem hiding this comment.
| "Required Python module ctypes does not exist or not loading libc.so.6 properly" | |
| "Required Python module ctypes do not exist or 'libc.so.6' is not loading properly." |
| Parameters | ||
| ---------- | ||
| version : str | ||
| Workbench version to launch. It must be a 3-digit version that is "242" or later. |
There was a problem hiding this comment.
| Workbench version to launch. It must be a 3-digit version that is "242" or later. | |
| Workbench version to launch. It must be a three-digit version, such as ``242`` or later. |
| version : str | ||
| Workbench version to launch. It must be a 3-digit version that is "242" or later. | ||
| show_gui : bool, default: True | ||
| Weather to launch Workbench in UI mode. |
There was a problem hiding this comment.
| Weather to launch Workbench in UI mode. | |
| Whether to launch Workbench in UI mode. |
| show_gui : bool, default: True | ||
| Weather to launch Workbench in UI mode. | ||
| server_workdir : str, default: None | ||
| Path to a writable directory on the server computer. The default is ``None``, |
There was a problem hiding this comment.
| Path to a writable directory on the server computer. The default is ``None``, | |
| Path to a writable directory on the server. The default is ``None``, |
I've not seen any other Ansys library use "server computer" but only "server" instead.
| Server computer's name or IP address. The default is ``None`` for launching on the | ||
| local computer. |
There was a problem hiding this comment.
| Server computer's name or IP address. The default is ``None`` for launching on the | |
| local computer. | |
| Name or IP address of the server. The default is ``None``, which launches | |
| Workbench on the local computer. |
Assuming it is launching Workbench but perhaps this and subsequent changes should be PyWorkbench?
| User's login name on the server computer. The default is ``None`` for launching on | ||
| the local computer. |
There was a problem hiding this comment.
| User's login name on the server computer. The default is ``None`` for launching on | |
| the local computer. | |
| User's login name on the server. The default is ``None``, which launches | |
| Workbench on the local computer. |
| User's password on the server computer. The default is ``None`` for launching on | ||
| the local computer. |
There was a problem hiding this comment.
| User's password on the server computer. The default is ``None`` for launching on | |
| the local computer. | |
| User's password on the server. The default is ``None``, which launches | |
| Workbench on the local computer. |
| If wmi service is not available for remote launching | ||
| If the host is given but username or password is missing. |
There was a problem hiding this comment.
| If wmi service is not available for remote launching | |
| If the host is given but username or password is missing. | |
| If the wmi service is not available for remote launching. | |
| If the host is given but the username or password is missing. |
| raise Exception("Invalid ANSYS version: " + version) | ||
|
|
||
| if host and not self._wmi: | ||
| raise Exception("Launching PyWorkbench on a remote machine from Linux is not supported") |
There was a problem hiding this comment.
| raise Exception("Launching PyWorkbench on a remote machine from Linux is not supported") | |
| raise Exception("Launching PyWorkbench on a remote machine from Linux is not supported.") |
| or version[0] not in ["2", "3"] | ||
| or version[2] not in ["1", "2"] | ||
| ): | ||
| raise Exception("Invalid ANSYS version: " + version) |
There was a problem hiding this comment.
| raise Exception("Invalid ANSYS version: " + version) | |
| raise Exception("Invalid Ansys version: " + version) |
| raise Exception( | ||
| "Launching PyWorkbench on a remote machine failed. " | ||
| "Make sure that the remote host is a Windows machine and that " | ||
| "correct credential is used." |
There was a problem hiding this comment.
| "correct credential is used." | |
| "the correct credential is used." |
Adding the article "the" to improve readability.
| self._process_id = process.pid | ||
| self._process = process | ||
| if successful: | ||
| logging.info("Workbench launched on the host with process id: " + str(self._process_id)) |
There was a problem hiding this comment.
| logging.info("Workbench launched on the host with process id: " + str(self._process_id)) | |
| logging.info("Workbench launched on the host with process ID: " + str(self._process_id)) |
| if not port or int(port) <= 0: | ||
| logging.error("Failed to retrieve the port used by Workbench service.") | ||
| return 0 | ||
| logging.info("Workbench service uses port " + port) |
There was a problem hiding this comment.
Concluding period or add a colon after port (and before + port)?
| if value: | ||
| value = value.decode("utf-8") | ||
| else: | ||
| raise Exception("unexpected code path") |
There was a problem hiding this comment.
| raise Exception("unexpected code path") | |
| raise Exception("Code path is unexpected.") |
| pass | ||
|
|
||
| """ | ||
| # terminate related processes bottom-up |
There was a problem hiding this comment.
| # terminate related processes bottom-up | |
| # terminate related processes from the bottom up |
PipKat
left a comment
There was a problem hiding this comment.
Performed doc review, leaving some minor comments.
| raise Exception("Ansys installation is not found.") | ||
|
|
||
| args = [] | ||
| if platform.system() == "Windows": |
There was a problem hiding this comment.
I think we should abstract the host machine to get rid of such if/else conditions, and self._wmi checks.
Probably, having three classes: Local Windows, Local Linux, and Remote Windows.
| command_line = " ".join(args) | ||
|
|
||
| successful = False | ||
| if self._wmi: |
There was a problem hiding this comment.
code can be simpler via host machine abstraction
| self._process_id = -1 | ||
| self._process = None | ||
|
|
||
| def __collect_process_tree(self): |
There was a problem hiding this comment.
This is a Windows only method. Abstracting the host machine will move it to the appropriate class.
| or version[2] not in ["1", "2"] | ||
| ): | ||
| raise Exception("Invalid ANSYS version: " + version) | ||
| raise Exception("Invalid Ansys version: " + version) |
There was a problem hiding this comment.
This version validation logic does not enforce the version to be >= 242
| ): | ||
| raise Exception("Invalid ANSYS version: " + version) | ||
|
|
||
| if host and not self._wmi: |
There was a problem hiding this comment.
The parameter description does not clearly state that. Users may make such mistake since using "localhost" or "127.0.0.1" is a common practice to specify the local machine.
| ): | ||
| raise Exception("Invalid ANSYS version: " + version) | ||
|
|
||
| if host and not self._wmi: |
There was a problem hiding this comment.
we could include the host value in the error message for easier troubleshooting.
| p.Terminate() | ||
| except Exception: | ||
| pass | ||
| """ |
There was a problem hiding this comment.
also the unused method __collect_process_tree should be removed
No description provided.