dbus_manager: clarify warnings
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
6065e9a0fe
commit
b6fc692500
|
@ -21,6 +21,11 @@ from typing import (
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from confighelper import ConfigHelper
|
from confighelper import ConfigHelper
|
||||||
|
|
||||||
|
DOC_URL = (
|
||||||
|
"https://moonraker.readthedocs.io/en/latest/"
|
||||||
|
"installation/#policykit-permissions"
|
||||||
|
)
|
||||||
|
|
||||||
class DbusManager:
|
class DbusManager:
|
||||||
Variant = dbus_next.Variant
|
Variant = dbus_next.Variant
|
||||||
DbusError = dbus_next.errors.DBusError
|
DbusError = dbus_next.errors.DBusError
|
||||||
|
@ -57,7 +62,8 @@ class DbusManager:
|
||||||
"org.freedesktop.PolicyKit1.Authority")
|
"org.freedesktop.PolicyKit1.Authority")
|
||||||
except self.DbusError:
|
except self.DbusError:
|
||||||
self.server.add_warning(
|
self.server.add_warning(
|
||||||
"Unable to find DBus PolicyKit Interface")
|
"Unable to find DBus PolKit Interface, this suggests PolKit "
|
||||||
|
"is not installed on your OS.")
|
||||||
|
|
||||||
async def check_permission(self,
|
async def check_permission(self,
|
||||||
action: str,
|
action: str,
|
||||||
|
@ -69,24 +75,26 @@ class DbusManager:
|
||||||
ret = await self.polkit.call_check_authorization( # type: ignore
|
ret = await self.polkit.call_check_authorization( # type: ignore
|
||||||
self.polkit_subject, action, {}, 0, "")
|
self.polkit_subject, action, {}, 0, "")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
self._check_warned()
|
||||||
self.server.add_warning(
|
self.server.add_warning(
|
||||||
f"Error checking authorization for action [{action}]: {e}"
|
f"Error checking authorization for action [{action}]: {e}. "
|
||||||
", This may indicate that PolicyKit is not installed, "
|
"This suggests that a dependency is not installed or "
|
||||||
f"{err_msg}")
|
f"up to date. {err_msg}.")
|
||||||
return False
|
return False
|
||||||
if not ret[0]:
|
if not ret[0]:
|
||||||
if not self.warned:
|
self._check_warned()
|
||||||
self.server.add_warning(
|
|
||||||
"Missing PolicyKit permisions detected. See the "
|
|
||||||
"PolicyKit Permissions section of the install "
|
|
||||||
"documentation at https://moonraker.readthedocs.io/ "
|
|
||||||
"for details.")
|
|
||||||
self.warned = True
|
|
||||||
self.server.add_warning(
|
self.server.add_warning(
|
||||||
"Moonraker not authorized for PolicyKit action: "
|
"Moonraker not authorized for PolicyKit action: "
|
||||||
f"[{action}], {err_msg}")
|
f"[{action}], {err_msg}")
|
||||||
return ret[0]
|
return ret[0]
|
||||||
|
|
||||||
|
def _check_warned(self):
|
||||||
|
if not self.warned:
|
||||||
|
self.server.add_warning(
|
||||||
|
f"PolKit warnings detected. See {DOC_URL} for instructions "
|
||||||
|
"on how to resolve.")
|
||||||
|
self.warned = True
|
||||||
|
|
||||||
async def get_interface(self,
|
async def get_interface(self,
|
||||||
bus_name: str,
|
bus_name: str,
|
||||||
bus_path: str,
|
bus_path: str,
|
||||||
|
|
Loading…
Reference in New Issue