diff options
Diffstat (limited to 'glances/outdated.py')
-rw-r--r-- | glances/outdated.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/glances/outdated.py b/glances/outdated.py index 74856ff4..bca7e893 100644 --- a/glances/outdated.py +++ b/glances/outdated.py @@ -2,25 +2,14 @@ # # This file is part of Glances. # -# Copyright (C) 2019 Nicolargo <nicolas@nicolargo.com> +# SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # -# Glances is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# SPDX-License-Identifier: LGPL-3.0-only # -# Glances is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. """Manage Glances update.""" from datetime import datetime, timedelta -from packaging.version import Version import threading import json import pickle @@ -32,6 +21,14 @@ from glances.globals import nativestr, urlopen, HTTPError, URLError, safe_makedi from glances.config import user_cache_dir from glances.logger import logger +try: + from packaging.version import Version + + PACKAGING_IMPORT = True +except Exception as e: + logger.warning("Unable to import 'packaging' module ({}). Glances cannot check for updates.".format(e)) + PACKAGING_IMPORT = False + PYPI_API_URL = 'https://pypi.python.org/pypi/Glances/json' @@ -51,8 +48,15 @@ class Outdated(object): # Set default value... self.data = {u'installed_version': __version__, u'latest_version': '0.0', u'refresh_date': datetime.now()} - # Read the configuration file - self.load_config(config) + + # Disable update check if `packaging` is not installed + if not PACKAGING_IMPORT: + self.args.disable_check_update = True + + # Read the configuration file only if update check is not explicitly disabled + if not self.args.disable_check_update: + self.load_config(config) + logger.debug("Check Glances version up-to-date: {}".format(not self.args.disable_check_update)) # And update ! |