From be29f61bfade513afe9dea18e1a3749ec19f0525 Mon Sep 17 00:00:00 2001 From: Sylvain Pineau Date: Thu, 31 Mar 2022 18:13:50 +0200 Subject: bin:pm_test.py: Always execute the respawn commands x-terminal-emulator (and dbus-launch) are not supported w/ Wayland This patch ensures the checkbox systemd service is always restarted. Fixes: lp:1967032 --- bin/pm_test.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/pm_test.py b/bin/pm_test.py index 45f52ec..92a5863 100755 --- a/bin/pm_test.py +++ b/bin/pm_test.py @@ -286,12 +286,21 @@ class PowerManagementOperation(): title = '{0} test'.format(self.args.pm_operation.capitalize()) MessageDialog(title, message).run() if self.args.checkbox_respawn_cmd: - subprocess.run( - r'unset LD_LIBRARY_PATH;' - r'unset PYTHONPATH; unset PYTHONHOME;' - r'DISPLAY=:0 x-terminal-emulator -e "sudo -u ' - r'{} bash -c \"source {}; exec bash\""'.format( - self.user, self.args.checkbox_respawn_cmd), shell=True) + try: + subprocess.run( + r'unset LD_LIBRARY_PATH;' + r'unset PYTHONPATH; unset PYTHONHOME;' + r'DISPLAY=:0 x-terminal-emulator -e "sudo -u ' + r'{} bash -c \"source {}; exec bash\""'.format( + self.user, self.args.checkbox_respawn_cmd), + shell=True, + check=True) + # x-terminal-emulator command does not work on Wayland + # Run the checkbox_respawn_cmd via subprocess.run instead + except subprocess.CalledProcessError: + with open(self.args.checkbox_respawn_cmd, 'rt') as f: + for l in f: + subprocess.run(l, shell=True) def teardown(self): """ -- cgit v1.2.3