Attach to a running application on Linux/MacOs

Feature suggestion

Add the ability to attach to a running application on Linux/MacOS.

Intended use

Same behaviour like on Windows where Qat can be attached to a running application using app_launcher.attach_to

Original post (Bug)

Details

Description of Issue

Unable to attach Qat to an already running application

Affected version(s)

all Linux versions up to 1.1.2.

MacOs versions are potentially impacted as well (not tested).

System information

  • OS: Linux
  • Kernel Version: 6.9.3-76060903-generic
  • OS version: Pop!_OS 22.04 LTS (64 bit)
  • Qt version: 6.2
  • Python version: 3.10.12

Steps to reproduce

  1. Manually launch QmlApp
  2. Run the following code :
import qat
qat.attach_to_application("QmlApp")
  1. Qat exits with a ProcessLookupError exception

What is the current issue behavior?

The file containing the application port is not created because Qat server is not injected

What is the expected expected behavior?

Qat is able to attach to a running application on Linux

Relevant logs and/or screenshots

>>> import qat
>>> qat.attach_to_application("QmlApp")
Could not load testSettings.json, using default values.
Error reading pid file [Errno 2] No such file or directory: '/tmp/qat-90376.txt'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/qat_user/.local/lib/python3.10/site-packages/qat/qat.py", line 177, in attach_to_application
    get_state().current_app_context = app_launcher.attach_to(name_or_pid)
  File "/home/qat_user/.local/lib/python3.10/site-packages/qat/internal/app_launcher.py", line 232, in attach_to
    connect_to(context)
  File "/home/qat_user/.local/lib/python3.10/site-packages/qat/internal/app_launcher.py", line 150, in connect_to
    raise ProcessLookupError(
ProcessLookupError: Could not retrieve server port number. Cannot establish communication with application.

Possible fixes

Find a way to inject the Qat server shared library and inject it in app_launcher.attach_to.

See comment #24 (comment 2079197276)

Edited by Kevin DA SILVA