[Pkg-privacy-commits] [onionshare] 147/256: Added UpdateThread to update_checker module, which checks for updates in a separate thread. And started implementing this in the OnionShareGui class, but have no finished
Ulrike Uhlig
ulrike at moszumanska.debian.org
Fri May 26 12:53:30 UTC 2017
This is an automated email from the git hooks/post-receive script.
ulrike pushed a commit to branch master
in repository onionshare.
commit dc1418cc3b1f6c3b4bb22716e22e38424e0a170c
Author: Micah Lee <micah at micahflee.com>
Date: Sat Apr 15 19:07:02 2017 -0700
Added UpdateThread to update_checker module, which checks for updates in a separate thread. And started implementing this in the OnionShareGui class, but have no finished
---
onionshare_gui/__init__.py | 20 ++++++++++++++++----
onionshare_gui/update_checker.py | 20 +++++++++++++++++++-
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py
index 074af39..6c399bb 100644
--- a/onionshare_gui/__init__.py
+++ b/onionshare_gui/__init__.py
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import division
-import os, sys, subprocess, inspect, platform, argparse, threading, time, math, inspect, platform
+import os, sys, subprocess, inspect, platform, argparse, threading, time, math, inspect
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtCore import pyqtSlot
@@ -31,6 +31,7 @@ from .file_selection import FileSelection
from .server_status import ServerStatus
from .downloads import Downloads
from .alert import Alert
+from .update_checker import UpdateThread
class Application(QtWidgets.QApplication):
"""
@@ -38,8 +39,8 @@ class Application(QtWidgets.QApplication):
and the quick keyboard shortcut.
"""
def __init__(self):
- platform = helpers.get_platform()
- if platform == 'Linux':
+ system = platform.system()
+ if system == 'Linux':
self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
QtWidgets.QApplication.__init__(self, sys.argv)
self.installEventFilter(self)
@@ -71,9 +72,20 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.setWindowTitle('OnionShare')
self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png')))
- # the menu bar
+ # Menu bar
self.setMenuBar(Menu(self.qtapp))
+ # Check for updates in a new thread, if enabled
+ system = platform.system()
+ if system == 'Windows' or system == 'Darwin':
+ settings = Settings()
+ settings.load()
+ if settings.get('use_autoupdate'):
+ # TODO: make updates actually work
+ print("Updating in another thread")
+ #t = UpdateThread()
+ #t.start()
+
def send_files(self, filenames=None):
"""
Build the GUI in send files mode.
diff --git a/onionshare_gui/update_checker.py b/onionshare_gui/update_checker.py
index f3d3fcd..16a0f44 100644
--- a/onionshare_gui/update_checker.py
+++ b/onionshare_gui/update_checker.py
@@ -20,10 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from PyQt5 import QtCore
import datetime, time, socks, socket, re, platform
-from . import strings, helpers
from onionshare.settings import Settings
from onionshare.onion import Onion
+from . import strings, helpers
+from .alert import Alert
+
class UpdateCheckerTorError(Exception):
"""
Error checking for updates because of some Tor connection issue.
@@ -127,3 +129,19 @@ class UpdateChecker(QtCore.QObject):
# No updates are available
self.update_not_available.emit()
+
+class UpdateThread(QtCore.QThread):
+ def __init__(self):
+ super(UpdateThread, self).__init__()
+
+ def run(self):
+ u = UpdateChecker()
+ u.update_available.connect(self.update_available)
+ try:
+ u.check()
+ except:
+ # If update check fails, silently ignore
+ pass
+
+ def update_available(update_url, installed_version, latest_version):
+ Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git
More information about the Pkg-privacy-commits
mailing list