Skip to content

Commit

Permalink
Added the possibility to launch aedt in ironpython server using relat…
Browse files Browse the repository at this point in the history
…ive. path
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Mar 24, 2022
1 parent 7903324 commit 9d02adb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions pyaedt/common_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def connect(server_name, aedt_client_port):
return "Error. No connection. Check if AEDT is running and if the port number is correct."


def client(server_name, server_port=18000, beta_options=None, use_aedt_local_path=False):
def client(server_name, server_port=18000, beta_options=None, use_aedt_relative_path=False):
"""Starts an rpyc client and connects to a remote machine.
Parameters
Expand All @@ -206,7 +206,7 @@ def client(server_name, server_port=18000, beta_options=None, use_aedt_local_pat
Port that the rpyc server is running on.
beta_options : list, optional
List of beta options to apply to the new service. The default is ``None``.
use_aedt_local_path : bool, optional
use_aedt_relative_path : bool, optional
Whether to use aedt executable full path or relative path call. Needed in case linux environment is defined.
Returns
-------
Expand Down Expand Up @@ -254,7 +254,7 @@ def client(server_name, server_port=18000, beta_options=None, use_aedt_local_pat
if not c:
print("Failing to connect to {} on port {}. Check the settings".format(server_name, server_port))
return False
port = c.root.start_service(server_name, beta_options, use_aedt_local_path=use_aedt_local_path)
port = c.root.start_service(server_name, beta_options, use_aedt_relative_path=use_aedt_relative_path)
if not port:
return "Error connecting to the server. Check the server name and port and retry."
print("Connecting to a new session of AEDT on port {}. Wait.".format(port))
Expand Down Expand Up @@ -364,7 +364,9 @@ def _download_dir(remotepath, localpath, server_name, server_port=18000):
_download_file(rfn, lfn, server_name, server_port=18000)


def launch_ironpython_server(aedt_path, non_graphical=False, port=18000, launch_client=True, use_aedt_local_path=False):
def launch_ironpython_server(
aedt_path, non_graphical=False, port=18000, launch_client=True, use_aedt_relative_path=False
):
"""Start a process in IronPython and launch the rpc server on the specified port given an AEDT path on Linux.
.. warning::
Expand All @@ -383,7 +385,7 @@ def launch_ironpython_server(aedt_path, non_graphical=False, port=18000, launch_
Port number. The default is ``18000``.
launch_client : bool, optional
Whether to launch the client. The default is ``True.``
use_aedt_local_path : bool, optional
use_aedt_relative_path : bool, optional
Whether to use aedt executable full path or relative path call. Needed in case linux environment is defined.
aedt_path parameter is still needed since it is necessary to retrieve ipy64.exe full path.
Expand Down Expand Up @@ -426,5 +428,5 @@ def launch_ironpython_server(aedt_path, non_graphical=False, port=18000, launch_
print("Known issues are in the returned list and dictionary.")
print("For these known issues, using the method client.convert_remote_object is recommended.")
if proc and launch_client:
return client(server_name=socket.getfqdn(), server_port=port1, use_aedt_local_path=use_aedt_local_path)
return client(server_name=socket.getfqdn(), server_port=port1, use_aedt_relative_path=use_aedt_relative_path)
return False
4 changes: 2 additions & 2 deletions pyaedt/rpc/rpyc_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def on_disconnect(self, connection):
# (to finalize the service, if needed)
pass

def exposed_start_service(self, hostname, beta_options=None, use_aedt_local_path=False):
def exposed_start_service(self, hostname, beta_options=None, use_aedt_relative_path=False):
"""Starts a new Pyaedt Service and start listen.
Returns
Expand Down Expand Up @@ -802,7 +802,7 @@ def exposed_start_service(self, hostname, beta_options=None, use_aedt_local_path
lines = f1.readlines()
for line in lines:
f.write(line)
if not use_aedt_local_path:
if not use_aedt_relative_path:
aedt_exe = os.path.join(ansysem_path, executable)
else:
aedt_exe = executable
Expand Down

0 comments on commit 9d02adb

Please sign in to comment.