3

Q'ícOã@sÖddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZmZddlmZddlmZmZddlmZmZdd	lmZd
ZejeƒZGdd„deƒZGd
d„deƒ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ú1/tmp/pip-build-l_bcah40/pip/pip/utils/outdated.pyÚ__init__sz!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 ttt
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}|jt
ƒ|dœ|tj<t	|jdƒ}t
j||dddWdQRXWdQRXdS)N)r r!rTr"r#)r$r%)r"r#)rrrÚdirnamerr
rÚLockFileÚexistsrrrr'r(rrr&)rr!r)rrrrrr*=s
zGlobalSelfCheckState.saveN)r+r,r-rr*rrrrr.2s
r.cCstƒrtƒStƒSdS)N)r	r
r.rrrrÚload_selfcheck_statefileXsr3c
Cs:tdƒ}|dkrdStj|ƒ}d}yîtƒ}tjjƒ}d|jkrvd|jkrvtjj|jdtƒ}t	||ƒdkrv|jd}|dkrÎ|j
tjdd	id
}|j
ƒdd„tt|jƒd
ƒtjdDƒd}|j||ƒtj|ƒ}||koê|j|jkrtrúd}	nd}	tjd|||	ƒWn$tk
r4tjddd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.
    ÚpipNr r!ééé<ÚAcceptzapplication/json)ÚheaderscSsg|]}tj|ƒjs|‘qSr)Úpackaging_versionÚparseÚ
is_prerelease)Ú.0Úvrrrú
<listcomp>‚sz%pip_version_check.<locals>.<listcomp>Úreleases)Ú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€:	éÿÿÿÿ)rr:r;r3ÚdatetimeÚutcnowrÚstrptimer(rÚgetrÚpip_json_urlÚraise_for_statusÚsortedÚlistrr*Úbase_versionrÚloggerÚwarningÚ	ExceptionÚdebug)
ÚsessionÚinstalled_versionÚpip_versionr!rr)r ÚrespÚremote_versionÚpip_cmdrrrÚpip_version_check_sJ



rY)#Ú
__future__rrFrÚloggingÚos.pathrrÚpip._vendorrZpip._vendor.packagingrr:Ú
pip.compatrrÚ
pip.modelsrÚ
pip.locationsrr	Ú	pip.utilsr
rÚpip.utils.filesystemrr(Ú	getLoggerr+rOÚobjectr
r.r3rYrrrrÚ<module>s$
&