U
    dT                     @   s   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 ejZ
dd ZeZed ed ed ed	 ed
 G dd dZdS )    )print_functionN)PIPEc                 C   s   | S N )er   r   </usr/lib/python3/dist-packages/softwareproperties/AptAuth.pydummy$       r   z;Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>z:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>zBUbuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>zAUbuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>zBUbuntu Extras Archive Automatic Signing Key <ftpmaster@ubuntu.com>c                   @   s>   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd ZdS )AptAuth/c              	   C   sf   || _ t | _tj| jd| _t| jd}|	d| j   W 5 Q R X | jtj
d< t| j d S )Nzapt.confwz
DIR "%s";
Z
APT_CONFIG)rootdirtempfileZmkdtemptmpdirospathjoinZaptconfopenwriteenvironatexitregister_cleanup_tmpdir)selfr   fr   r   r   __init__/   s    
zAptAuth.__init__c                 C   s   t | j d S r   )shutilZrmtreer   )r   r   r   r   r   8   s    zAptAuth._cleanup_tmpdirc           	      C   s   dddddddg}g }t j|ttdd	j}d
}|D ]p}|d}|d dkrT|d }|d dkr|d }tjt|d 	 }|sq2|
d||t|f  d
}q2|  |S )N/usr/bin/apt-key--quietZadvz--with-colonsz--batchz--fixed-list-modez--list-keysT)stdoutstderrZuniversal_newlines :r   )pubZuid	   r#         z%s %s
%s)
subprocessPopenr   r   splitdatetimedateZfromtimestampintZ	isoformatappend_close)	r   cmdrespnamelineZfieldskeyZexpiryr   r   r   list;   s"    
zAptAuth.listc                 C   s(   dddd|g}t j|td}| dkS )Nr   r   
--fakerootaddr    r   r'   r(   r   wait)r   filenamer0   r2   r   r   r   r8   N   s    zAptAuth.addc                 C   s&   ddddg}t j|td}| dkS )Nr   r   r7   updater9   r   r:   )r   r0   r2   r   r   r   r=   S   s    zAptAuth.updatec                 C   s(   dddd|g}t j|td}| dkS )Nr   r   r7   rmr9   r   r:   )r   r5   r0   r2   r   r   r   r>   X   s    z
AptAuth.rmN)r   )	__name__
__module____qualname__r   r   r6   r8   r=   r>   r   r   r   r   r
   .   s   
	r
   )Z
__future__r   r   r*   gettextr   r   r'   r   r   r.   r   ZN_r
   r   r   r   r   <module>   s"   