Port socializer to Python 3. #16

This commit is contained in:
2019-01-02 04:42:53 +03:00
parent 1aeab0aef5
commit 4442931dd4
68 changed files with 967 additions and 1006 deletions

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import application
import update
import platform
import logging
import output
from requests.exceptions import ConnectionError
from wxUpdater import *
from . import update
from .wxUpdater import *
logger = logging.getLogger("updater")
def do_update(update_type="stable"):

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def convert_bytes(n):
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
@@ -24,19 +25,19 @@ def seconds_to_string(seconds, precision=0):
sec_string = sec.__format__(sec_spec)
string = ""
if day == 1:
string += _(u"%d day, ") % day
string += _("%d day, ") % day
elif day >= 2:
string += _(u"%d days, ") % day
string += _("%d days, ") % day
if (hour == 1):
string += _(u"%d hour, ") % hour
string += _("%d hour, ") % hour
elif (hour >= 2):
string += _("%d hours, ") % hour
if (min == 1):
string += _(u"%d minute, ") % min
string += _("%d minute, ") % min
elif (min >= 2):
string += _(u"%d minutes, ") % min
string += _("%d minutes, ") % min
if sec >= 0 and sec <= 2:
string += _(u"%s second") % sec_string
string += _("%s second") % sec_string
else:
string += _(u"%s seconds") % sec_string
string += _("%s seconds") % sec_string
return string

View File

@@ -1,19 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import unicode_literals
import wx
import application
import utils
from . import utils
progress_dialog = None
def available_update_dialog(version, description):
dialog = wx.MessageDialog(None, _(u"There's a new %s version available. Would you like to download it now?\n\n %s version: %s\n\nChanges:\n%s") % (application.name, application.name, version, description), _(u"New version for %s") % application.name, style=wx.YES|wx.NO|wx.ICON_WARNING)
dialog = wx.MessageDialog(None, _("There's a new %s version available. Would you like to download it now?\n\n %s version: %s\n\nChanges:\n%s") % (application.name, application.name, version, description), _("New version for %s") % application.name, style=wx.YES|wx.NO|wx.ICON_WARNING)
if dialog.ShowModal() == wx.ID_YES:
return True
else:
return False
def create_progress_dialog():
return wx.ProgressDialog(_(u"Download in Progress"), _(u"Downloading the new version..."), parent=None, maximum=100)
return wx.ProgressDialog(_("Download in Progress"), _("Downloading the new version..."), parent=None, maximum=100)
def progress_callback(total_downloaded, total_size):
wx.CallAfter(_progress_callback, total_downloaded, total_size)
@@ -26,7 +28,7 @@ def _progress_callback(total_downloaded, total_size):
if total_downloaded == total_size:
progress_dialog.Destroy()
else:
progress_dialog.Update((total_downloaded*100)/total_size, _(u"Updating... %s of %s") % (str(utils.convert_bytes(total_downloaded)), str(utils.convert_bytes(total_size))))
progress_dialog.Update((total_downloaded*100)/total_size, _("Updating... %s of %s") % (utils.convert_bytes(total_downloaded), utils.convert_bytes(total_size)))
def update_finished():
return wx.MessageDialog(None, _(u"The update has been downloaded and installed successfully. Press OK to continue."), _(u"Done!")).ShowModal()
return wx.MessageDialog(None, _("The update has been downloaded and installed successfully. Press OK to continue."), _("Done!")).ShowModal()