mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-07 03:48:06 +02:00
main: Return return code from launched executable
Using powerprofilesctl to launch an app would always result in what was detected as success, because the code wasn't propagating the retval from the launched application.
This commit is contained in:
parent
53fb59a2b9
commit
c19bede0d7
1 changed files with 6 additions and 1 deletions
|
|
@ -170,6 +170,7 @@ def _list_holds():
|
|||
index += 1
|
||||
|
||||
def _launch(args, profile, appid, reason):
|
||||
ret = 0
|
||||
try:
|
||||
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
||||
proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
|
||||
|
|
@ -189,8 +190,11 @@ def _launch(args, profile, appid, reason):
|
|||
# print (f'Got {cookie} for {profile} hold')
|
||||
with subprocess.Popen(args) as launched_app:
|
||||
launched_app.wait()
|
||||
ret = launched_app.returncode
|
||||
proxy.ReleaseProfile('(u)', cookie)
|
||||
|
||||
return ret
|
||||
|
||||
def main(): # pylint: disable=too-many-branches, disable=too-many-statements
|
||||
args = None
|
||||
if len(sys.argv) == 1:
|
||||
|
|
@ -277,7 +281,8 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements
|
|||
if not profile:
|
||||
profile = 'performance'
|
||||
try:
|
||||
_launch(args, profile, appid, reason)
|
||||
ret = _launch(args, profile, appid, reason)
|
||||
sys.exit(ret)
|
||||
except GLib.Error as error:
|
||||
sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
sys.exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue