3 go @sdZddddgZddlZddlZddlZddlmZddlmZdd lm Z dd l m Z dd lm Z dd l mZGd ddejZeddZeddZddZdS)z>This module contains decorators for use with and without D-BusFirewallDBusExceptionhandle_exceptionsdbus_handle_exceptionsdbus_service_methodN) DBusException) decorator)config) FirewallError)errors)logc@seZdZdZdejjZdS)rz %s.ExceptionN)__name__ __module__ __qualname____doc__rdbusZDBUS_INTERFACEZ_dbus_error_namerr /usr/lib/python3.6/decorators.pyr+scOsdy |||Stk rD}ztjtjtj|WYdd}~Xntk r^tjYnXdS)zTDecorator to handle exceptions and log them. Used if not conneced to D-Bus. N)r r debug1 traceback format_excerror Exception exception)funcargskwargsrrrrr/s cOsy |||Stk r}zdtjt|}|tjtjtjtjgkrRtj t|ntj t j tj t|tt|WYdd}~XnZtk r}z |WYdd}~Xn6tk r}ztjtt|WYdd}~XnXdS)zDecorator to handle exceptions, log and report them into D-Bus :Raises DBusException: on a firewall error code problems. N)r get_codestrr ZALREADY_ENABLEDZ NOT_ENABLEDZZONE_ALREADY_SETZ ALREADY_SETr Zwarningrrrrrrrr)rrrrcodeZexrrrr<s  cOs|jddtjj||S)zAdd sender argument for D-BusZsender_keywordZsender) setdefaultrZservicemethod)rrrrrrTs )r__all__rZ dbus.servicerZdbus.exceptionsrrZfirewallrZfirewall.errorsr r Zfirewall.core.loggerr rrrrrrrrs