3 YÉjo ã @ s¦ d Z ddddgZddlZddlZddlZddlmZ ddlmZ dd lm Z dd l mZ ddlmZ ddl mZ G d 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 @ s e Zd Zd Zdejj ZdS )r z%s.ExceptionN)Ú__name__Ú __module__Ú__qualname__Ú__doc__r ÚdbusZDBUS_INTERFACEZ_dbus_error_name© r r ú /usr/lib/python3.6/decorators.pyr + s c O sd y | ||ŽS t k rD } ztjtjƒ ƒ tj|ƒ W Y dd}~X n tk r^ tjƒ Y nX dS )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Úkwargsr r r r r / s c O sè y | ||ŽS t k rŠ } zdt jt|ƒƒ}|tjtjtjtjgkrRtj t|ƒƒ ntj tjƒ ƒ tj t|ƒƒ tt|ƒƒ‚W Y dd}~X nZ tk r® } z |‚W Y dd}~X n6 tk râ } ztjƒ tt|ƒƒ‚W Y dd}~X nX dS )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_ENABLEDZNOT_ENABLEDZZONE_ALREADY_SETZALREADY_SETr Zwarningr r r r r r r r )r r r r ÚcodeZexr r r r <