updater fixes

This commit is contained in:
ingvar1995 2016-10-15 19:47:02 +03:00
parent ecf045182a
commit 1e6201b3fa
4 changed files with 20 additions and 2 deletions

View file

@ -260,7 +260,7 @@ class Toxygen:
self.tray.activated.connect(tray_activated)
updating = False
if settings['update']: # auto update
if settings['update'] and updater.connection_available(): # auto update
version = updater.check_for_updates()
if version is not None:
if settings['update'] == 2:

View file

@ -950,6 +950,16 @@ class UpdateSettings(CenteredWidget):
settings.save()
def update_client(self):
if not updater.connection_available():
msgBox = QtGui.QMessageBox()
msgBox.setWindowTitle(
QtGui.QApplication.translate("updateSettingsForm", "Error", None,
QtGui.QApplication.UnicodeUTF8))
text = (QtGui.QApplication.translate("updateSettingsForm", 'Problems with internet connection', None,
QtGui.QApplication.UnicodeUTF8))
msgBox.setText(text)
msgBox.exec_()
return
version = updater.check_for_updates()
if version is not None:
updater.download(version)

View file

@ -68,7 +68,6 @@ class PluginLoader(util.Singleton):
"""
New incoming custom lossless packet (callback)
"""
print('Custom', data)
l = data[0] - pl.LOSSLESS_FIRST_BYTE
name = ''.join(chr(x) for x in data[1:l + 1])
if name in self._plugins and self._plugins[name][1]:

View file

@ -2,6 +2,7 @@ import util
import os
import settings
import platform
import urllib
try:
from PySide import QtNetwork, QtCore
except ImportError:
@ -9,6 +10,14 @@ except ImportError:
import subprocess
def connection_available():
try:
urllib.request.urlopen('http://216.58.192.142', timeout=1) # google.com
return True
except:
return False
def check_for_updates():
current_version = util.program_version
major, minor, patch = list(map(lambda x: int(x), current_version.split('.')))