o
    Û1j0  ã                   @   s4   d dl Z d dlmZ d dlmZ G dd„ deƒZdS )é    N)ÚUploadTarget)ÚUbuntuPolicyc                       s`   e Zd ZdZdZdZdZdZdZd‡ fdd„	Z	d	d
„ Z
d‡ fdd„	Zdd„ Z‡ fdd„Z‡  ZS )ÚUbuntuUploadTargetzUbuntu Upload TargetÚ	canonicalz,https://files.support.canonical.com/uploads/ÚubuntuÚputNc                    s   t ƒ j|||d� d S )N)ÚparserÚargsÚcmdline)ÚsuperÚ__init__)Úselfr   r	   r
   ©Ú	__class__© ú;/usr/lib/python3/dist-packages/sos/upload/targets/ubuntu.pyr      s   zUbuntuUploadTarget.__init__c                 C   s   t | jd tƒS )z1 Return true if we are running in a Ubuntu systemÚpolicy)Ú
isinstanceÚcommonsr   ©r   r   r   r   Úcheck_distribution   s   z%UbuntuUploadTarget.check_distributionc                    s$   | j  | j¡r| j| jfS tƒ  ¡ S ©N)Ú
upload_urlÚ
startswithÚ_upload_urlÚ_upload_userÚ_upload_passwordr   Úget_upload_https_auth)r   ÚuserÚpasswordr   r   r   r      s   
z(UbuntuUploadTarget.get_upload_https_authc                 C   s    | j  | j¡r	dS |  |  ¡ ¡S )NzCanonical Support File Server)r   r   r   Ú_get_obfuscated_upload_urlÚget_upload_urlr   r   r   r   Úget_upload_url_string"   s   z(UbuntuUploadTarget.get_upload_url_stringc                    sB   | j r
| j  | j¡r| js| jS tj | j¡}| j| S tƒ  ¡ S r   )	r   r   r   Úupload_archive_nameÚosÚpathÚbasenamer   r!   )r   Úfnamer   r   r   r!   '   s   

z!UbuntuUploadTarget.get_upload_url)NNN)NN)Ú__name__Ú
__module__Ú__qualname__Úupload_target_nameÚupload_target_idr   r   r   Ú_upload_methodr   r   r   r"   r!   Ú__classcell__r   r   r   r   r      s    r   )r$   Úsos.upload.targetsr   Úsos.policies.distros.ubuntur   r   r   r   r   r   Ú<module>   s   