3 @)òfo ã@s¦dZddddgZddlZddlZddlZddlmZddlmZdd lm Z dd l m Z dd lm Z dd l mZGd d„dejƒZedd„ƒZedd„ƒZdd„ZdS)z>This module contains decorators for use with and without D-BusÚFirewallDBusExceptionÚhandle_exceptionsÚdbus_handle_exceptionsÚdbus_service_methodéN)Ú DBusException)Ú decorator)Úconfig)Ú FirewallError)Úerrors)Úlogc@seZdZdZdejjZdS)rz %s.ExceptionN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚdbusZDBUS_INTERFACEZ_dbus_error_name©rrú /usr/lib/python3.6/decorators.pyr+scOsdy |||ŽStk rD}ztjtjƒƒtj|ƒWYdd}~Xntk r^tjƒYnXdS)zTDecorator to handle exceptions and log them. Used if not conneced to D-Bus. N)r r Údebug1Ú tracebackÚ format_excÚerrorÚ ExceptionÚ exception)ÚfuncÚargsÚkwargsrrrrr/s cOsèy |||ŽStk rŠ}zdtjt|ƒƒ}|tjtjtjtjgkrRtj t|ƒƒntj t j ƒƒtj t|ƒƒtt|ƒƒ‚WYdd}~XnZtk r®}z |‚WYdd}~Xn6tk râ}ztjƒtt|ƒƒ‚WYdd}~XnXdS)z‚Decorator to handle exceptions, log and report them into D-Bus :Raises DBusException: on a firewall error code problems. N)r Úget_codeÚstrr ZALREADY_ENABLEDZ NOT_ENABLEDZZONE_ALREADY_SETZ ALREADY_SETr Zwarningrrrrrrrr)rrrrÚcodeZexrrrr<s  cOs|jddƒtjj||ŽS)zAdd sender argument for D-BusZsender_keywordZsender)Ú setdefaultrZserviceÚmethod)rrrrrrTs )rÚ__all__rZ dbus.servicerZdbus.exceptionsrrZfirewallrZfirewall.errorsr r Zfirewall.core.loggerr rrrrrrrrÚs