summaryrefslogtreecommitdiff
diff options
authorSylvain Pineau <sylvain.pineau@canonical.com>2022-03-31 18:13:50 +0200
committerSylvain Pineau <sylvain.pineau@canonical.com>2022-04-11 21:39:06 +0200
commitbe29f61bfade513afe9dea18e1a3749ec19f0525 (patch)
treefd128ac8580d83f0383609f0b6a44ef51c8c57e3
parent55b00cb28b74a6d3e35631af3103ba5a849797b0 (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-xbin/pm_test.py21
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):
"""