check if updater exists

This commit is contained in:
ingvar1995 2016-10-22 20:31:34 +03:00
parent 56d8fa1cad
commit c4843148e4
4 changed files with 27 additions and 6 deletions

View file

@ -9,7 +9,7 @@ except ImportError:
from bootstrap import node_generator
from mainscreen import MainWindow
from callbacks import init_callbacks, stop, start
from util import curr_directory, program_version
from util import curr_directory, program_version, remove
import styles.style
import platform
import toxencryptsave
@ -22,7 +22,7 @@ class Toxygen:
def __init__(self, path_or_uri=None):
super(Toxygen, self).__init__()
self.tox = self.ms = self.init = self.mainloop = self.avloop = None
self.tox = self.ms = self.init = self.app = self.tray = self.mainloop = self.avloop = None
if path_or_uri is None:
self.uri = self.path = None
elif path_or_uri.startswith('tox:'):
@ -260,7 +260,7 @@ class Toxygen:
self.tray.activated.connect(tray_activated)
updating = False
if settings['update'] and updater.connection_available(): # auto update
if settings['update'] and updater.updater_available() and updater.connection_available(): # auto update
version = updater.check_for_updates()
if version is not None:
if settings['update'] == 2:
@ -440,9 +440,7 @@ class Toxygen:
def clean():
"""Removes all windows libs from libs folder"""
d = curr_directory() + '/libs/'
for fl in ('libtox64.dll', 'libtox.dll', 'libsodium64.a', 'libsodium.a'):
if os.path.exists(d + fl):
os.remove(d + fl)
remove(d)
def configure():

View file

@ -960,6 +960,16 @@ class UpdateSettings(CenteredWidget):
msgBox.setText(text)
msgBox.exec_()
return
if not updater.updater_available():
msgBox = QtGui.QMessageBox()
msgBox.setWindowTitle(
QtGui.QApplication.translate("updateSettingsForm", "Error", None,
QtGui.QApplication.UnicodeUTF8))
text = (QtGui.QApplication.translate("updateSettingsForm", 'Updater not found', 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

@ -18,6 +18,15 @@ def connection_available():
return False
def updater_available():
if is_from_sources():
return os.path.exists(util.curr_directory() + '/toxygen_updater.py')
elif platform.system() == 'Windows':
return os.path.exists(util.curr_directory() + '/toxygen_updater.exe')
else:
return os.path.exists(util.curr_directory() + '/toxygen_updater')
def check_for_updates():
current_version = util.program_version
major, minor, patch = list(map(lambda x: int(x), current_version.split('.')))

View file

@ -30,6 +30,10 @@ def copy(src, dest):
copy(full_file_name, os.path.join(dest, file_name))
def remove(folder):
shutil.rmtree(folder)
def convert_time(t):
offset = time.timezone - time.daylight * 3600
sec = int(t) - offset