diff --git a/src/calibre/gui2/update.py b/src/calibre/gui2/update.py index 3e294cac3..580f736ef 100644 --- a/src/calibre/gui2/update.py +++ b/src/calibre/gui2/update.py @@ -1,19 +1,17 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -import re, binascii, cPickle, ssl, json +import binascii, cPickle from future_builtins import map from threading import Thread, Event from PyQt5.Qt import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout, - QLabel, QCheckBox, QDialogButtonBox, QIcon) + QLabel, QDialogButtonBox, QIcon) -from calibre.constants import (__appname__, __version__, iswindows, isosx, - isportable, is64bit, numeric_version) +from calibre.constants import (__appname__, iswindows, isosx, + isportable, is64bit) from calibre import prints, as_unicode -from calibre.utils.config import prefs -from calibre.utils.https import get_https_resource_securely -from calibre.gui2 import config, dynamic, open_url +from calibre.gui2 import dynamic, open_url from calibre.gui2.dialogs.plugin_updater import get_plugin_updates_available URL = 'https://code.calibre-ebook.com/latest' @@ -30,35 +28,7 @@ def get_download_url(): def get_newest_version(): - try: - icon_theme_name = json.loads(I('icon-theme.json', data=True))['name'] - except Exception: - icon_theme_name = '' - headers={ - 'CALIBRE-VERSION':__version__, - 'CALIBRE-OS': ('win' if iswindows else 'osx' if isosx else 'oth'), - 'CALIBRE-INSTALL-UUID': prefs['installation_uuid'], - 'CALIBRE-ICON-THEME': icon_theme_name, - } - try: - version = get_https_resource_securely(URL, headers=headers) - except ssl.SSLError as err: - if getattr(err, 'reason', None) != 'CERTIFICATE_VERIFY_FAILED': - raise - # certificate verification failed, since the version check contains no - # critical information, ignore and proceed - # We have to do this as if the calibre CA certificate ever - # needs to be revoked, then we wont be able to do version checks - version = get_https_resource_securely(URL, headers=headers, cacerts=None) - try: - version = version.decode('utf-8').strip() - except UnicodeDecodeError: - version = u'' - ans = NO_CALIBRE_UPDATE - m = re.match(ur'(\d+)\.(\d+).(\d+)$', version) - if m is not None: - ans = tuple(map(int, (m.group(1), m.group(2), m.group(3)))) - return ans + return NO_CALIBRE_UPDATE class Signal(QObject): @@ -81,12 +51,6 @@ class CheckForUpdates(Thread): calibre_update_version = NO_CALIBRE_UPDATE plugins_update_found = 0 try: - version = get_newest_version() - if version[:2] > numeric_version[:2]: - calibre_update_version = version - except Exception as e: - prints('Failed to check for calibre update:', as_unicode(e)) - try: update_plugins = get_plugin_updates_available(raise_error=True) if update_plugins is not None: plugins_update_found = len(update_plugins) @@ -200,22 +164,15 @@ class UpdateMixin(object): self.status_bar.update_label.setText(msg) self.status_bar.update_label.setVisible(True) - if has_calibre_update: - if (force or (config.get('new_version_notification') and - dynamic.get('update to version %s'%calibre_version, True))): - if not no_show_popup: - self._update_notification__ = UpdateNotification(calibre_version, - number_of_plugin_updates, parent=self) - self._update_notification__.show() - elif has_plugin_updates: - if force: - from calibre.gui2.dialogs.plugin_updater import (PluginUpdaterDialog, - FILTER_UPDATE_AVAILABLE) - d = PluginUpdaterDialog(self, - initial_filter=FILTER_UPDATE_AVAILABLE) - d.exec_() - if d.do_restart: - self.quit(restart=True) + if has_plugin_updates: + if force: + from calibre.gui2.dialogs.plugin_updater import (PluginUpdaterDialog, + FILTER_UPDATE_AVAILABLE) + d = PluginUpdaterDialog(self, + initial_filter=FILTER_UPDATE_AVAILABLE) + d.exec_() + if d.do_restart: + self.quit(restart=True) def plugin_update_found(self, number_of_updates): # Change the plugin icon to indicate there are updates available