관리-도구
편집 파일: dbus_exporter.cpython-39.opt-1.pyc
a ����,�g�����������������������@���s���d�dl�mZ�ddlZddlZddlZddlZddlZddlZ ddl mZ�ddlZddl Z ddlmZ�ddlmZ�ddlmZ�ddlmZ�ddlmZ�dd lmZ�zdd lmZ�dd��ZW�n�ey����dd lmZ�Y�n0�e j���Zdd��ZG�dd��dej �Z!dS�)����)� interfaces�����N)�ismethod)�polkit)�GLib)�FunctionType)� DBusException)�ErrorMessage��getfullargspecc�����������������C���s���t�|��S��Nr ���)�func��r����?/usr/lib/python3.9/site-packages/tuned/exports/dbus_exporter.py� getargspec���s����r���)r���c�����������������C���s����t�|dd��}|d�urn0t�|dd�dv�r4d|jj�}nd|j|jjf�}t|t�rZ|���}nd�t� |j|��}t |||�}|���s�|��|��d�S�)NZ_dbus_error_name� __module__��)r����__main__zorg.freedesktop.DBus.Python.%sz!org.freedesktop.DBus.Python.%s.%s) �getattr� __class__�__name__r���� isinstancer���Zget_dbus_message�join� traceback�format_exception_onlyr ���Zget_no_replyZsend_message)Z connection�message� exception�name�contentsZreplyr���r���r����_method_reply_error$���s���� �r���c�������������������@���s����e�Zd�ZdZdd��Zedd���Zedd���Zedd ���Zd d��Z dd ��Z dd��Zddd�Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��ZdS�) �DBusExportera+�� Export method calls through DBus Interface. We take a method to be exported and create a simple wrapper function to call it. This is required as we need the original function to be bound to the original object instance. While the wrapper will be bound to an object we dynamically construct. c�����������������C���s����t����tjkrttj_tjjj dd��d�|�_ d�|�_i�|�_t ��|�_||�_||�_||�_||�_d�|�_d�|�_t��|�_t�tj�}t���|�_t�tj|��d�S�)NT)Zset_as_default)�logZgetEffectiveLevel�logging�DEBUGr����dbus�serviceZmainloopZglibZ DBusGMainLoop�_dbus_object_clsZ_dbus_object� _dbus_methods�set�_signals� _bus_name�_interface_name�_object_name� _namespace�_thread�_bus_objectr����_polkit�signal� getsignal�SIGINTr���ZMainLoop� _main_loop)�self�bus_name�interface_name�object_name� namespaceZsignal_handlerr���r���r����__init__B���s"���� zDBusExporter.__init__c�����������������C���s���|�j�S�r���)r*����r5���r���r���r���r6���`���s����zDBusExporter.bus_namec�����������������C���s���|�j�S�r���)r+���r;���r���r���r���r7���d���s����zDBusExporter.interface_namec�����������������C���s���|�j�S�r���)r,���r;���r���r���r���r8���h���s����zDBusExporter.object_namec�����������������C���s ���|�j�d�uS�r���)r.���r;���r���r���r����runningl���s����zDBusExporter.runningc�����������������C���sN���dj�|jd�t|j�j�d�}t|dt|�j��d�}t |j d�t��|j�}|S�)Nz2def {name}({args}): return wrapper({args}) z, )r����argsz<decorator-gen-%d>�execr���)�formatr���r���r����__func__r=����compile�lenr'���r���� co_consts�locals)r5����method�wrapper�source�coder ���r���r���r����_prepare_for_dbuso���s�����zDBusExporter._prepare_for_dbusc�����������������G���s��|�j�d�|�}|d�}t�d||f���|�j�||�}|}|dkrVt�d||f���n�|dkrrt�d||f���n�|dkr�t�d ||f���t|d�d���d g�}nZ|dkr�t�d||f���t|d�d���d g�}n(t�d||f���t|d�d���d g�}|S�) N�.���z?checking authorization for action '%s' requested by caller '%s'r���zJaction '%s' requested by caller '%s' was successfully authorized by polkit����zepolkit error, but action '%s' requested by caller '%s' was successfully authorized by fallback methodr���zLaction '%s' requested by caller '%s' wasn't authorized, ignoring the requestr���zppolkit error and action '%s' requested by caller '%s' wasn't authorized by fallback method, ignoring the requestzvpolkit error and unable to use fallback method to authorize action '%s' requested by caller '%s', ignoring the request) r-���r!����debugr0���Zcheck_authorizationZwarning�info�list�error)r5����action_namer=���Z action_id�caller�retZ args_copyr���r���r����_polkit_auth}���s$����zDBusExporter._polkit_authNc��������������������st���t���std���j}|�jv�r(td����p.|������fdd�}���|�}tjj�j||dd�|�}|�j|<�d�S�)N�#Only bound methods can be exported.�*Method with this name is already exported.c��������������������s�����j���g|�R���i�|��S�r���)rT�����ownerr=����kwargs�rQ���rE���r5���r���r����auth_wrapper����s����z)DBusExporter.export.<locals>.auth_wrapperrR���)Zsender_keyword) r���� Exceptionr���r'���rI���r$���r%���rE���r+���)r5���rE���Zin_signature� out_signaturerQ����method_namer[���rF���r���rZ���r����export����s���� zDBusExporter.exportc��������������������sn���t����std����j}||�jv�r(td����fdd�}|����|�}tj�|�j|�|�}||�j|<�|�j � |��d�S�)NrU���rV���c��������������������s�����|i�|��S�r���r���rW����rE���r���r���rF�������s����z$DBusExporter.signal.<locals>.wrapper)r���r\���r���r'���rI���r$���r%���r1���r+���r)����add)r5���rE���r]���r^���rF���r���r`���r���r1�������s���� zDBusExporter.signalc�����������������O���sh���d}||�j�vs|�jd�u�rd}zt|�j|�}W�n�tyB���d}Y�n0�|rVtd|���n||i�|���d�S�)NFTzSignal '%s' doesn't exist.)r)���r/���r����AttributeErrorr\���)r5���r1���r=���rY����errrE���r���r���r����send_signal����s���� zDBusExporter.send_signalc�����������������C���s<���|�j�d�urtd��dt|���}t|tjjf|�j�}||�_�d�S�)Nz%The exporter class was already build.zDBusExporter_%d)r&���r\����id�typer$���r%���ZObjectr'���)r5���Zunique_name�clsr���r���r����_construct_dbus_object_class����s ���� z)DBusExporter._construct_dbus_object_classc�����������������C���sn���|�����rd�S�|�jd�u�r|�����|�����t���}tj�|�j|�}|��||�j |�|�_ tj|�j d�|�_|�j����d�S�)N)�target)r<���r&���rh����stopr$���Z SystemBusr%���ZBusNamer*���r,���r/���� threading�Thread�_thread_coder.����start)r5���Zbusr6���r���r���r���rn�������s���� zDBusExporter.startc�����������������C���s2���|�j�d�ur.|�j����r.|�j����|�j�����d�|�_�d�S�r���)r.����is_aliver4����quitr���r;���r���r���r���rj�������s���� zDBusExporter.stopc�����������������C���s���|�j�����|�`d�|�_d�S�r���)r4����runr/���r;���r���r���r���rm�������s���� zDBusExporter._thread_code)N)r���r����__qualname__�__doc__r:����propertyr6���r7���r8���r<���rI���rT���r_���r1���rd���rh���rn���rj���rm���r���r���r���r���r ���8���s$��� r ���)"r���r���Zdbus.servicer$���Zdbus.mainloop.glibZdbus.exceptionsrk���r1���Z tuned.logsZtunedZtuned.constsZconstsr���r"����inspectr���Ztuned.utils.polkitr���Z gi.repositoryr����typesr���r���Z dbus.lowlevelr ���r���r����ImportErrorZlogs�getr!���r���ZExporterInterfacer ���r���r���r���r����<module>���s.���