3
Eo�c� � @ s� d Z ddlmZmZ ddlZddlZddlZddlZddlmZ ddl m
Z
ddlmZm
Z
mZmZ ddlmZ ddlmZ dd lmZ ydd
lmZ dZW n6 ek
r� Z zejdje�� d
ZW Y ddZ[X nX dZG dd� de�ZdS )zManage Glances update.� )�datetime� timedeltaN)�CertificateError)�__version__)� nativestr�urlopen� HTTPError�URLError)�user_cache_dir)�
safe_makedirs)�logger)�VersionTzKUnable to import 'packaging' module ({}). Glances cannot check for updates.Fz)https://pypi.python.org/pypi/Glances/jsonc @ s` e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dS )�Outdatedz�
This class aims at providing methods to warn the user when a new Glances
version is available on the PyPI repository (https://pypi.python.org/pypi/Glances/).
c C sp || _ || _t� | _tjj| jd�| _tdt j
� d�| _| j|� t
sNd| j _tjdj| j j �� | j� dS )zInit the Outdated classzglances-version.dbz0.0)�installed_version�latest_version�refresh_dateTz$Check Glances version up-to-date: {}N)�args�configr
� cache_dir�os�path�join�
cache_filer r �now�data�load_config�PACKAGING_IMPORT�disable_check_updater �debug�format�get_pypi_version)�selfr r � r"