%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/aptdaemon/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/aptdaemon/__pycache__/core.cpython-312.pyc

�

��kdk���dZdZdZddlZddlmZddlZddlmZddl	Z	ddl
Z
ddlZ
ddlm
Z
ddlZddlZddlZddlZddlZddlZddlmZmZddlZddlZddlZd	d
lmZd	dlmZd	dlmZdd
l m!Z!m"Z"m#Z#ddl$m%Z%d	dlm&Z&d	dl'm(Z(m)Z)d	dl*m+Z+d	dl,m-Z-m.Z.d	dl/m0Z0d	dl1m2Z2d�Z3ejhdk\rdZ5dZ6ndZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<d Z=d!Z>d"Z?d#Z@d$ZAej`j�j�d%�&�ej�d'd(�e
j�d)�ZF	e
j�j�d*e
j�j�j��+�ZJeJj�e
j��e
j�d,�ZNeJj�eN�eFj�eJ�e
j��ZRe2d-d.�ZSeRj�eS�eFj�eR�e
j�d/�ZT	e	j�e	j�d0�d2�ZYej�j�d3k(rej�Z\d4�e_ZGd5�d6ej�j��Z_Gd7�d8e_�Z`Gd9�d:ej*�ZaGd;�d)e_�Zbd>d<�Zcd=�Zdy#Y��xYw#e	j�$reFj�d1�Y��wxYw)?aN
Core components of aptdaemon.

This module provides the following core classes of the aptdaemon:
AptDaemon - complete daemon for managing software via DBus interface
Transaction - represents a software management operation
TransactionQueue - queue for aptdaemon transactions

The main function allows to run the daemon as a command.
z%Sebastian Heinlein <devel@glatzor.de>)
�Transaction�TransactionQueue�	AptDaemon�$APTDAEMON_TRANSACTION_DBUS_INTERFACE�+APTDAEMON_DBUS_INTERFACEAPTDAEMON_DBUS_PATH�APTDAEMON_DBUS_SERVICE�APTDAEMON_IDLE_CHECK_INTERVAL�APTDAEMON_IDLE_TIMEOUT�TRANSACTION_IDLE_TIMEOUT�TRANSACTION_DEL_TIMEOUT�N)�ElementTree)�md5)�OptionParser)�GObject�GLib�)�ConfigWriter)�errors)�enums)�inline_callbacks�return_value�Deferred)�dbus_deferred_method)�
policykit1)�split_package_id�
set_euid_egid)�DummyWorker)�	AptWorker�.trans_only_installs_pkgs_from_high_trust_repos)�mainloop)�ColoredFormatterc�.�tjd|�S)N�	aptdaemon)�gettext�dgettext)�msgs �0/usr/lib/python3/dist-packages/aptdaemon/core.py�<lambda>r(Gs��� � ��c�2���3r$�ngettext�ugettext�	ungettextzorg.debian.aptz/org/debian/aptzorg.debian.apt.transaction�<iX�,�z$^[a-z0-9][a-z0-9\-+.]+(:[a-z0-9]+)?$z^[0-9][0-9.+\-A-Za-z:~]*$z^[a-zA-Z0-9_\-\.]+$T)�set_as_default�PATHz</usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binrz/dev/log)�address�facilityz$%(name)s: %(levelname)s: %(message)sz1%(asctime)s %(name)s [%(levelname)s]: %(message)sz%TzAptDaemon.Trans�z7Failed to unset LC_ALL. Translations are not available.c�|�t|tj�rtj|||�y||||�y)z�Handle exceptions of aptdaemon and avoid tiggering apport crash
    reports for valid DBusExceptions that are sent to the client.
    N)�
issubclassr�AptDaemonError�sys�__excepthook__)�exc_type�exc_obj�exc_tb�apport_excepthooks    r'�_excepthookr?�s2���(�F�1�1�2����8�W�f�5��(�G�V�4r)r>c�&�t|||t�S�N)r?r>)�etype�eobj�etbs   r'r(r(�s��k�%��s�:K�/M�r)c���eZdZdZdZejjejd��d��Z	ejjejdddd	�
�d��Ze
ejddd
��d��Zejjejdd��d��Zejjejdd��d��Zd�Zd�Zy)�
DBusObjectz6Enhanced D-Bus object class which supports properties.�zsa{sv}as��dbus_interface�	signaturec�@�tjd|�d|�d|���y)a�The signal gets emitted if a property of the object's
        interfaces changed.

        :param property: The name of the interface.
        :param changed_properties: A dictrionary of changed
            property/value pairs
        :param invalidated_properties: An array of property names which
            changed but the value isn't conveyed.

        :type interface: s
        :type changed_properties: a{sv}
        :type invalidated_properties: as
        zEmitting PropertiesChanged: �, N��log�debug)�self�	interface�changed_properties�invalidated_propertiess    r'�PropertiesChangedzDBusObject.PropertiesChanged�s ��"	�	�	��0�2H�J�	Kr)r5�s�object_path�
connection)�in_signature�
out_signature�path_keyword�connection_keywordc	��tjjj|||�}t	j
|�}|j
d�D�]�}|j|jd�}|j�D�]�\}}d|i}	||jvrd|	d<nd|	d<t|tj�rd|	d<�nDt|tj�rd|	d<�n#t|tj�rd	|	d<�nt|tj�rd
|	d<n�t|tj �rd|	d<n�t|tj"�rd|	d<n�t|tj$�rd
|j&z|	d<nut|tj(�rd|j&z|	d<nHt|tj*�rd|j&z|	d<nt-dt/|��d|�d���|j1t	j2d|	��������t	j4|d��}
|
S)NrQ�name�	readwrite�access�readrU�type�u�i�t�x�bz(%s)za{%s}za%szType z
 of property z isn't convertable�property�UTF-8)�encoding)�dbus�service�Object�
Introspectr
�
fromstring�findall�_get_properties�attrib�items�WRITABLE_PROPERTIES�
isinstance�String�UInt32�Int32�UInt64�Int64�Boolean�StructrJ�
Dictionary�Array�	Exceptionra�append�Element�tostring)rPrVrW�data�xml�iface�props�key�valuerq�new_datas           r'rmzDBusObject.Introspect�s����|�|�"�"�-�-�d�K��L���$�$�T�*���[�[��-�	F�E��(�(����f�)=�>�E�#�k�k�m�
F�
��U� �#����$�2�2�2�'2�F�8�$�'-�F�8�$��e�T�[�[�1�%(�F�6�N���t�{�{�3�%(�F�6�N���t�z�z�2�%(�F�6�N���t�{�{�3�%(�F�6�N���t�z�z�2�%(�F�6�N���t�|�|�4�%(�F�6�N���t�{�{�3�%+�e�o�o�%=�F�6�N���t���7�%,�u���%>�F�6�N���t�z�z�2�%*�U�_�_�%<�F�6�N�#�59�%�[�#�%G�H�H����[�0�0��V�D�E�7
F�	F�<�'�'��g�>���r)�ssv�sender�rXrY�sender_keywordc�`�tjd|�d|���|j||||�S)arSet a property.

        Only the user who intiaited the transaction is
        allowed to modify it.

        :param iface: The interface which provides the property.
        :param name: The name of the property which should be modified.
        :param value: The new value of the property.

        :type iface: s
        :type name: s
        :type value: v
        zSet() was called: rL)rNrO�
_set_property�rPr�r]r�r�s     r'�SetzDBusObject.Set�s,��"	�	�	��e�<�=��!�!�%��u�f�=�=r)za{sv}�rXrYc�T�tjd|z�|j|�S)z4Get all available properties of the given interface.zGetAll() was called: %s�rNrOrp�rPr�s  r'�GetAllzDBusObject.GetAll�s'��	�	�	�+�e�3�4��#�#�E�*�*r)�ss�vc�`�tjd|�d|���|j|�|S)zXReturn the value of the given property provided by the given
        interface.
        zGet() was called: rLr�)rPr�rgs   r'�GetzDBusObject.Gets+��	�	�	��x�@�A��#�#�E�*�8�4�4r)c�F�tjjd|z��)�;Helper to set a property on the properties D-Bus interface.�!Unknown or read only property: %s)rj�
exceptions�
DBusExceptionr�s     r'r�zDBusObject._set_property
s)���o�o�+�+�-;�=A�-B�C�	Cr)c��iS)�2Helper to get the properties of a D-Bus interface.rGr�s  r'rpzDBusObject._get_propertiess���	r)N)�__name__�
__module__�__qualname__�__doc__rsrjrk�signal�PROPERTIES_IFACErT�method�INTROSPECTABLE_IFACErmrr�r�r�r�rprGr)r'rFrF�s��@���
�\�\����(=�(=�#-��/�K�/�K�&
�\�\����2�2�&(��&3�,8��:�#�	:�#�L�$�/�/�',�B�)1�3�>�3�>�$
�\�\����.�.�&)���B�+�B�+�
�\�\����.�.�&*�#��?�5�?�5�C�
r)rFc�	�eZdZdZiej
d�ejej�ejej�ejej�ejej�ejej�ejej �ej"ej�ej$ej&�ej(ej&�ej*ej&�ej,ej�ej.ej�ej0ej&�ej2ej�ej4ej6�ej8ej&�ej:eji�ZdZ	dmd�Z d�Z!d�Z"d�Z#d�Z$d	�Z%e&e%e$d
��Z'd�Z(d
�Z)e&e)e(d��Z*d�Z+d�Z,e&e,e+d��Z-d�Z.d�Z/e&e/e.d��Z0d�Z1d�Z2e&e2e1d��Z3d�Z4d�Z5e&e4e5d��Z6d�Z7d�Z8e&e7e8d��Z9d�Z:d�Z;e&e;e:d ��Z<d!�Z=d"�Z>e&e=e>d#��Z?d$�Z@d%�ZAe&e@eAd&��ZBd'�ZCd(�ZDe&eCeDd)��ZEd*�ZFd+�ZGe&eFeGd,��ZHd-�ZId.�ZJe&eIeJd/��ZKd0�ZLd1�ZMe&eLeMd2�ZNd3�ZOd4�ZPe&eOePd5��ZQd6�ZRd7�ZSe&eReSd8��ZTd9�ZUd:�ZVe&eUeVd;��ZWd<�ZXd=�ZYe&eXeYd>��ZZd?�Z[d@�Z\e&e[e\dA��Z]dB�Z^dC�Z_e&e^e_dD��Z`eaj�j�eddE�F�dG��Zeeaj�j�eddH�F�dI��Zfeaj�j�eddJ�F�dK��Zgeaj�j�eddJ�F�dL��ZhdM�ZiejdN��ZkdO�ZldP�Zmeaj�j�eddHdQdR�S�dT��ZoepeddQdQdR�S�dU��ZqejdV��ZrejdW��ZsejdX��ZtejdY��ZuepeddQdQdR�S�dZ��Zvejd[��ZwepeddQdQdR�S�d\��Zxejd]��Zyejd^��Zzd_�Z{d`�Z|da�Z}epeddHdQdR�S�db��Z~ejdc��ZepeddJdQdR�S�dd��Z�ejde��Z�ejdf��Z�dg�Z�ejdh��Z�di�Z�dj�Z�dk�Z�dl�Z�y)nraRepresents a transaction on the D-Bus.

    A transaction represents a single package management task, e.g.
    installation or removal of packages. This class allows to expose
    information and to controll the transaction via DBus using PolicyKit
    for managing privileges.
    N)�	HttpProxy�Terminal�AllowUnauthenticated�
DebconfSocket�MetaData�Locale�RemoveObsoleteDependsc
	�
�|�tj�j}d|z|_|	dur]|
|_|
�tj�|_t
jjt|j�}
|j}nd}
d}
d}tj||
|�|sggggggf}|si}||_||_
||_tjd�|_tj"d�|_tj"d�|_||_||_tjd�|_tjd�|_d|jz}t0j2j5|�rtj|�|_ntjd�|_||_d|_d|_tj|�|_tj@d�|_!tjDdd	�
�|_#tjDdd�
�|_$tjDd
d�
�|_%tjtLjN�|_(tjtLjR�|_*tjd�|_+d|_,tjDd
d�
�|_-tj"d�|_.tj"d�|_/tjDd
d�
�|_0tjDd
d�
�|_1d|_2tj"d�|_3tj"d�|_4tjjd�
�|_6tjnd�|_8tjnd�|_9tjDtud�D�cgc]}tjvgd�
���c}d�
�|_<tjD|D�cgc]}tjv|d�
���c}d�
�|_=tjvgtj|d��
�|_?tjvgtj|d��
�|_@t�j�t�|j��|_Ed|_F|
r"|
j�||j��|_Ind|_I||_Jd|_Kd|_Ld|_Mycc}wcc}w)a�Initialize a new Transaction instance.

        Keyword arguments:
        tid -- The unique identifier
        role -- The role enum of the transaction
        queue -- TransactionQueue instance of the daemon
        pid -- the id of the process which created the transaction
        uid -- the uid of the user who created the transaction
        cmdline -- the cmdline of the calling process
        sender -- the DBus name of the sender who created the transaction
        connect -- if the Transaction should connect to DBus (default is True)
        bus -- the DBus connection which should be used
            (defaults to system bus)
        Nz/org/debian/apt/transaction/%sTr5Fz/run/user/%d/pk-debconf-socketr)rrrrgr�iixxdx�rJ)r5r5r5rrr5�sssxxs�r5r5r��sv�rU�asasasasasasas�asasasasasas)N�uuid�uuid4�hex�tid�busrj�	SystemBusrk�BusNamerrF�__init__�queue�uid�gidru�localerz�allow_unauthenticated�remove_obsoleted_depends�cmdline�pid�
http_proxy�terminal�os�path�exists�debconf�kwargs�_translation�after�_rolerw�	_progressr{�_progress_details�_progress_download�_progress_packager�EXIT_UNFINISHED�_exit�STATUS_SETTING_UP�_status�_status_details�_error�_error_property�_cancellable�_term_attached�_required_medium�_config_file_conflict� _config_file_conflict_resolution�	cancelled�pausedr|�
_meta_datary�	_download�_space�ranger}�_depends�	_packages�	Signature�_unauthenticated�_high_trust_packagesr�timeout_add_secondsr
� _remove_from_connection_no_raise�_idle_watch�sender_alive�watch_name_owner�_sender_owner_changed�
_sender_watchr��output�	simulated�
_simulated_cb)rPr��roler�r�r�r�r�r��connectr��packagesr��bus_name�	dbus_path�	pk_socketrc�pkgss                  r'r�zTransaction.__init__Gs��� �;��*�*�,�"�"�C�3�c�9����d�?��D�H��{��>�>�+����|�|�+�+�,B�D�H�H�M�H����I��C��H��I����D�(�I�6���B��B��B�/�H���F���
��������k�k�"�o���%)�\�\�%�%8��"�(,���U�(;��%��������+�+�b�/������B���
�4�t�x�x�?�	�
�7�7�>�>�)�$��;�;�y�1�D�L��;�;�r�?�D�L���� �����
��[�[��&��
����A����!%���-A�7?�"A���"&�+�+�.D�8@�#B���!%���X��!F����[�[��!6�!6�7��
��{�{�5�#:�#:�;���#�{�{�2�������#�{�{�8�t�D��� �L�L��.���"�l�l�5�1��� $���H�� E���%)�[�[��T�%J��"�02��-����e�,����l�l�5�)����/�/�D�9������A�����j�j��m������.3�A�h�%8�)*�&*�Z�Z��c�%B�%8�.>�@��
����2:�&<�*.�'+�j�j���&E�&<�/=�?���!%�
�
�2�����9L� M���$(�J�J�r�9=����9L�%N��!� �3�3�$�d�&K�&K�M���!����!$�!5�!5���2�2�"4�D��"&�D�����������!����/%8��&<s�;T<�:Uc��|sd|_yy)zPCallback if the owner of the original sender changed, e.g.
        disconnected.FN)r�)rPrWs  r'r�z!Transaction._sender_owner_changed�s��� %�D��r)c�*�tjd�	|j�	|jj
j
|j�y#t$r"}tjd|z�Yd}~�Wd}~wwxYw#t$rYywxYw)zdVersion of remove_from_connection that does not raise if the
        object isn't exported.
        zRemoving transactionz1remove_from_connection() raised LookupError: '%s'NF)	�	log_transrO�remove_from_connection�LookupErrorr��limbo�popr��KeyError)rP�errors  r'r�z,Transaction._remove_from_connection_no_raise�s���	���.�/�	,��'�'�)�
	��J�J��� � ����*����	,��O�O�#�%*�+�
,�
,��	,���	���	�s(�A�/B�	B�!A>�>B�	B�Bc�$�g}t|�D�]\}}	||dk(r%|jtj|��n�||dk(r%|jtj|��n�||dk(r%|jtj
|��n�||dk(r%|jtj|��nd||dk(r%|jtj|��n7||dk(r|jt|��ntd|�d||������"tj|tj|���S#t$r+}|jd	|�d
|�d|�dt|�����d
}~wwxYw)z�Convert a list to a DBus struct with the given signature. Currently
        integer, long, unsigned long, double, string and boolean are
        supported (ixtdsb).
        rcrerd�drfrUzValue z with unknown signature zFailed to convert item z of z with signature z: Nr�)�	enumeraterrjrwryrx�Doublerz�get_dbus_stringr~�	__class__�strr{r�)rP�lstrJ�struct�num�itemrs       r'�_convert_structzTransaction._convert_struct�s^��
��"�3��	I�I�C��
I��S�>�S�(��M�M�$�*�*�T�"2�3��s�^�s�*��M�M�$�*�*�T�"2�3��s�^�s�*��M�M�$�+�+�d�"3�4��s�^�s�*��M�M�$�+�+�d�"3�4��s�^�s�*��M�M�$�,�,�t�"4�5��s�^�s�*��M�M�/�$�"7�8�#�%)�9�S�>�%;�<�<��	I�,�{�{�6�T�^�^�I�-F�G�G���
I��o�o�<?��<E�<?��J�'H�I�I��
I�s�DE�	F�$&F
�
Fc���|jtjk7rtj��t|tj�stjd|z��|jjd�stjd��|j�D]�\}}||jvrtjd|z��t|jd��dkDstjd��t|tj�r�ytjd|z��|jj!|�|j#d	|j�y)
Nz)The data value has to be a dictionary: %srUz"Only strings are accepted as keys.zHThe key %s already exists. It is not allowed to overwrite existing data.�_rz5The key %s has to be of the format IDENTIFIER-KEYNAMEz The value has to be a string: %sr�)�statusrr�r�TransactionAlreadyRunningrtrjr|�InvalidMetaDataErrorrJ�
startswithrrr��len�splitru�update�PropertyChanged)rPr�r�r�s    r'�_set_meta_datazTransaction._set_meta_data�sX���;�;�%�1�1�1��2�2�4�4��$����0��-�-�/?�AE�/F�G�
G��~�~�(�(��-��-�-�/9�:�
:��*�*�,�	H�J�C���d�o�o�%��1�1�3:�=@�3@�A�A��s�y�y��~�&��*��1�1�3G�H�H��e�T�[�[�1��1�1�3?�AF�3G�H�H�	H�	
�����t�$����Z����9r)c��|jSrA)r��rPs r'�_get_meta_datazTransaction._get_meta_data�s�����r)zRAllows client applications to store meta data for the transaction in a dictionary.)�docc���|jtjk7rtj��tj|�|_|jd|j�y)N�Role)r�r�
ROLE_UNSETr�TransactionRoleAlreadySetrjrur�rP�enums  r'�	_set_rolezTransaction._set_rolesG���:�:��)�)�)��2�2�4�4��[�[��&��
����V�T�Z�Z�0r)c��|jSrA)r�r!s r'�	_get_rolezTransaction._get_role	����z�z�r)zOperation type of transaction.c�j�|j|d�|_|jd|j�y)Nr��ProgressDetails)rr�r)rP�detailss  r'�_set_progress_detailsz!Transaction._set_progress_detailss.��!%�!5�!5�g�x�!H������.��0F�0F�Gr)c��|jSrA)r�r!s r'�_get_progress_detailsz!Transaction._get_progress_details����%�%�%r)zzTuple containing detailed progress information: items done, total items, bytes done, total bytes, speed and remaining timec���||_|j|j�|jz}|j	|j
|fd�|_|jd|j�y)Nr��Error)r�r$r0�details_argsr�coder�r)rP�excepr&s   r'�
_set_errorzTransaction._set_errorsZ������l�l�5�=�=�)�E�,>�,>�>��#�3�3�U�Z�Z��4E�t�L������W�d�&:�&:�;r)c��|jSrA)r�r!s r'�
_get_errorzTransaction._get_error"����{�{�r)zRaised exception.c�d�tj|_tj|�|_|j
d|j
�|j|j
�|jr|jj�tjt|j�y)N�	ExitState)r�STATUS_FINISHEDrrjrur�r�Finishedr��cancelrr�rr�r(s  r'�	_set_exitzTransaction._set_exit's{���+�+����[�[��&��
����[�$�*�*�5��
�
�d�j�j�!�������%�%�'�	
� � �!8�!%�!F�!F�	Hr)c��|jSrA)r�r!s r'�	_get_exitzTransaction._get_exit3r-r)z"The exit state of the transaction.c��|jSrA)r�r!s r'�
_get_downloadzTransaction._get_download9����~�~�r)c�p�tj|�|_|jd|j�y)N�Download)rjryr�r�rP�sizes  r'�
_set_downloadzTransaction._set_download<s&�����D�)������Z����8r)z%The download size of the transaction.c��|jSrA)r�r!s r'�
_get_spacezTransaction._get_spaceCr=r)c�p�tj|�|_|jd|j�y)N�Space)rjryr�rrKs  r'�
_set_spacezTransaction._set_spaceFs&���j�j��&������W�d�k�k�2r)z+The required disk space of the transaction.c	���tj|D�cgc]}tj|d����c}d��|_|j	d|j�ycc}w)NrUr��as�Packages)rjr{r}r�r)rPr�r�s   r'�
_set_packageszTransaction._set_packagesMsQ�����2:�&<�*.�'+�j�j���&E�&<�/3�5���	
���Z����8��&<��Ac��|jSrA)r�r!s r'�
_get_packageszTransaction._get_packagesSrHr)zaPackages which will be explictly installed, reinstalled, removed, purged, upgraded or downgraded.c��|jSrA)r�r!s r'�_get_unauthenticatedz Transaction._get_unauthenticated[����$�$�$r)c�t�tj|d��|_|jd|j�y)NrUr��Unauthenticated)rjr}r�r)rP�unauthenticateds  r'�_set_unauthenticatedz Transaction._set_unauthenticated^s,�� $�
�
�?�c� J������.��0E�0E�Fr)z,Unauthenticated packages in this transactionc��|jSrA)r�r!s r'�_get_high_trust_packagesz$Transaction._get_high_trust_packagesis���(�(�(r)c�t�tj|d��|_|jd|j�y)NrUr��HighTrustWhitelistedPackages)rjr}r�r)rP�whitelisted_packagess  r'�_set_high_trust_packagesz$Transaction._set_high_trust_packagesls3��$(�J�J�/C�9<�%>��!����;�!�6�6�	8r)z'High trust packages in this transactionc��|jSrA)r�r!s r'�_get_dependszTransaction._get_dependsws���}�}�r)c	���tj|D�cgc]}tj|d����c}d��|_|j	d|j�ycc}w)NrUr�rT�Dependencies)rjr{r}r�r)rP�depends�depss   r'�_set_dependszTransaction._set_dependszsQ�����18�%:�)-�&*�Z�Z���%D�%:�.2�4��
�	
���^�T�]�]�;��%:rWzIThe additional dependencies: installs, removals, upgrades and downgrades.c��|jSrA)r�r!s r'�_get_statuszTransaction._get_status�s���|�|�r)c�p�tj|�|_|jd|j�y)N�Status)rjrur�rr(s  r'�_set_statuszTransaction._set_status�s&���{�{�4�(������X�t�|�|�4r)zThe status of the transaction.c��|jSrA)r�r!s r'�_get_status_detailszTransaction._get_status_details�s���#�#�#r)c�\�t|�|_|jd|j�y)N�
StatusDetails)r
r�r)rP�texts  r'�_set_status_detailszTransaction._set_status_details�s%��.�t�4������_�d�.B�.B�Cr)zThe status message from apt.c��|jSrA)r�r!s r'�
_get_progresszTransaction._get_progress�rHr)c�p�tj|�|_|jd|j�y)N�Progress)rjrwr�r)rP�percents  r'�
_set_progresszTransaction._set_progress�s&�����G�,������Z����8r)z+The progress of the transaction in percent.c��|jSrA)r�r!s r'�_get_progress_packagez!Transaction._get_progress_package�r4r)c�2�|j|d�|_y)Nr�)rr�)rP�progress_packages  r'�_set_progress_packagez!Transaction._set_progress_package�s��!%�!5�!5�6F��!M��r)zbThe last progress update of a currentlyprocessed package. A tuple of package name and status enum.c��|jSrA)r�r!s r'�_get_progress_downloadz"Transaction._get_progress_download�s���&�&�&r)c�j�|j|d�|_|jd|j�y)Nr��ProgressDownload)rr�r)rP�progress_downloads  r'�_set_progress_downloadz"Transaction._set_progress_download�s3��"&�"6�"6�7H�7?�#A������/��1H�1H�Ir)z�The last progress update of a currentlyrunning download. A tuple of URI, status, short description, full size, partially downloaded size and a status message.c��|jSrA)r�r!s r'�_get_cancellablezTransaction._get_cancellable�s��� � � r)c�p�tj|�|_|jd|j�y)N�Cancellable)rjrzr�r)rP�cancellables  r'�_set_cancellablezTransaction._set_cancellable�s)�� �L�L��5������]�D�,=�,=�>r)z4If it's currently allowed to cancel the transaction.c��|jSrA)r�r!s r'�_get_term_attachedzTransaction._get_term_attached�s���"�"�"r)c�p�tj|�|_|jd|j�y)N�TerminalAttached)rjrzr�r)rP�attacheds  r'�_set_term_attachedzTransaction._set_term_attached�s*��"�l�l�8�4������/��1D�1D�Er)zVIf the controlling terminal is currently attached to the dpkg call of the transaction.c��|jSrA)r�r!s r'�_get_required_mediumz Transaction._get_required_medium�r\r)c��|j|d�|_|jd|j�|j|j�y)Nr��RequiredMedium)rr�r�MediumRequired)rP�mediums  r'�_set_required_mediumz Transaction._set_required_medium�sD�� $� 4� 4�V�T� B������-�t�/D�/D�E�����T�2�2�3r)zWTuple containing the label and the drive of a required CD/DVD to install packages from.c��|jSrA)r�r!s r'�_get_config_file_conflictz%Transaction._get_config_file_conflict�s���)�)�)r)c���|�tjdd��|_y|j|d�|_|j	d|j�|j
|j�y)Nr�r�r��ConfigFileConflict)rjr{r�rrr�)rP�prompts  r'�_set_config_file_conflictz%Transaction._set_config_file_conflict�s_���>�)-���X��)N�D�&��%)�%9�%9�&�$�%G��"����1�4�3M�3M�N������!;�!;�<r)zCTuple containing the old and the new path of the configuration filer�rHc�:�tjd|�d|���y�z�The signal gets emitted if a property of the transaction changed.

        :param property: The name of the property.
        :param value: The new value of the property.

        :type property: s
        :type value: v
        zEmitting PropertyChanged: rLN�rrO�rPrgr�s   r'rzTransaction.PropertyChanged�s��	���h��N�Or)rUc�Z�tjdtj|�z�y)z�The signal gets emitted if the transaction has been finished.

        :param exit_state: The exit state of the transaction, e.g.
            ``exit-failed``.
        :type exit_state: s
        zEmitting Finished: %sN)rrOr�get_exit_string_from_enum)rP�
exit_states  r'rAzTransaction.Finisheds(��	���/��7�7�
�C�D�	Er)r�c�:�tjd|�d|���y)aSet and emit the required medium change.

        This method/signal should be used to inform the user to
        insert the installation CD/DVD:

        Keyword arguments:
        medium -- the CD/DVD label
        drive -- mount point of the drive
        zEmitting MediumRequired: rLNr�)rPr��drives   r'r�zTransaction.MediumRequireds��	���V�U�K�Lr)c�:�tjd|�d|���y)a(Set and emit the ConfigFileConflict signal.

        This method/signal should be used to inform the user to
        answer a config file prompt.

        Keyword arguments:
        old -- current version of the configuration prompt
        new -- new version of the configuration prompt
        zEmitting ConfigFileConflict: rLNr�)rP�old�news   r'r�zTransaction.ConfigFileConflicts��	����c�J�Kr)c���|jtjk7rtj��dt|�vrt
d��	tjt|��\}}|�d}tj|�|_ntj|�d|���|_tjdd|g��|_
|jd	|j�y#t$r�wxYw)
z�Set the language and encoding.

        Keyword arguments:
        locale -- specifies language, territory and encoding according
                  to RFC 1766,  e.g. "de_DE.UTF-8"
        �/z,Security exception: Absolute path for localeN�C�.r#T)�fallback�	languagesr�)rrr�rrr�
ValueErrorr��_parse_localenamerjrur$�translationr�r)rP�
locale_str�langris    r'�_set_localezTransaction._set_locale/s����;�;�%�1�1�1��2�2�4�4��#�j�/�!��K�L�L�	8�%�7�7��J��H��T�8��|���"�k�k�$�/���"�k�k�T�8�*D�E��� '� 3� 3�K�=A�?C�f�!F�D��
� � ��4�;�;�7���	��	�s�!C%�%C0c#�>K�|dk7r*|jd�rd|vrtj|��tj}tj
|||j����tj|�|_	|jd|j�y�w)z�Set an http network proxy.

        Keyword arguments:
        url -- the URL of the proxy server, e.g. http://proxy:8080
        r5zhttp://�:�r�r�N)rr�InvalidProxyErrorr�PK_ACTION_SET_PROXY�check_authorization_by_namer�rjrur�r)rP�urlr��actions    r'�_set_http_proxyzTransaction._set_http_proxyJs������"�9�c�n�n�Y�7�3�c�>��*�*�3�/�/��/�/���4�4�V�V�9=���C�	C��+�+�c�*������[�$�/�/�:�s�BBc�p�tj|�|_|jd|j�y)a
Set the handling of the removal of automatically installed
        dependencies which are now obsoleted.

        Keyword arguments:
        remove_obsoleted_depends -- If True also remove automatically installed
            dependencies of to removed packages
        �RemoveObsoletedDependsN)rjrzr�r)rPr�s  r'�_set_remove_obsoleted_dependsz)Transaction._set_remove_obsoleted_dependsYs0��)-���5M�(N��%����5�!�:�:�	<r)c�p�tj|�|_|jd|j�y)z�Set the handling of unauthenticated packages

        Keyword arguments:
        allow_unauthenticated -- True to allow packages that come from a
            repository without a valid authentication signature
        r�N)rjrzr�r)rPr�s  r'�_set_allow_unauthenticatedz&Transaction._set_allow_unauthenticatedes0��&*�\�\�2G�%H��"����3�!�7�7�	9r)r5r�r�c���tjd|j�	|jj|}|jrt
d��||_y#t
$rt
d��wxYw)a0Queue the transaction for processing after the given transaction.

        The transaction will also fail if the previous one failed. Several
        transactions can be chained up.

        :param tid: The id of the transaction which should be executed
            before.

        :type tid: s
        �Queuing transaction %sz9The given transaction doesn't exist or is already queued!z&There is already an after transaction!N)r�infor�r�rrr~r�)rPr�r��trans_befores    r'�RunAfterzTransaction.RunAfterqsr��	���/����:�	/��:�:�+�+�C�0�L�����D�E�E�!�����	/��.�/�
/�	/�s�A�A/c�d�tjd|j�|j|�S)zTCheck the authentication, simulate and queue the transaction for
        processing.r�)rr�r��_run�rPr�s  r'�RunzTransaction.Run�s&��	���/����:��y�y�� � r)c#��K�|j|���|j���|j���|jj	|j
�tj|_|j}|rn|j���|j���|jj	|j
�tj|_|j}|r�myy�wrA)
�_check_foreign_user�_check_simulated�_check_authr��putr�r�STATUS_WAITINGrr�)rPr��
next_transs   r'r�zTransaction._run�s������&�&�v�.�.��#�#�%�%���� � ��
�
���t�x�x� ��*�*����Z�Z�
���'�'�)�)��(�(�*�*��J�J�N�N�:�>�>�*� %� 4� 4�J��#�)�)�J��s�C,C1�/C1c#�K�|j�:|jjjsd|_|j���yy�w)N�	)r�r��worker�trans�progress�_simulate_realr!s r'r�zTransaction._check_simulated�s@����
�>�>�!�
�:�:�$�$�*�*� !��
��%�%�'�'��s�AA
c#�K�tj|_|j|j}|�y|jtj
tjfvrt|�rtj}|jtjk(r�|jtjs�|jtjsg|jtjsJ|jtjs-|jtjstj }	|j#���}|s/tj$|j&||j(����yy#t*j,$rN}t+j.tj0t3|��|_tj6|_|�d}~wt*j:$rN}t+j.tj<t3|��|_tj6|_|�d}~wwxYw�w)z�Check silently if one of the high level privileges has been granted
        before to reduce clicks to install packages from third party
        epositories: AddRepository -> UpdateCache -> InstallPackages
        Nr�)r�STATUS_AUTHENTICATINGr�ROLE_ACTION_MAPr��ROLE_INSTALL_PACKAGES�ROLE_COMMIT_PACKAGESrr�/PK_ACTION_INSTALL_PACKAGES_FROM_HIGH_TRUST_REPOr��PKGS_INSTALL�PKGS_REINSTALL�PKGS_REMOVE�
PKGS_PURGE�PKGS_DOWNGRADE�PK_ACTION_UPGRADE_PACKAGES�_check_alternative_authr�r�r�r�NotAuthorizedError�TransactionFailed�ERROR_NOT_AUTHORIZEDrr�EXIT_FAILED�exit�AuthorizationFailed�ERROR_AUTH_FAILED)rPr��
authorizedrs    r'r�zTransaction._check_auth�s������1�1����%�%�d�i�i�0���>��
�I�I�%�5�5��4�4�6�
6�>�t�D��O�O�F��I�I��3�3�3��M�M�%�"4�"4�5��M�M�%�"6�"6�7��M�M�%�"3�"3�4��M�M�%�"2�"2�3��M�M�%�"6�"6�7��:�:�F�	�#�;�;�=�=�J�� �<�<�T�[�[�=C�AE���K�K����(�(�	��1�1�%�2L�2L�25�e�*�>�D�J��)�)�D�I��L���)�)�	��1�1�%�2I�2I�25�e�*�>�D�J��)�)�D�I��L��		�s9�D7I�:AE>�<I�>H>�A	G�H>�0A	H9�9H>�>Ic#�K�|jtjtjtjtj
tjfvrtd�tj}tjtjfD]=}	tj|j||j|����td��?td�y#tj $rY�awxYw�w)z^Check non-interactively if one of the high level privileges
        has been granted.
        F)r��flagsTN)r�r�ROLE_ADD_REPOSITORY�"ROLE_ADD_VENDOR_KEY_FROM_KEYSERVER�ROLE_UPDATE_CACHEr��ROLE_ADD_LICENSE_KEYrr�CHECK_AUTH_NONE�(PK_ACTION_INSTALL_PACKAGES_FROM_NEW_REPO�$PK_ACTION_INSTALL_PURCHASED_PACKAGESr�r�r�rr�)rPr�r�s   r'r�z#Transaction._check_alternative_auth�s�����
�9�9�U�6�6�"�E�E�"�4�4�"�8�8�"�7�7�	9�9�

����*�*��!�J�J�!�F�F�H�
	#�F�
#� �<�<�T�[�[�=C�AE���CH�J�J��T�"�
	#�	�U���	�,�,�
��
�s*�BC<�/C#�
C<�#C9�6C<�8C9�9C<c�d�tjd|j�|j|�S)zCancel the transaction.zCancelling transaction %s)rr�r��_cancelr�s  r'�CancelzTransaction.Cancel�s&��
	���2�D�H�H�=��|�|�F�#�#r)c#��K�	|j|���	|jj|�tjd�tj|_
tj|_y#tj$r7tj}tj
|||j����Y��wxYw#t $rYnwxYw|j"|jj$vrtj|_y|j&r9tjd�d|_tj|_
d|_ytj,d���w)Nr�zRemoved transaction from queuezSetting cancel eventTFzCould not cancel transaction)r�r�ForeignTransactionr�PK_ACTION_CANCEL_FOREIGNr�r�r��removerrOr�STATUS_CANCELLINGr�EXIT_CANCELLEDr�r�r�rr�r�r�r8)rPr�r�s   r'r�zTransaction._cancel�s%����	G��*�*�6�2�2�
	��J�J���d�#��O�O�<�=� �1�1�D�K��,�,�D�I����(�(�	G��8�8�F��8�8���=A�X�X�G�
G�	G���	��	���8�8�t�z�z�'�'�'��,�,�D�I��
�
�
��O�O�2�3�!�D�N��1�1�D�K��D�K���#�#�$B�C�C�sG�E!�A3�0C�+E!�3AB=�:E!�<B=�=E!�	C�	E!�C�BE!c�N�tjd�|j|�S)z�Simulate a transaction to update its dependencies, download size
        and required disk space.

        Call this method if you want to show changes before queuing the
        transaction.
        zSimulate was called)rr��	_simulater�s  r'�SimulatezTransaction.Simulates ��	���,�-��~�~�f�%�%r)c#�K�|jrtj��|jtj
k7rtj��|j|���|j���y�wrA)	r�r�TransactionAlreadySimulatingrrr�rr�r�r�s  r'rzTransaction._simulate's_��������5�5�7�7��;�;�%�1�1�1��2�2�4�4��&�&�v�.�.��!�!�#�#�s�A8A:c#��K�|jrtj��|jtj
k(r|j
���|jjj|�t�}|j�tj|j�d|_|jjjd|j|�|_|��y�w)Nztransaction-simulated)r�rr
r�r�ROLE_INSTALL_FILEr�r�r��simulaterr�r�
source_remover��_on_transaction_simulated)rP�deferreds  r'r�zTransaction._simulate_real0s���������5�5�7�7��9�9��/�/�/��"�"�$�$��
�
���"�"�4�(��:�����'����t�/�/�0����!�Z�Z�.�.�6�6�#��*�*�������s�C,C.c���||ury|jjj|j�d|_|j
r|j
|j
�y|j�yrA)r�r��
disconnectr��
_simualted_cbr�errback�callback)rPr�r�rs    r'rz%Transaction._on_transaction_simulatedAsX�������
�
���$�$�T�%7�%7�8�!����;�;����U�[�[�)����r)c���|jtjk7rtj��t|j|j�5tjj|�dk7rtjd|z��d}	tj|tjtjz�}tj|�j |jk7r&tjd|�d|j�d���tj"|�r7t%j&|�|_|j+d|j(�ntjd|z��	|�tj.|�	ddd�y#t,$rtjd|z��wxYw#|�tj.|�wwxYw#1swYyxYw)	aASet the controlling terminal.

        The worker will be attached to the specified slave end of a pty
        master/slave pair. This allows to interact with the

        Can only be changed before the transaction is started.

        Keyword arguments:
        ttyname -- file path to the slave file descriptor
        z/dev/ptsz%s isn't a ttyNzPty device 'z6' has to be owned bythe owner of the transaction (uid z) r�zCould not open %s)rrr�rrrr�r�r�r��dirnamer8�open�O_RDWR�O_NOCTTY�fstat�st_uid�isattyrjrur�rr~�close)rP�ttyname�slave_fds   r'�
_set_terminalzTransaction._set_terminalKs����;�;�%�1�1�1��2�2�4�4�
�4�8�8�T�X�X�
.�	'��w�w���w�'�:�5��+�+�,<�w�,F�G�G��H�
'��7�7�7�B�I�I����,C�D���8�8�H�%�,�,����8� �/�/�?F����1R�S�S��9�9�X�&�$(�K�K��$8�D�M��(�(��T�]�]�C� �/�/�0@�7�0J�K�K�D��'��H�H�X�&�+	'�	'���
K��+�+�,?�'�,I�J�J�
K���'��H�H�X�&�(��)	'�	'�s7�=G�5F�B6G�<G�"F?�?G�G�G�G(c��|jtjk7rtj��t|j|j�5	tj|�}|j|jk7rtjd|z��	ddd�tj|�|_|j!d|j�y#t$rtjd|z��wxYw#1swY�exYw)a�Set the socket of the debconf proxy.

        The worker process forwards all debconf commands through this
        socket by using the passthrough frontend. On the client side
        debconf-communicate should be connected to the socket.

        Can only be changed before the transaction is started.

        Keyword arguments:
        debconf_socket: absolute path to the socket
        z;socket '%s' has to be owned by the owner of the transactionz#socket status could not be read: %sNr�)rrr�rrrr�r�r��statrr8r~rjrur�r)rP�debconf_socketr#s   r'�_set_debconfzTransaction._set_debconfos����;�;�%�1�1�1��2�2�4�4�
�4�8�8�T�X�X�
.�
	P�	
P��w�w�~�.��
�;�;�$�(�(�*� �/�/�1>�@N�1O�P�P�+�
	P��{�{�>�2������_�d�l�l�;���
C��+�+�-1�3A�-B�C�C�
C��
	P�
	P�s$�C?�C�)1C?�"C<�<C?�?Dc�R�tjd|�|j||�S)a$Continue paused transaction with the inserted medium.

        If a media change is required to install packages from CD/DVD
        the transaction will be paused and could be resumed with this
        method.

        :param medium: The label of the CD/DVD.
        :type medium: s
        zMedium %s was provided)rr��_provide_medium�rPr�r�s   r'�
ProvideMediumzTransaction.ProvideMedium�s&��	���/��8��#�#�F�F�3�3r)c#��K�|j|���|jstjd��|jd|k(stjd|z��d|_y�w)Nz There isn't any required medium.rz The medium '%s' isn't requested.F)r��required_mediumrr8r�r(s   r'r'zTransaction._provide_medium�sl�����&�&�v�.�.��#�#��'�'�(J�K�K��#�#�A�&�&�0��'�'�)5�7=�)>�?�
?����s�A'A)c�V�tjd||�|j|||�S)a�Resolve a configuration file conflict and continue the transaction.

        If a config file prompt is detected the transaction will be
        paused and could be resumed with this method.

        :param config: The path to the original config file.
        :param answer: The answer to the configuration file question, can be
            "keep" or "replace"

        :type config: s
        :type answer: s
        zResolved conflict of %s with %s)rr��_resolve_config_file_conflict�rP�config�answerr�s    r'�ResolveConfigFileConflictz%Transaction.ResolveConfigFileConflict�s*�� 	���8�&�&�I��1�1�&�&�&�I�Ir)c#�K�|j|���|jstjd��|dvrtjd|z��|jd|k(stjd|z��||_d|_y�w)Nz+There isn't any config file prompt required)�keep�replacezInvalid value: %srzInvalid config file: %sF)r��config_file_conflictrr8�config_file_conflict_resolutionr�r.s    r'r-z)Transaction._resolve_config_file_conflict�s������&�&�v�.�.��(�(��'�'�)3�4�
4��,�,��'�'�(;�f�(D�E�E��(�(��+�v�5��'�'�(A�F�(J�K�K�/5��,����s�B
Bc#�K�|j|���|tk(r�|dk(r|j|�y
|dk(r|j|�y
|dk(r|j	|�y
|dk(r|j|�y
|dk(r|j
|�y
|dk(r|j|�y
|dk(r|j||�y
tjjd|z��tjjd	|z���w)z7Helper to set a name on the properties D-Bus interface.r�r�r�r�r�r�r�r��Unknown interface: %sN)r�rrr!r%r�r�r�r�rjr�r�r�s     r'r�zTransaction._set_property�s�����&�&�v�.�.��8�8��z�!��#�#�E�*���#��"�"�5�)���(��!�!�%�(���!�� � ��'��1�1��2�2�5�9��/�/��/�/��6���$��$�$�U�F�3��o�o�3�3�5C�EI�5J�K�K��/�/�/�/�0G�05�16�7�
7�s�DDc
��|tk(�rMid|j�d|j�d|j�d|j�d|j
�d|j�d|j�d|j�d	|j�d
|j�d|j�d|j�d
|j�d|j�d|j�dt!j"|j$��d|j&�|j(|j*|j,|j.|j0|j2|j4|j6d��SiS)r�r%r|r/r�rqrvr�r�r�r�r?r6r�r�r��Pausedr�)r�r�rUr�rjrJrQr^)rr�r��progress_detailsr�r�status_detailsr��
term_attachedr+r5r�r�r�r�r�rjrzr�r�r�r�r��	meta_datark�download�spacer_r�s  r'rpzTransaction._get_properties�s����8�8��F�D�I�I����
�
��%�t�'<�'<��'��(>�(>���d�k�k�	�
$�T�%8�%8��"�4�#3�#3�
�'��(:�(:��%�d�&:�&:��)�$�*C�*C�� ������T�1�1���d�k�k����
�
��$�T�\�\���d�l�l�4�;�;�7�� +�D�,F�,F�!�"/3�.K�.K�!%��� $�
�
� $���$(�L�L� $�
�
�!�Z�Z�'+�';�';�1�
�6�Ir)c#�K�tj||j���}|j|k7rt	j
��y�w)z6Check if the transaction is owned by the given caller.N)r�get_uid_from_dbus_namer�r�rr)rP�	dbus_namer�s   r'r�zTransaction._check_foreign_users@�����5�5�i����J�J���8�8�s�?��+�+�-�-��s�AA	c��||_y)z3Set the kwargs which will be send to the AptWorker.N�r�)rPr�s  r'�_set_kwargszTransaction._set_kwargss	����r)c��|jr|jSd}tj|tj|�d��S)z1Get a usable translations object, no matter what.r#T)r�)r�r$r��bindtextdomain)rP�domains  r'�_get_translationszTransaction._get_translationssA������$�$�$� �F��&�&�v�w�/E�/E�f�/M�04�6�
6r)c�T�|sy|j�}t|t�|�S)zpTranslate the given message to the language of the transaction.
        Fallback to the system default.
        r5)rJ�getattr�_gettext_method)rPr&r�s   r'r$zTransaction.gettexts,��
���,�,�.��4�w�{�O�4�S�9�9r)c�R�|j�}t|t�|||�S)zwTranslate the given plural message to the language of the
        transaction. Fallback to the system default.
        )rJrL�_ngettext_method)rP�singular�plural�countr�s     r'r+zTransaction.ngettext"s+���,�,�.��5�w�{�$4�5�h���N�Nr))TNNN)�r�r�r�r�r�
ROLE_PK_QUERYr�r�$PK_ACTION_INSTALL_OR_REMOVE_PACKAGES�ROLE_REMOVE_PACKAGESr�PK_ACTION_INSTALL_FILE�ROLE_UPGRADE_PACKAGESr��ROLE_UPGRADE_SYSTEMr��PK_ACTION_UPDATE_CACHEr��ROLE_ADD_VENDOR_KEY_FILE�PK_ACTION_CHANGE_REPOSITORYr��ROLE_REMOVE_VENDOR_KEY�ROLE_FIX_INCOMPLETE_INSTALL�ROLE_FIX_BROKEN_DEPENDSr��ROLE_RECONFIGURE�
ROLE_CLEAN�PK_ACTION_CLEAN�ROLE_ENABLE_DISTRO_COMPr�r�rsr�r�r�rrr"rgr>r*r,r�r1r3r;r:r<rrCrEr�rGrMr?rOrRr@rVrYr�r[r`r_rbrf�high_trust_packagesrhrmrkrorrrrtrxr<rzr~r�r�r�r�r�r�r�r�r�r�r�r�r=r�r�r+r�r�r5rjrkr�rrrAr�r�r�rr�r�r�r�r�rr�r�r�r�r�r�r�rrr�rr!r%r)r'r1r-r�rpr�rFrJr$r+rGr)r'rrsF���#>�
���T�#>�
�#�#��;�;�#>�	�"�"��;�;�#>�	����-�-�#>�	�#�#��1�1�#>�	�!�!��1�1�#>�	����-�-�#>�	�"�"��;�;�#>� 	�&�&��2�2�##>�$	�0�0��2�2�'#>�(	�$�$��2�2�+#>�,	�)�)��;�;�/#>�0	�%�%��;�;�3#>�4	�!�!��2�2�7#>�8	����;�;�;#>�<	����&�&�?#>�@	�%�%��2�2�C#>�D	�"�"��;�;�G#>�O�J4��
@D�c"�J&��"H�<:�6����D�E�I�1���I�y�.N�O�D�H�
&� � 5�7L�%5�6��<��
�Z��1D�E�E�
H���I�y�<�>�D��9��
�}�C�E�H��3�
�Z��F�
H�E�9���
�}�*�+�H�
%�G��3�5I�$1�2�O�)�8�#�#;�#;�(5�6��
�<��|�\�6�7�G��5��k�;�:�<�F�$�D��1�3F�"@�B�N��9��
�}�E�G�H�&�N� � 5� 5�%<�=��'�J�
!�!7�!7�&0�1��!�?��+�-=� .�/�K�#�F��/�1C�"0�1�M�
%�4�
�3�5I�$+�,�O�
*�=�$�$=�$=�)I�J��
�\�\���(L�#'��)�	P�)�	P�
�\�\���(L�#&��(�E�(�E�
�\�\���(L�#'��)�
M�)�
M�
�\�\���(L�#'��)�
L�)�
L�8�6�;��;�
<�	9�
�\�\���=�&)��(0��2�"�2�"�,�>�')��)1�3�!�3�!��*��*��
��
��&��&�P����2�>�')��)1�3�$�3�$�
�D��D�8�>�')��)1�3�&�3�&��$��$�����  �"'�H<�:�>�'*�"�)1�3�4�3�4������>�'+�2�)1�3�J�3�J� �
��
��7��7�2�@�.��.��6�:�Or)rc��eZdZdZdej
jddfiZd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zed��Zy)
rzQueue for transactions.�
queue-changedNrGc���tjj|�tj�|_d|_||_i|_|jjd|j�y)z*Intialize a new TransactionQueue instance.rztransaction-doneN)
rr��collections�deque�_queue�_proc_countr�rr��_on_transaction_done)rPr�s  r'r�zTransactionQueue.__init__2sU����� � ��&�!�'�'�)�����������
������.��0I�0I�Jr)c�,�t|j�SrA)rrir!s r'�__len__zTransactionQueue.__len__<s���4�;�;��r)c�P�tjd�|jd�y)zEmit the queued-changed signal.zemitting queue changedreN)rNrO�emitr!s r'�_emit_queue_changedz$TransactionQueue._emit_queue_changed?s���	�	�*�+��	�	�/�"r)c�t�|jj|�}|j�tj|j�|j
jr1tj|_	|jj|�n|j
j|�|j�y)zAdd an item to the queue.N)rrr�rrr�r�rr�rrir�runrp)rPr�r�s   r'r�zTransactionQueue.putDs|���
�
���s�#�����(����u�0�0�1��;�;��� �/�/�E�L��K�K���u�%��K�K�O�O�E�"�� � �"r)c�b�|jtjtjfvr�|jtjk(rtj}ntj}|j
}|rM|j
|�||_tj|j�}||_	|j
}|r�M	|jj�}|jj|�|j#�y#t$rtj!d�Y�1wxYw)z2Mark the last item as done and request a new item.z"There isn't any queued transactionN)r�rr�r�EXIT_PREVIOUS_FAILEDr�r�get_role_error_from_enumr�r<ri�popleftr�rr�
IndexErrorrNrOrp)rPr�r�r��_transr&r�s       r'rkz%TransactionQueue._on_transaction_donePs���
�:�:�%�+�+�U�-A�-A�B�B��z�z�U�.�.�.��1�1���+�+���[�[�F�����F�#�"����4�4�U�Z�Z�@��(+��%������	(����,�,�.�J�
�K�K�O�O�J�'�� � �"��	�	<��I�I�:�;�	<�s�D
�
D.�-D.c�Z�|jj|�|j�y)z)Remove the specified item from the queue.N)rirrp�rP�transactions  r'rzTransactionQueue.removeis �������;�'�� � �"r)c�z�|jD]}|j��|jj�y)z Remove all items from the queue.N)rir��clearrzs  r'r}zTransactionQueue.clearns1���;�;�	;�K��8�8�:�	;������r)c�,�t|j�S)z*Return a list containing all queued items.)�listrir!s r'rrzTransactionQueue.itemsts���D�K�K� � r))r�r�r�r�r�SignalFlags�	RUN_FIRST�__gsignals__r�rmrpr�rkrr}rgrrrGr)r'rr*s`��!�#�g�&9�&9�&C�&C�&*�&(�&*�+�L�K� �#�

#�#�2#�
��!��!r)rc�8�eZdZdZd5d�Zd�Zejje	d��d��Z
ejje	d��d	��Zd
�Ze
d6d��Zee	dd
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	d
d
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	dd
d��d��Zee	d
d
d��d��Zee	d
d
d��d��Zee	d d
d��d!��Zee	dd
d��d"��Zee	d#d
d��d$��Zee	d%d
d��d&��Zee	d
d
d��d'��Z ee	ddd��d(��Z!e
d)��Z"ejjGe	dd�*�d+��Z$ejjGe	ddd,��d-��Z%ee	d.d
d��d/��Z&e
d0��Z'd1�Z(d2�Z)d3�Z*d4�Z+y)7rz�Provides a system daemon to process package management tasks.

    The daemon is transaction based. Each package management tasks runs
    in a separate transaction. The transactions can be created,
    monitored and managed via the D-Bus interface.
    Nc�P�tjd�tjtjt
j|jd�tjd�||_
d|_|durK|�tj�}||_t}	tj j#t$|d��}nd}d}t>jA|||�|jBrtE�|_#n,|jH}	ddl%m&}||jN|�|_#tS|jF�|_*|jTjWd
|jX�|jFj[�|_.tj_d�y#tj&j($r�|jj*dur*tj-d�t/j0d�tj3d	�|j5t$t�}|j7t8d
��t;j<d�tj j#t$|d��}Y���wxYw#tQ|jN|�|_#Y��|xYw)a Initialize a new AptDaemon instance.

        Keyword arguments:
        options -- command line options of the type optparse.Values
        connect -- if the daemon should connect to the D-Bus (default is True)
        bus -- the D-Bus to connect to (defaults to the system bus)
        zInitializing daemonN�T)�do_not_queueFz!Another daemon is already runningrz Replacing already running daemonr/)rI�timeout)�AptPackageKitWorkerrezDaemon was initialized)0rNr�r�unix_signal_add�
PRIORITY_HIGHr��SIGTERM�_sigquitr��nice�options�
packagekitrjr�r��APTDAEMON_DBUS_PATHrkr�rr��NameExistsExceptionr4�criticalr9r��warning�
get_object�Quit�APTDAEMON_DBUS_INTERFACE�time�sleeprFr��dummyrr��disable_plugins�worker.pkworkerr��chrootrrr�r��_on_queue_changed�is_reboot_required�_reboot_requiredrO)	rPr�r�r��bus_pathr��
the_other_guy�load_pluginsr�s	         r'r�zAptDaemon.__init__�s��	���&�'�	
���T�/�/����!�]�]�D�	2�	����
��������d�?��{��n�n�&���D�H�*�H�
C��<�<�/�/�0F�03�=A�0�C��"�H��H����D�(�H�5��=�=�%�-�D�K�&�6�6�6�L�
F�@�1�'�.�.�2>�@���&�d�k�k�2��
��
�
���?�D�,B�,B�C� $��� >� >� @����	�	�*�+��?�?�?�6�6�
C��<�<�'�'�5�0��L�L�!D�E��H�H�Q�K����>�?� #���/E�/B�!D�
��"�"�2J�+.�#�0��
�
�1�
��<�<�/�/�0F�03�=A�0�C��
C��2
F�'�����E���s�&F�J�C J�J�J%c���|jj�|jk7r;|jj�|_|jd|j�|jjj
r+|jjj
j}nd}|jjD�cgc]}|j��}}|j||�ycc}w)z)Callback for a changed transaction queue.�RebootRequiredr5N)	r�r�r�rr�r�r�rr�ActiveTransactionsChanged)rPr��currentr��queueds     r'r�zAptDaemon._on_queue_changed�s����;�;�)�)�+�t�/D�/D�D�$(�K�K�$B�$B�$D�D�!�� � �!1�4�3H�3H�I��:�:���"�"��j�j�'�'�-�-�1�1�G��G�)-���)9�)9�:��%�)�)�:��:��&�&�w��7��;s�C0r�rHc�:�tjd|�d|���yr�rMr�s   r'rzAptDaemon.PropertyChanged�s��	�	�	��%�H�Ir)�sasc�2�tjd||�y)a!The currently processed or the queued transactions changed.

        :param current: The path of the currently running transaction or
            an empty string.
        :param queued: List of the ids of the queued transactions.

        :type current: s
        :type queued: as
        z1Emitting ActiveTransactionsChanged signal: %s, %sNrM)rPr�r�s   r'r�z#AptDaemon.ActiveTransactionsChanged�s��	�	�	�E��6�	#r)c�:�|jjdur9tjd�t	j
t|j�tjd�	tj�y#t$r|jd�YywxYw)z&Start the daemon and listen for calls.FzUsing inactivity checkzWaiting for callsN)r��disable_timeoutrNrOrr�r�_check_for_inactivityr rr�KeyboardInterruptr�r!s r'rrz
AptDaemon.run�sq���<�<�'�'�5�0��I�I�.�/��$�$�%B�%)�%?�%?�
A��	�	�%�&�	��L�L�N�� �	��I�I�d�O�	�s�(A=�=B�Bc
#�ZK�tj||j���\}}}}tj�j
}	t
|	||j||||||||j��}
|
|jj|
j<t|
j�y�w)z9Helper method which returns the tid of a new transaction.)r�r�r�N)r�get_proc_info_from_dbus_namer�r�r�r�rr�rr�r)rPr�r�r�r�r�r�r�r�r�r�s           r'�
_create_transzAptDaemon._create_trans�s������9�9�&�$�(�(�K�K�	��S�#�w��j�j�l�������t�z�z�3��S�'�6��f�$�(�(�<��',��
�
������#��U�Y�Y��s�B)B+r5rUr�r�c�l�tjd�|jtj|�S)aNTry to complete cancelled installations. This is equivalent to a
        call of ``dpkg --configure -a``.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zFixIncompleteInstall() called)rNr�r�rr]r�s  r'�FixIncompleteInstallzAptDaemon.FixIncompleteInstalls*��	���0�1��!�!�%�"C�"C�V�L�Lr)c�l�tjd�|jtj|�S)a#Try to resolve unsatisfied dependencies of installed packages.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zFixBrokenDepends() called)rNr�r�rr^r�s  r'�FixBrokenDependszAptDaemon.FixBrokenDependss*��	���,�-��!�!�%�"?�"?��H�Hr)c�x�tjd�ddi}|jtj||��S)aLDownload the latest information about available packages from the
        repositories and rebuild the package cache.

        Requires the ``org.debian.apt.update-cache``
        :ref:`PolicyKit privilege <policykit>`.

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zUpdateCache() was called�sources_listNrE�rNr�r�rr�)rPr�r�s   r'�UpdateCachezAptDaemon.UpdateCache's@��	���+�,� �$�'���!�!�%�"9�"9�6�)/�"�1�	1r)c�x�tjd�d|i}|jtj||��S)aLUpdate the cache from the repositories defined in the given
        sources.list only.

        Requires the ``org.debian.apt.update-cache``
        :ref:`PolicyKit privilege <policykit>`.

        :param sources_list: The absolute path to a sources.list, e.g.
            :file:`/etc/apt/sources.list.d/ppa-aptdaemon.list` or the name
            of the snippet in :file:`/etc/apt/sources.list.d/`, e.g.
            :file:`ppa-aptdaemon.list`.
        :type sources_list: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
         z!UpdateCachePartially() was calledr�rEr�)rPr�r�r�s    r'�UpdateCachePartiallyzAptDaemon.UpdateCachePartially:s@��&	���4�5� �,�/���!�!�%�"9�"9�6�)/�"�1�	1r)rTc
��tjd|�|j|�|jtj
|gg|gggf��S)a�Remove the given packages from the system. The configuration files
        will be kept by default. Use :func:`CommitPackages()` to also purge the
        configuration files.

        Requires the ``org.debian.apt.install-or-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param package_names: packages to be removed
        :type package_names: as

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z!RemovePackages() was called: '%s'�r�)rNr��_check_package_namesr�rrU�rP�
package_namesr�s   r'�RemovePackageszAptDaemon.RemovePackagesSsU��"	���4�m�D��!�!�-�0��!�!�%�"<�"<�f�,.��M�2�r�2�+N�"�P�	Pr)rfc�z�tjd|z�|jtj|d|i��S)a�Apply all available upgrades and try to resolve conflicts.

        Requires the ``org.debian.apt.upgrade-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param safe_mode: If True only already installed packages will be
            updated. Updates which require to remove installed packages or to
            install additional packages will be skipped.

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z-UpgradeSystem() was called with safe mode: %s�	safe_moderE)rNr�r�rrX)rPr�r�s   r'�
UpgradeSystemzAptDaemon.UpgradeSystemjsI�� 	����!�"�	#��!�!�%�";�";�V�*5�y�)A�"�C�	Cr)r�c	���tjd||||||�d�}||||||fD�	cgc]
}	||	���}
}	|
D]}|j|��|jtj
||
��Scc}	w)a�Perform several package changes at the same time.

        The version number and target release of the packages can be specified
        using the traditional apt-get syntax, e.g. "xterm=281.1" to force
        installing the version 281.1 of xterm or "xterm/experimental" to
        force installing xterm from the experimental release.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param install: Packages to be installed.
        :param reinstall: Packages to be re-installed
        :param remove: Packages to be removed
        :param purge: Package to be removed including theirs configuration
            files.
        :param upgrade: Packages to be upgraded.
        :param downgrade: Packages to be downgraded. You
            have to append the target version to the package name separated
            by "="

        :type install: as
        :type reinstall: as
        :type remove: as
        :type purge: as
        :type upgrade: as
        :type downgrade: as

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z3CommitPackages() was called: %s, %s, %s, %s, %s, %sc��|dgk(rgS|S)Nr5rG)rs r'�check_empty_listz2AptDaemon.CommitPackages.<locals>.check_empty_list�s���r�d�{��	��
r)r�)rNr�r�r�rr�)rP�install�	reinstallr�purge�upgrade�	downgrader�r�r�packages_lstr�s            r'�CommitPackageszAptDaemon.CommitPackages�s���J	���F��)�V�U�G�Y�	H�	�
;B�9�:@�%�:A�:C�:E�F�#�(��-�F��F�%�	0�H��%�%�h�/�	0��!�!�%�"<�"<�f�+7�"�9�	9��
Fs�A4c
��tjd|z�|j|�|jtj
||gggggf��S)a�Fetch and install the given packages from the repositories.

        The version number and target release of the packages can be specified
        using the traditional apt-get syntax, e.g. "xterm=281.1" to force
        installing the version 281.1 of xterm or "xterm/experimental" to
        force installing xterm from the experimental release.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param package_names: Packages to be upgraded
        :type package_names: as

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z InstallPackages() was called: %sr�)rNr�r�r�rr�r�s   r'�InstallPackageszAptDaemon.InstallPackages�sX��(	���3�m�C�D��!�!�-�0��!�!�%�"=�"=�v�,9�2�r�2�r�2�+N�"�P�	Pr)c
��tjd|z�|j|�|jtj
|gggg|gf��S)a�Upgrade the given packages to their latest version.

        The version number and target release of the packages can be specified
        using the traditional apt-get syntax, e.g. "xterm=281.1" to force
        installing the version 281.1 of xterm or "xterm/experimental" to
        force installing xterm from the experimental release.

        Requires the ``org.debian.apt.upgrade-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param package_names: Packages to be upgraded
        :type package_names: as

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z UpgradePackages() was called: %sr�)rNr�r�r�rrWr�s   r'�UpgradePackageszAptDaemon.UpgradePackages�sX��(	���3�m�C�D��!�!�-�0��!�!�%�"=�"=�v�,.��B��M�2�+N�"�P�	Pr)r�c�z�tjd||�|jtj|||d���S)a%Download and install the key of a software vendor. The key is
        used to authenticate packages of the vendor.

        Requires the ``org.debian.apt.change-repositories``
        :ref:`PolicyKit privilege <policykit>`.

        :param keyid: The id of the GnuPG key (e.g. 0x0EB12F05)
        :param keyserver: The server to get the key from (e.g.
            keyserver.ubuntu.com)

        :type keyid: s
        :type keyserver: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z1InstallVendorKeyFromKeyserver() was called: %s %s)�keyid�	keyserverrE)rNr�r�rr�)rPr�r�r�s    r'�AddVendorKeyFromKeyserverz#AptDaemon.AddVendorKeyFromKeyserver�sH��(	���D��	�	#��!�!�%�"J�"J�"(�5�?H�2J�"�K�	Kr)c�z�tjd|z�|jtj|d|i��S)a�Install the key file of a software vendor. The key is
        used to authenticate packages of the vendor.

        Requires the ``org.debian.apt.change-repositories``
        :ref:`PolicyKit privilege <policykit>`.

        :param path: The absolute path to the key file.
        :type path: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z%InstallVendorKeyFile() was called: %sr�rE)rNr�r�rrZ)rPr�r�s   r'�AddVendorKeyFromFilezAptDaemon.AddVendorKeyFromFilesA�� 	���8�4�?�@��!�!�%�"@�"@�"(�&�$��"�A�	Ar)c�z�tjd|z�|jtj|d|i��S)a�Remove the given key of a software vendor. The key is used to
        authenticate packages of the vendor.

        Requires the ``org.debian.apt.change-repositories``
        :ref:`PolicyKit privilege <policykit>`.

        :param fingerprint: The fingerprint of the key.
        :type fingerprint: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z RemoveVendorKey() was called: %s�fingerprintrE)rNr�r�rr\)rPr�r�s   r'�RemoveVendorKeyzAptDaemon.RemoveVendorKeysB�� 	���3�k�A�B��!�!�%�">�">�"(�-��1M�"�O�	Or)�sbc�|�tjd|z�|jtj|||d���S)a�Install the given local package file.

        Requires the ``org.debian.apt.install-file``
        :ref:`PolicyKit privilege <policykit>`.

        :param path: The absolute path to the package file.
        :param force: If the installation of a package which violates the
            Debian/Ubuntu policy should be forced.

        :type path: s
        :type force: b

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zInstallFile() was called: %s)r��forcerE)rNr�r�rr)rPr�r�r�s    r'�InstallFilezAptDaemon.InstallFile0sH��&	���/�$�6�7��!�!�%�"9�"9�"(�$�;@�2B�"�C�	Cr)c�l�tjd�|jtj|�S)z�Remove downloaded package files.

        Requires the ``org.debian.apt.clean``
        :ref:`PolicyKit privilege <policykit>`.

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zClean() was called)rNr�r�rr`r�s  r'�CleanzAptDaemon.CleanKs*��	���%�&��!�!�%�"2�"2�F�;�;r)�assc
��tjddj|�z�|jtj
|g|gggggd|i��S)a:Reconfigure already installed packages.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param packages: List of package names which should be reconfigure.
        :param priority: The minimum debconf priority of question to be
            displayed. Can be of value "low", "medium", "high", "critical",
            "default".

        :type packages: as
        :type priority: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zReconfigure() was called: %s� �priority)r�r�)rNr��joinr�rr_)rPr�r�r�s    r'�ReconfigurezAptDaemon.Reconfigure[s[��(	���/�#�(�(�8�2D�D�E��!�!�%�"8�"8�&�,.��"�b�"�b�+I�*4�h�)?�"�A�	Ar)�sssasssc��tjd||||||�|jtj|||||||d���S)aaAdd given repository to the sources list.

        Requires the ``org.debian.apt.change-repositories``
        :ref:`PolicyKit privilege <policykit>`.

        :param src_type: The type of the repository (deb, deb-src).
        :param uri: The main repository URI
            (e.g. http://archive.ubuntu.com/ubuntu)
        :param dist: The distribution to use (e.g. stable or lenny-backports).
        :param comps: List of components (e.g. main, restricted).
        :param comment: A comment which should be added to the sources.list.
        :param sourcesfile: (Optoinal) filename in sources.list.d.

        :type src_type: s
        :type uri: s
        :type dist: s
        :type comps: as
        :type comment: s
        :type sourcesfile: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zaAddRepository() was called: type='%s' uri='%s' dist='%s' comps='%s' comment='%s' sourcesfile='%s')�src_type�uri�dist�comps�comment�sourcesfilerE)rNr�r�rr�)rPr�r�r�r�r�r�r�s        r'�
AddRepositoryzAptDaemon.AddRepositoryus`��8	���F��3��e�W�k�	C��!�!�%�";�";�V�6>�s�26��5<�9D�*F�"�G�	Gr)c�v�tjd|�|jtj|d|i��S)a�Enable the component in the distribution repositories. This will
        not affect third-party repositories.

        The repositories of a distribution are often separated into
        different components because of policy reasons. E.g. Debian uses main
        for DFSG-free software and non-free for re-distributable but not free
        in the sense of the Debian Free Software Guidelines.

        Requires the ``org.debian.apt.change-repositories``
        :ref:`PolicyKit privilege <policykit>`.

        :param component: The component, e,g, main or non-free.
        :type component: s
        :returns: The D-Bus path of the new transaction object which
            performs this action.
        z-EnableComponent() was called: component='%s' �	componentrE)rNr�r�rrb)rPr�r�s   r'�EnableDistroComponentzAptDaemon.EnableDistroComponent�s?��(	���@�)�L��!�!�%�"?�"?��*5�y�)A�"�C�	Cr)c�N�tjd�|j|�S)aGet the list of the installed vendor keys which are used to
        authenticate packages.

        Requires the ``org.debian.apt.get-trusted-vendor-keys``
        :ref:`PolicyKit privilege <policykit>`.

        :returns: Fingerprints of all installed keys.
        z!GetTrustedVendorKeys() was called)rNr��_get_trusted_vendor_keysr�s  r'�GetTrustedVendorKeyszAptDaemon.GetTrustedVendorKeys�s"��	���4�5��,�,�V�4�4r)c#�K�tj}tj|||j����|jj�}t
|�y�w)Nr�)r�!PK_ACTION_GET_TRUSTED_VENDOR_KEYSr�r�r��get_trusted_vendor_keysr)rPr�r��fingerprintss    r'r�z"AptDaemon._get_trusted_vendor_keys�sK�����=�=���4�4�V�V�9=���C�	C��{�{�:�:�<���\�"�s�AAr�c�8�tjd�|jjD�cgc]}|j��}}|jj
jr.|jj
jj}||fSd}||fScc}w)z^Return the currently running transaction and the list of queued
        transactions.
        z"GetActiveTransactions() was calledr5)rNrOr�rrr�r�r�)rPr�r�r�s    r'�GetActiveTransactionszAptDaemon.GetActiveTransactions�s���	�	�	�6�7�)-���)9�)9�:��%�)�)�:��:��:�:���"�"��j�j�'�'�-�-�1�1�G������G������;s�B�caller_namec��tjd�tjd�tj�tjd�y)z!Request a shutdown of the daemon.zQuitting was requestedzQuitting main loop...�ExitN)rNr�rOr �quit)rPr�s  r'r�zAptDaemon.Quit�s3��
	���)�*��	�	�)�*��
�
���	�	�&�r)�sssc�x�tjd�|jtj||||d���S)a�Install a license key to use a piece of proprietary software.

        Requires the ``org.debian.apt.install-or-remove-packages``
        :ref:`PolicyKit privilege <policykit>`.

        :param pkg_name: The name of the package which requires the license
        :type pkg_name: s
        :param json_token: The oauth token to use with the server in
            json format
        :type pkg_name: s
        :param server_name: The name of the server to use (ubuntu-production,
            ubuntu-staging)
        :type pkg_name: s

        :returns: The D-Bus path of the new transaction object which
            performs this action.
        zAddLicenseKey() was called)�pkg_name�
json_token�server_namerE)rNr�r�rr�)rPrrrr�s     r'�
AddLicenseKeyzAptDaemon.AddLicenseKey�sD��*	���-�.��!�!�%�"<�"<�f�6>�8B�9D�*F�"�G�	Gr)c#�(K�tj}tj|||j����|tk(�r/|dk(r0|j
j
|tj|��y
|dk(r1|j
j
|tj|�d�y
|dk(r1|j
j
|tj|�d�y
|dk(r1|j
j
|tj|�d�y
|dk(r1|j
j
|tj|�d�y
tjjd|z��tjjd	|z���w)r�r��PopConParticipation�AutoUpdateInterval�
10periodic�AutoDownload�AutoCleanInterval�UnattendedUpgrader�r8N)r�PK_ACTION_CHANGE_CONFIGr�r�r�r��
set_configrjrzrwr�r�)rPr�r]r�r�r�s      r'r�zAptDaemon._set_propertysM�����3�3���4�4�V�V�9=���C�	C��,�,��,�,����&�&�t�T�\�\�%�-@�A��-�-����&�&�t�T�Z�Z��->��M���'����&�&�t�T�\�\�%�-@�,�O��,�,����&�&�t�T�Z�Z��->��M��,�,����&�&�t�T�\�\�%�-@�,�O��o�o�3�3�5C�EI�5J�K�K��/�/�/�/�0G�05�16�7�
7�s�FFc���|D]�}t|�\}}}|jd�\}}}|dvrtjd|z��t	j
t|�stjd|z��|�2t	j
t|�stjd|z��|���t	j
t|�r��tjd|z��y)zTCheck if the package names are valid. Otherwise raise an
        exception.
        �#)r5�autoz%s isn't a valid flagz%s isn't a valid package nameNz%s isn't a valid versionz%s isn't a valid release)	r�	partitionrr8�re�match�REGEX_VALID_PACKAGENAME�REGEX_VALID_VERSION�REGEX_VALID_RELEASE)rP�	pkg_names�fullnamer]�version�release�sep�	auto_flags        r'r�zAptDaemon._check_package_namess���"�	5�H�%5�h�%?�"�D�'�7�#'�>�>�#�#6� �D�#�y���,��+�+�,C�,5�-6�7�7��8�8�3�T�:��+�+�,K�,0�-1�2�2��#����!4�g�>��+�+�,F�,3�-4�5�5��#����!4�g�>��+�+�,F�,3�-4�5�5�	5r)c	�:�|tk(�rtj|jj	d��tj
|jj	d��tj|jj	d��tj|jj	d��tj
|jj	d��tj
|jj
��d�SiS)z/Helper get the properties of a D-Bus interface.r	rrr
r)r	rrr
rr�)r�rjrwr��
get_configrzr�r�s  r'rpzAptDaemon._get_properties/s����,�,�&*�j�j��K�K�*�*�+?�@�'B� $����K�K�*�*�>�:�!<�%)�Z�Z��K�K�*�*�+>�?�&A�%)�Z�Z��K�K�*�*�+>�?�&A�'+�|�|��K�K�*�*�+@�A�(C�"&�,�,��K�K�2�2�4�#6�7�
7��Ir)c�&�|jd�y)z&Internal callback for the quit signal.N)r�)rPr�s  r'r�zAptDaemon._sigquitBs
���	�	�$�r)c��tjd�|jjj}|jjj
sst
j�j�sQtj�|z
tkDr3|js'tjd�|jd�yy)zjShutdown the daemon if it has been inactive for time specified
        in APTDAEMON_IDLE_TIMEOUT.
        zChecking for inactivityzQuitting due to inactivityNFT)
rNrOr�r��last_action_timestampr�r�main_context_default�pendingr�r	r�r�)rP�	timestamps  r'r�zAptDaemon._check_for_inactivityFs���	�	�	�+�,��J�J�%�%�;�;�	��
�
�!�!�'�'��-�-�/�7�7�9��	�	��i�'�*@�@��J�J��H�H�1�2��I�I�d�O��r))TN)NN),r�r�r�r�r�r�rjrkr�r�rr�rrrr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rpr�r�rGr)r'rrzs����<,�|8�
�\�\���(@�#'��)�	J�)�	J�
�\�\���(@�#(��*�#�*�#�
��	 ��	 ��2�')��)1�3�M�3�M��2�')��)1�3�
I�3�
I��2�')��)1�3�
1�3�
1� �2�'*�#�)1�3�1�3�1�,�2�'+�3�)1�3�P�3�P�(�2�'*�#�)1�3�C�3�C�&�2�'5�S�)1�3�19�3�19�h�2�'+�3�)1�3�P�3�P�.�2�'+�3�)1�3�P�3�P�.�2�'+�3�)1�3�K�3�K�0�2�'*�#�)1�3�A�3�A�$�2�'*�#�)1�3�O�3�O�$�2�'+�3�)1�3�C�3�C�0�2�')��)1�3�
<�3�
<��2�',�C�)1�3�A�3�A�.�2�'0��)1�3� G�3� G�F�2�'*�#�)1�3�C�3�C�,�2�')��)1�3�
5�3�
5��#��#�
�\�\���1�&(���?�
�?�
�
�\�\���1�&(��(5��7��7���2�',�C�)1�3�G�3�G�0�7��7�.5�,�&�
r)c��	tj|�S#t$r(tj|j|d��cYSwxYw)z<Convert the given string or unicode object to a dbus.String.�ignore)rjru�UnicodeDecodeError�decode)rwris  r'r
r
Vs?��<��{�{�4� � ���<��{�{�4�;�;�x��:�;�;�<�s��.A�Ac�~�t�}|jdddddtd���|jdd	ddd
td���|jdd
dddtd���|jdddddtd���|jdddddtd���|jddddddtd���|jdddddd td!���|jd"ddd#td$���|j�\}}|jd%ur$t
j
tj�nFt
j
tj�tj
tj�|jrtj�}nd}t||�&�}|jr[d'dl}|j!�}|j#|j$�|j'|j�|j)�y|j%�y)(z.Allow to run the daemon from the command line.z-tz--disable-timeoutF�
store_truer�z0Do not shutdown the daemon because of inactivity)�defaultr��dest�helpr5z--disable-pluginsr�zDo not load any pluginsz-dz--debugrOz$Show internal processing informationz-rz	--replacer4z*Quit and replace an already running daemonz
--session-bus�session_busz9Listen on the DBus session bus (Only required for testingz--chrootN�store�stringr�z&Perform operations in the given chroot)r-r�rar.r/z-pz	--profile�profilez)Store profile stats in the specified filez--dummyr�zADo not make any changes to the system (Only of use to developers)Tr�r)r�
add_optionr�
parse_argsrOrN�setLevel�logging�DEBUG�INFO�_console_handlerr0rj�
SessionBusrr3�Profile�runcallrr�
dump_stats�print_stats)�parserr��argsr��daemonr3�profilers       r'�mainrD^s?��
�^�F�
���d�/�#�)�0A��*�+��,�
���b�-�#�)�0A��6�7��9����d�I�#�)���+�,��-�
���d�K�#�)�	��&�'��(�
���b�/�#�)�
��+�,��-�
���b�*�d�$�8�(��&�'��(����d�K�#�$�8�)��$�%��&�
���i�#�)���5�6��7�
�%�%�'�M�G�T��}�}������W�]�]�#����W�\�\�"��!�!�'�,�,�/�����o�o�����
�w�C�
(�F������?�?�$��������$����G�O�O�,������
�
�r))rh)er��
__author__�__all__rg�	xml.etreer
r$�hashlibrr�r7�logging.handlers�optparserr�rr�r9r�r��
gi.repositoryrr�dbus.exceptionsrj�dbus.service�dbus.mainloop.glibr/rr5rr�deferrrr�defer.utilsrr�utilsrrr�r�worker.aptworkerrr�loopr �loggerr!rrrMrOr�r�rrrr	r
rrrr�glib�
DBusGMainLoop�putenv�	getLoggerrN�handlers�
SysLogHandler�
LOG_DAEMON�_syslog_handlerr6r9�	Formatter�_syslog_formatter�setFormatter�
addHandler�
StreamHandlerr:�_console_formatterr�	setlocale�LC_ALLr6r�r?�
excepthookr�r>rkrlrFrrrr
rDrGr)r'�<module>rfs���	�45�
�B���!���
���!�	�	�
�
���'���� ���:�:�,��2��O��$�3���;�;�#���O�!�� �O�"��+��'��)��'C�$� "�� ������A��2��+���
�
��� � �� �5�
��	�	�&�
H�J��g����$��$��&�&�4�4���!�!�/�/�:�:�5�<�O����W�\�\�*�)��)�)�+8�9��� � �!2�3��N�N�?�#�(�7�(�(�*��%�'4�&*�,�����0�1����� ��G���/�0�	�K��F���V�]�]�B�'�

5��>�>���1�1�����M�C�N�s����$�$�s�lSO�*�SO�l M!�w���M!�`Y�
�Y�x<�;��M?	����|�|�K��K�K�I�J�K�s� A9J�9J�J� K�K

Zerion Mini Shell 1.0