forked from pool/power-profiles-daemon
Accepting request 932771 from Base:System
OBS-URL: https://build.opensuse.org/request/show/932771 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/power-profiles-daemon?expand=0&rev=3
This commit is contained in:
commit
014685c5d0
146
fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch
Normal file
146
fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch
Normal file
@ -0,0 +1,146 @@
|
||||
From fd1664dfe26f13f8c8cd7b44483cd872dfdede36 Mon Sep 17 00:00:00 2001
|
||||
From: Bastien Nocera <hadess@hadess.net>
|
||||
Date: Mon, 8 Nov 2021 15:39:07 +0100
|
||||
Subject: [PATCH] main: Error out on D-Bus communication errors
|
||||
|
||||
The bug reporting tool in Fedora, in its infinite wisdom, considers
|
||||
innocuous exceptions that occur when system daemons aren't running
|
||||
to be bug report worthy.
|
||||
|
||||
Catch all the D-Bus communication errors, print an error message
|
||||
detailing the problem and exit with a return value of 1 when they occur
|
||||
instead of printing an exception.
|
||||
|
||||
See:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=2019536
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=2020251
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=2020941
|
||||
---
|
||||
meson.build | 2 +-
|
||||
src/powerprofilesctl.in | 44 +++++++++++++++++++++++++++++------------
|
||||
2 files changed, 32 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index d7b5a8c..84e67c6 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -44,7 +44,7 @@ add_global_arguments(common_cflags, language: 'c')
|
||||
|
||||
if get_option('pylint')
|
||||
pylint = find_program('pylint-3', 'pylint3', 'pylint', required: true)
|
||||
- pylint_flags = ['-d', 'C0116', '-d', 'C0114', '-d', 'W0707']
|
||||
+ pylint_flags = ['-d', 'C0116', '-d', 'C0114', '-d', 'W0707', '-d', 'W0706' ]
|
||||
endif
|
||||
xmllint = find_program('xmllint', required: false)
|
||||
|
||||
diff --git a/src/powerprofilesctl.in b/src/powerprofilesctl.in
|
||||
index 9b5e201..1461e3a 100755
|
||||
--- a/src/powerprofilesctl.in
|
||||
+++ b/src/powerprofilesctl.in
|
||||
@@ -98,7 +98,7 @@ def get_proxy():
|
||||
'/net/hadess/PowerProfiles',
|
||||
'org.freedesktop.DBus.Properties', None)
|
||||
except:
|
||||
- raise SystemError
|
||||
+ raise
|
||||
return proxy
|
||||
|
||||
def _get():
|
||||
@@ -117,13 +117,13 @@ def get_profiles_property(prop):
|
||||
try:
|
||||
proxy = get_proxy()
|
||||
except:
|
||||
- raise SystemError
|
||||
+ raise
|
||||
|
||||
profiles = None
|
||||
try:
|
||||
profiles = proxy.Get('(ss)', 'net.hadess.PowerProfiles', prop)
|
||||
except:
|
||||
- raise ReferenceError
|
||||
+ raise
|
||||
else:
|
||||
return profiles
|
||||
|
||||
@@ -134,8 +134,7 @@ def _list():
|
||||
degraded = (reason != '')
|
||||
active = get_proxy().Get('(ss)', 'net.hadess.PowerProfiles', 'ActiveProfile')
|
||||
except:
|
||||
- print("Couldn\'t get Profiles: ", sys.exc_info()[0])
|
||||
- raise SystemError
|
||||
+ raise
|
||||
else:
|
||||
index = 0
|
||||
for profile in reversed(profiles):
|
||||
@@ -152,8 +151,7 @@ def _list_holds():
|
||||
try:
|
||||
holds = get_profiles_property('ActiveProfileHolds')
|
||||
except:
|
||||
- # print("Couldn\'t get ActiveProfileHolds: ", sys.exc_info()[0])
|
||||
- raise SystemError
|
||||
+ raise
|
||||
else:
|
||||
index = 0
|
||||
for hold in holds:
|
||||
@@ -173,7 +171,7 @@ def _launch(args, profile, appid, reason):
|
||||
'/net/hadess/PowerProfiles',
|
||||
'net.hadess.PowerProfiles', None)
|
||||
except:
|
||||
- raise SystemError
|
||||
+ raise
|
||||
|
||||
cookie = proxy.HoldProfile('(sss)', profile, reason, appid)
|
||||
|
||||
@@ -208,16 +206,32 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements
|
||||
elif command == 'version':
|
||||
version()
|
||||
elif command == 'get':
|
||||
- _get()
|
||||
+ try:
|
||||
+ _get()
|
||||
+ except GLib.Error as error:
|
||||
+ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
+ sys.exit(1)
|
||||
elif command == 'set':
|
||||
if len(args) != 1:
|
||||
usage_set()
|
||||
sys.exit(1)
|
||||
- _set(args[0])
|
||||
+ try:
|
||||
+ _set(args[0])
|
||||
+ except GLib.Error as error:
|
||||
+ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
+ sys.exit(1)
|
||||
elif command == 'list':
|
||||
- _list()
|
||||
+ try:
|
||||
+ _list()
|
||||
+ except GLib.Error as error:
|
||||
+ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
+ sys.exit(1)
|
||||
elif command == 'list-holds':
|
||||
- _list_holds()
|
||||
+ try:
|
||||
+ _list_holds()
|
||||
+ except GLib.Error as error:
|
||||
+ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
+ sys.exit(1)
|
||||
elif command == 'launch':
|
||||
if len(args) == 0:
|
||||
sys.exit(0)
|
||||
@@ -256,7 +270,11 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements
|
||||
reason = 'Running ' + appid
|
||||
if not profile:
|
||||
profile = 'performance'
|
||||
- _launch(args, profile, appid, reason)
|
||||
+ try:
|
||||
+ _launch(args, profile, appid, reason)
|
||||
+ except GLib.Error as error:
|
||||
+ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n')
|
||||
+ sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
--
|
||||
GitLab
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 19 15:29:11 UTC 2021 - Bjørn Lie <bjorn.lie@gmail.com>
|
||||
|
||||
- Add fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch: main: Error
|
||||
out on D-Bus communication errors (rh#2019536).
|
||||
- Bump pkgconfig(polkit-gobject-1) BuildRequires version to 0.114.
|
||||
It's required for the g_autoptr() support we use.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 5 18:35:24 UTC 2021 - Atri Bhattacharya <badshah400@gmail.com>
|
||||
|
||||
|
@ -25,6 +25,8 @@ URL: https://gitlab.freedesktop.org/hadess/power-profiles-daemon
|
||||
Source: %{url}/-/archive/%{version}/%{name}-%{version}.tar.bz2
|
||||
# PATCH-FEATURE-OPENSUSE hold-profile-hardening.patch boo#1189900 -- Hardening of HoldProfile D-Bus method
|
||||
Patch0: hold-profile-hardening.patch
|
||||
# PATCH-FIX-UPSTREAM fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch -- main: Error out on D-Bus communication errors
|
||||
Patch1: https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch
|
||||
|
||||
BuildRequires: c_compiler
|
||||
BuildRequires: gtk-doc
|
||||
@ -33,7 +35,7 @@ BuildRequires: pkgconfig
|
||||
BuildRequires: python3-dbusmock
|
||||
BuildRequires: pkgconfig(gio-2.0)
|
||||
BuildRequires: pkgconfig(gudev-1.0)
|
||||
BuildRequires: pkgconfig(polkit-gobject-1)
|
||||
BuildRequires: pkgconfig(polkit-gobject-1) >= 0.114
|
||||
BuildRequires: pkgconfig(systemd)
|
||||
BuildRequires: pkgconfig(udev)
|
||||
BuildRequires: pkgconfig(umockdev-1.0)
|
||||
|
Loading…
Reference in New Issue
Block a user