diff options
author | Sylvain Pineau <sylvain.pineau@canonical.com> | 2022-03-31 18:13:50 +0200 |
---|---|---|
committer | Sylvain Pineau <sylvain.pineau@canonical.com> | 2022-03-31 18:24:31 +0200 |
commit | ece5bed9c23afae9741242803823bf8fe98bbb66 (patch) | |
tree | fd128ac8580d83f0383609f0b6a44ef51c8c57e3 | |
parent | f4a0e5c1ad690c983a5aa7ad025e9760e4121338 (diff) |
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
-rwxr-xr-x | bin/pm_test.py | 21 |
1 files 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): """ |