Skip to content

Implement file exists check for executable #104

@akaszynski

Description

@akaszynski

In https://github.com/pyansys/pydpf-core/blob/7d0c59796baac823702e38dcc0dcb74098844af0/ansys/dpf/core/server.py#L509 we don't check if the dpf server executable actually exists prior to running it. This appears to be version dependent and leads to a not so helpful traceback:

>>> model = Model(r'c:\static.rst')

Traceback (most recent call last):

  File "<pyshell#11>", line 1, in <module>

    model = Model(r'c:\static.rst')

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\site-packages\ansys\dpf\core\model.py", line 49, in __init__

    server = dpf.core._global_server()

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\site-packages\ansys\dpf\core\server.py", line 62, in _global_server

    start_local_server()

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\site-packages\ansys\dpf\core\server.py", line 177, in start_local_server

    server = DpfServer(ansys_path, ip, port,as_global= as_global, load_operators = load_operators)

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\site-packages\ansys\dpf\core\server.py", line 281, in __init__

    launch_dpf(ansys_path, ip, port)

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\site-packages\ansys\dpf\core\server.py", line 473, in launch_dpf

    process = subprocess.Popen(run_cmd,

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__

    self._execute_child(args, executable, preexec_fn, close_fds,

  File "C:\Users\<redacted-user>\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child

    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

FileNotFoundError: [WinError 2] The system cannot find the file specified

Would be great to implement a version and/or file exists check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions