Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
):
""" Send notification to systemd daemon
:param return_exceptions: Return exception or raise it.
:param unset_environment: If the unset_environment parameter is non-zero,
notify() will unset the $NOTIFY_SOCKET environment variable
before returning (regardless of whether the function call itself
succeeded or not). Further calls to notify() will then fail,
but the variable is no longer inherited by child processes.
:param notification: Notification object
:param value: str or int value for non constant notifications
:returns None
"""
if not isinstance(notification, Notification):
raise TypeError("state must be an instance of Notification")
state = notification.value
if state.constant is not None and value:
raise ValueError(
"State %s should contain only constant value %r"
% (state.name, state.constant),
state.name,
state.constant,
)
line = "%s=%s" % (
state.name,
state.constant if state.constant is not None else state.type(value),
)