lutris-wrapper: setproctitle to game name

Makes it slightly easier to identify what game a particular
lutris-wrapper instance is responsible for.
This commit is contained in:
Aaron Opfer 2019-12-27 12:16:43 -05:00 committed by Mathieu Comandon
parent c21d71c444
commit d394a1750f
8 changed files with 20 additions and 4 deletions

View file

@ -18,7 +18,7 @@ before_install:
install:
- pip install --upgrade pip pypresence~=3.3.2
- sudo apt-get -qq update
- sudo apt-get install -y python3-yaml python3-gi python3-pil gir1.2-gtk-3.0 psmisc gir1.2-glib-2.0 libgirepository1.0-dev gir1.2-gnomedesktop-3.0 gir1.2-webkit2-4.0 gir1.2-notify-0.7
- sudo apt-get install -y python3-yaml python3-gi python3-pil python3-setproctitle gir1.2-gtk-3.0 psmisc gir1.2-glib-2.0 libgirepository1.0-dev gir1.2-gnomedesktop-3.0 gir1.2-webkit2-4.0 gir1.2-notify-0.7
script: nosetests
# Cache the pip dependencies

View file

@ -14,6 +14,7 @@ be installed:
* python3-requests
* python3-pillow
* python3-yaml
* python3-setproctitle
* python3-evdev (optional, for controller detection)
These dependencies are only for running the Lutris client. To install and run
@ -36,7 +37,8 @@ To install all those dependencies on Ubuntu based systems, you can run::
sudo apt install python3-yaml python3-requests python3-pil python3-gi \
gir1.2-gtk-3.0 gir1.2-gnomedesktop-3.0 gir1.2-webkit2-4.0 \
gir1.2-notify-0.7 psmisc cabextract unzip p7zip curl fluid-soundfont-gs \
x11-xserver-utils python3-evdev libc6-i386 lib32gcc1 libgirepository1.0-dev
x11-xserver-utils python3-evdev libc6-i386 lib32gcc1 libgirepository1.0-dev \
python3-setproctitle
Note :
If you use OpenSUSE, some dependencies are missing. You need to install python3-gobject-Gdk and typelib-1_0-Gtk-3_0

View file

@ -9,6 +9,11 @@ from ctypes.util import find_library
from lutris.util.monitor import ProcessMonitor
from lutris.util.log import logger
try:
from setproctitle import setproctitle
except ImportError:
setproctitle = print
PR_SET_CHILD_SUBREAPER = 36
@ -62,7 +67,9 @@ def log(line):
def main():
"""Runs a command independently from the Lutris client"""
set_child_subreaper()
_, include_proc_count, exclude_proc_count, *args = sys.argv
_, proc_title, include_proc_count, exclude_proc_count, *args = sys.argv
setproctitle("lutris-wrapper: " + proc_title)
# So I'm too lazy to implement real argument parsing... sorry.
include_proc_count = int(include_proc_count)

1
debian/control vendored
View file

@ -30,6 +30,7 @@ Depends: ${misc:Depends},
python3-requests,
python3-pil,
python3-gi,
python3-setproctitle,
gir1.2-gtk-3.0,
gir1.2-gnomedesktop-3.0,
gir1.2-webkit2-4.0,

View file

@ -34,6 +34,7 @@ class MonitoredCommand:
include_processes=None,
exclude_processes=None,
log_buffer=None,
title=None,
): # pylint: disable=too-many-arguments
self.ready_state = True
self.env = self.get_environment(env)
@ -60,6 +61,8 @@ class MonitoredCommand:
self._stdout = io.StringIO()
self._title = title if title else command
@property
def stdout(self):
return self._stdout.getvalue()
@ -70,6 +73,7 @@ class MonitoredCommand:
return [
WRAPPER_SCRIPT,
self._title,
str(len(self.include_processes)),
str(len(self.exclude_processes)),
] + self.include_processes + self.exclude_processes + self.command

View file

@ -562,6 +562,7 @@ class Game(GObject.Object):
"""Run a background command to lauch the game"""
self.game_thread = MonitoredCommand(
self.game_runtime_config["args"],
title=self.name,
runner=self.runner,
env=self.game_runtime_config["env"],
term=self.game_runtime_config["terminal"],

View file

@ -86,7 +86,7 @@ parts:
lutris-runtime:
plugin: nil
stage-packages: [python3, python3-yaml, python3-requests, python3-pil, python3-gi, dh-python, curl, cabextract, psmisc, gvfs-backends, unzip, p7zip, mesa-utils, fluid-soundfont-gs, libgnutls30, x11-xserver-utils, on amd64: ['libxrandr-dev:i386', 'libgnutls30:i386', 'x11-xserver-utils:i386', 'libc6-i386', 'lib32gcc1'] ]
stage-packages: [python3, python3-setproctitle, python3-yaml, python3-requests, python3-pil, python3-gi, dh-python, curl, cabextract, psmisc, gvfs-backends, unzip, p7zip, mesa-utils, fluid-soundfont-gs, libgnutls30, x11-xserver-utils, on amd64: ['libxrandr-dev:i386', 'libgnutls30:i386', 'x11-xserver-utils:i386', 'libc6-i386', 'lib32gcc1'] ]
stage: [-lib/ld-linux.so.2, -usr/bin/cpp-7, -usr/share/doc/cpp/README.Debian, -usr/share/man/man1/cpp-7.1.gz]
after: [enable-i386]

View file

@ -23,6 +23,7 @@ class LutrisWrapperTestCase(unittest.TestCase):
[
sys.executable,
lutris_wrapper_bin,
'title',
'0',
'0',
'bash',