Sindbad~EG File Manager
3
�Pfe�@s�ddlmZddlZddlZddlZddlZddlZddlm Z ddl
mZddl
mZmZddlmZddlmZmZddlmZmZdd lmZd
Zeje�ZGdd�de�ZGd
d�de�Z dd�Z!dd�Z"dd�Z#dS)�)�absolute_importN)�lockfile)�version)�
total_seconds�WINDOWS)�PyPI)�USER_CACHE_DIR�running_under_virtualenv)�
ensure_dir�get_installed_version)�check_path_ownerz%Y-%m-%dT%H:%M:%SZc@seZdZdd�Zdd�ZdS)�VirtualenvSelfCheckStatecCs\tjjtjd�|_y&t|j��}tj|�|_ WdQRXWnt
tfk
rVi|_ YnXdS)Nzpip-selfcheck.json)�os�path�join�sys�prefix�statefile_path�open�json�load�state�IOError�
ValueError)�self� statefile�r�/usr/lib/python3.6/outdated.py�__init__sz!VirtualenvSelfCheckState.__init__c
Cs:t|jd��$}tj|jt�|d�|ddd�WdQRXdS)N�w)�
last_check�pypi_versionT�,�:)� sort_keys�
separators)r"r#)rrr�dump�strftime�SELFCHECK_DATE_FMT)rr!�current_timerrrr�save$szVirtualenvSelfCheckState.saveN)�__name__�
__module__�__qualname__rr*rrrrr
s
r
c@seZdZdd�Zdd�ZdS)�GlobalSelfCheckStatecCsbtjjtd�|_y,t|j��}tj|�tj |_
WdQRXWn ttt
fk
r\i|_
YnXdS)Nzselfcheck.json)rrrrrrrrrrrrr�KeyError)rrrrrr3s zGlobalSelfCheckState.__init__cCs�ttjj|j��sdSttjj|j��tj|j��ztjj|j�rft |j��}t
j|�}WdQRXni}|jt
�|d�|tj<t |jd��}t
j||ddd�WdQRXWdQRXdS)N)r r!rTr"r#)r$r%)r"r#)rrr�dirnamerr
rZLockFile�existsrrrr'r(rrr&)rr!r)rrrrrr*=s
zGlobalSelfCheckState.saveN)r+r,r-rr*rrrrr.2s
r.cCst�rt�St�SdS)N)r r
r.rrrr�load_selfcheck_statefileXsr2cCsFddl}y"|jd�}|jd�o*d|jd�kS|jk
r@dSXdS)z�Checks whether pip was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
rN�pipZ INSTALLERF)�
pkg_resourcesZget_distributionZhas_metadataZget_metadata_linesZDistributionNotFound)r4Zdistrrr�pip_installed_by_pip_s
r5c
CsFtd�}|dkrdStj|�}d}�y�t�}tjj�}d|jkrxd|jkrxtjj|jdt�}t ||�dkrx|jd}|dkr�|j
tjdd id
�}|j
�dd�tt|j�d
�tjd�D�d}|j||�tj|�}||k�r|j|jk�rt��rt�rd} nd} tjd||| �Wn$tk
�r@tjddd�YnXdS)z�Check for an update for pip.
Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.
r3Nr r!���<ZAcceptzapplication/json)ZheaderscSsg|]}tj|�js|�qSr)�packaging_version�parseZ
is_prerelease)�.0�vrrr�
<listcomp>�sz%pip_version_check.<locals>.<listcomp>Zreleases)�key�z
python -m pipz�You are using pip version %s, however version %s is available.
You should consider upgrading via the '%s install --upgrade pip' command.z5There was an error checking the latest version of pipT)�exc_info�i`'i�: ���)rr9r:r2�datetimeZutcnowrZstrptimer(r�getrZpip_json_urlZraise_for_status�sorted�listrr*Zbase_versionr5r�loggerZwarning� Exception�debug)
ZsessionZinstalled_versionZpip_versionr!rr)r ZrespZremote_versionZpip_cmdrrr�pip_version_checknsL
rJ)$Z
__future__rrCrZloggingZos.pathrrZpip._vendorrZpip._vendor.packagingrr9Z
pip.compatrrZ
pip.modelsrZ
pip.locationsrr Z pip.utilsr
rZpip.utils.filesystemrr(Z getLoggerr+rG�objectr
r.r2r5rJrrrr�<module>s&
&
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists