2016-02-25 05:49:18 -06:00
# -*- coding: utf-8 -*-
2019-08-19 10:02:05 -05:00
import sys
2016-02-25 05:49:18 -06:00
import application
import platform
import logging
import output
from requests . exceptions import ConnectionError
2019-01-01 19:42:53 -06:00
from . import update
from . wxUpdater import *
2016-02-25 05:49:18 -06:00
logger = logging . getLogger ( " updater " )
2018-12-27 09:29:46 -06:00
def do_update ( update_type = " stable " ) :
2019-08-19 10:02:05 -05:00
# Updates cannot be performed in the source code version of Socializer.
if hasattr ( sys , " frozen " ) == False :
return
2018-12-27 09:29:46 -06:00
if update_type == " stable " :
endpoint = application . update_stable_url
version = application . version
else :
endpoint = application . update_next_url
version = application . update_next_version
2016-02-25 05:49:18 -06:00
try :
2018-12-27 09:29:46 -06:00
return update . perform_update ( endpoint = endpoint , current_version = version , app_name = application . name , update_type = update_type , update_available_callback = available_update_dialog , progress_callback = progress_callback , update_complete_callback = update_finished )
2016-02-25 05:49:18 -06:00
except ConnectionError :
logger . exception ( " Update failed. " )
output . speak ( " An exception occurred while attempting to update " + application . name + " . If this message persists, contact the " + application . name + " developers. More information about the exception has been written to the error log. " , True )