From 6766735fe250a9999c4f612435eb64ee705aa94f Mon Sep 17 00:00:00 2001 From: 10se1ucgo Date: Thu, 24 Mar 2016 15:36:32 -0400 Subject: Update checker --- dwt.py | 6 +++--- dwt_about.py | 23 +++++++++++++++++++++++ dwt_util.py | 5 +++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/dwt.py b/dwt.py index 1963672..527b464 100644 --- a/dwt.py +++ b/dwt.py @@ -14,12 +14,12 @@ # # You should have received a copy of the GNU General Public License # along with DisableWinTracking. If not, see . -import os import logging import sys import io import platform import traceback +import webbrowser from ctypes import windll import wx @@ -68,7 +68,7 @@ class ConsoleDialog(wx.Dialog): self.SetSizer(top_sizer) def submit_issue(self, event): - os.startfile("https://github.com/10se1ucgo/DisableWinTracking/issues/new") + webbrowser.open_new_tab("https://github.com/10se1ucgo/DisableWinTracking/issues/new") class MainFrame(wx.Frame): @@ -236,7 +236,6 @@ class MainPanel(wx.Panel): self.Bind(wx.EVT_BUTTON, handler=self.go, source=go_button) self.SetSizer(top_sizer) - print(self.GetSize()) def select_all_apps(self, event): # Iters through all children of the wxStaticBox of the wxStaticBoxSizer and checks/un checks all wxCheckBoxes. @@ -422,5 +421,6 @@ if __name__ == '__main__': console = ConsoleDialog(sys.stdout) setup_logging() sys.excepthook = exception_hook + dwt_about.update_check(None) frame.Show() wx_app.MainLoop() diff --git a/dwt_about.py b/dwt_about.py index 1746ff0..4b9b2ec 100644 --- a/dwt_about.py +++ b/dwt_about.py @@ -16,6 +16,11 @@ # along with DisableWinTracking. If not, see . # dwt.py will become cluttered enough :^) +import json +import urllib.request +import webbrowser +from distutils.version import StrictVersion + import wx import wx.adv import wx.lib.scrolledpanel as sp @@ -158,3 +163,21 @@ class Licenses(wx.Dialog): self.scrolled_panel.SetSizerAndFit(self.scroll_sizer) self.scrolled_panel.SetupScrolling() self.Show() + + +def update_check(parent): + response = urllib.request.urlopen('https://api.github.com/repos/10se1ucgo/DisableWinTracking/releases/latest') + release = json.loads(response.read().decode()) + if release['prerelease']: + return + new = release['tag_name'] + + try: + if StrictVersion(__version__) < StrictVersion(new.lstrip('v')): + info = wx.MessageDialog(parent, message="DWT {v} is now available!\nGo to download page?".format(v=new), + caption="DWT Update", style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION) + if info.ShowModal() == wx.ID_OK: + webbrowser.open_new_tab(release['html_url']) + info.Destroy() + except ValueError: + pass diff --git a/dwt_util.py b/dwt_util.py index 85ce134..31cd033 100644 --- a/dwt_util.py +++ b/dwt_util.py @@ -21,11 +21,12 @@ import pywintypes import shutil import subprocess import tempfile -import win32serviceutil -import winerror import winreg import shlex +import win32serviceutil +import winerror + logger = logging.getLogger('dwt.util') -- cgit v1.2.3