Your IP : 216.73.216.14


Current Path : /usr/lib/python3/dist-packages/uaclient/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/uaclient/__pycache__/version.cpython-38.pyc

U

��.d<�@s�dZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
mZddlmZddlmZd	Zd
ZdZed�d
d�Zeed�dd�Zeed�dd�ZdS)z"
Client version related functions
�N)�inf)�Optional)�compare_versions� get_apt_cache_policy_for_package�get_apt_cache_time)�CANDIDATE_CACHE_PATH�UAC_RUN_PATH)�ProcessExecutionError)�subpz27.14.4z
27.14.4~20.04zCandidate: (?P<candidate>.*?)\n)�returncCsvt�d�stStj�tj�t��}tj�tj�|d��rrdddddg}zt|�\}}|�	�WSt
k
rpYnXtS)aOReturn the packaged version as a string

    Prefer the binary PACKAGED_VESION set by debian/rules to DEB_VERSION.
    If unavailable, check for a .git development environments:
      a. If run in our upstream repo `git describe` will gives a leading
         XX.Y so return the --long version to allow daily build recipes
         to count commit offset from upstream's XX.Y signed tag.
      b. If run in a git-ubuntu pkg repo, upstream tags aren't visible,
         believe __VERSION__ is correct - there is and MUST always be a
         test to make sure it matches debian/changelog
    z@@PACKAGED_VERSIONz.gitZgitZdescribez
--abbrev=8z--match=[0-9]*z--long)�PACKAGED_VERSION�
startswith�os�path�dirname�__file__�exists�joinr
�stripr	�__VERSION__)Ztopdir�cmd�out�_�r�2/usr/lib/python3/dist-packages/uaclient/version.py�get_versions

rc
Cs�t�pt}tj�t�r&t�t�j|kr�d}zZtd�}t	�
t|�}|r�|�d�}tj
tdd�ttd��}|�|�W5QRX|WSWn$tk
r�|dk	r�|YSYnXz0ttd��}|����W5QR�WSQRXWntk
r�YnXdS)Nzubuntu-advantage-tools�	candidateT)�exist_ok�w�r)rrrrrr�stat�st_mtimer�re�search�CANDIDATE_REGEX�group�makedirsr�open�write�	Exception�readr)Zlast_apt_cache_updateZcandidate_versionZpolicy�match�frrr�get_last_known_candidate1s0

��

$r-cCs t�}|rt|t�d�r|SdS)N�gt)r-rr)rrrr�check_for_new_versionPsr/)�__doc__�os.pathrr"Zmathr�typingrZuaclient.aptrrrZuaclient.defaultsrrZuaclient.exceptionsr	Zuaclient.systemr
rrr$�strrr-r/rrrr�<module>s