1
0
Dominique Leuenberger 2022-05-02 14:25:37 +00:00 committed by Git OBS Bridge
commit 70791ba8d2
6 changed files with 24 additions and 158 deletions

View File

@ -1,146 +0,0 @@
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

View File

@ -1,8 +1,8 @@
Index: power-profiles-daemon-0.10.1/src/power-profiles-daemon.c
Index: power-profiles-daemon-0.11/src/power-profiles-daemon.c
===================================================================
--- power-profiles-daemon-0.10.1.orig/src/power-profiles-daemon.c
+++ power-profiles-daemon-0.10.1/src/power-profiles-daemon.c
@@ -531,6 +531,29 @@ holder_disappeared (GDBusConnection *con
--- power-profiles-daemon-0.11.orig/src/power-profiles-daemon.c
+++ power-profiles-daemon-0.11/src/power-profiles-daemon.c
@@ -537,6 +537,29 @@ holder_disappeared (GDBusConnection *con
g_ptr_array_free (cookies, TRUE);
}
@ -32,7 +32,7 @@ Index: power-profiles-daemon-0.10.1/src/power-profiles-daemon.c
static void
hold_profile (PpdApp *data,
GVariant *parameters,
@@ -553,6 +576,18 @@ hold_profile (PpdApp *dat
@@ -559,6 +582,18 @@ hold_profile (PpdApp *dat
return;
}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fffaf7cd11ab305497fb8842fc2497caf92a3f260ba9272159b0612820f1399c
size 44125

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:244e1b2031a64311ca4a3e04a9f057f3d9cd5ba40d2cbf8d1e253b4b49efd148
size 46057

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Sun May 1 17:32:18 UTC 2022 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 0.11:
* Fixes problems on Intel machines when the CPUs didn't support
turbo at all, or the performance scaling governor was built as
default in the kernel.
* Add better end-user documentation.
* Fixes in the command-line tool to not cause bug report tools
to popup on not-uncommon errors.
* Bug fix for running on some systems with controllable charge
speeds.
- Drop fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch: upstreamed.
-------------------------------------------------------------------
Fri Nov 19 15:29:11 UTC 2021 - Bjørn Lie <bjorn.lie@gmail.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package power-profiles-daemon
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,7 +17,7 @@
Name: power-profiles-daemon
Version: 0.10.1
Version: 0.11
Release: 0
Summary: Power profiles handling over D-Bus
License: GPL-3.0-or-later
@ -25,8 +25,6 @@ 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