diff --git a/AdmDialogs.py b/AdmDialogs.py
index 08cddc1..8b20eb7 100644
--- a/AdmDialogs.py
+++ b/AdmDialogs.py
@@ -1,5 +1,5 @@
# The Admin4 Project
-# (c) 2013-2014 Andreas Pflug
+# (c) 2013-2022 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
@@ -183,14 +183,17 @@ def Go(self):
self.Proxy=adm.proxy
self['UpdateCheckPeriod'].Append( [ (1, xlt("daily")), (7, xlt('weekly')), (30, xlt('monthly')), (0, xlt('never')) ] )
self.UpdateCheckPeriod=adm.updateCheckPeriod
+ self.AllowPrereleases=adm.allowPrereleases
def Save(self):
adm.confirmDeletes=self.ConfirmDeletes
adm.updateCheckPeriod=self.UpdateCheckPeriod
+ adm.allowPrereleases=self.AllowPrereleases
adm.proxy=self.Proxy
adm.config.Write("ConfirmDeletes", adm.confirmDeletes)
adm.config.Write("UpdateCheckPeriod", adm.updateCheckPeriod)
+ adm.config.Write("AllowPrereleases", adm.allowPrereleases)
adm.config.Write("Proxy", adm.proxy)
return True
@@ -198,6 +201,7 @@ def Save(self):
def Init():
adm.confirmDeletes=adm.config.Read("ConfirmDeletes", True)
adm.updateCheckPeriod=adm.config.Read("UpdateCheckPeriod", 7)
+ adm.allowPrereleases=adm.config.Read("AllowPrereleases", False)
adm.proxy=adm.config.Read("Proxy")
diff --git a/Preferences.xrc b/Preferences.xrc
index 5ef7792..72824bd 100644
--- a/Preferences.xrc
+++ b/Preferences.xrc
@@ -30,6 +30,18 @@
+
+
+
+
+ wxALIGN_CENTRE_VERTICAL
+
+
+
+
+ 1
+
+
@@ -47,4 +59,4 @@
-
\ No newline at end of file
+
diff --git a/Update.py b/Update.py
index 65c3dfa..cebc0f8 100644
--- a/Update.py
+++ b/Update.py
@@ -12,50 +12,101 @@
from xmlhelp import Document as XmlDocument
import time, threading, subprocess
-try:
- import Crypto.PublicKey.RSA, Crypto.Hash.SHA, Crypto.Signature.PKCS1_v1_5
-except:
- Crypto=None
+Crypto=None
onlineTimeout=5
+FORCE_UPDATECHECK=False # used while developing
class UpdateThread(threading.Thread):
def __init__(self, frame):
self.frame=frame
threading.Thread.__init__(self)
+
+
+ def OnUpdate(self, _evt=None):
+ lines=[]
+ lines.append(xlt("New version: %s") % adm.updateInfo.release['tag_name'])
+ lines.append(adm.updateInfo.release['body'].replace('\r', ''))
+ lines.append(xlt("Please visit the releases website at"))
+ lines.append(admVersion.RELEASE_URL)
+ dlg=wx.MessageDialog(self.frame, "\n".join(lines), caption=xlt("Update available"))
+ dlg.ShowModal()
def run(self):
- # currently no update check
- return
-
- update=OnlineUpdate()
+ update=GithubUpdateCheck()
if update.IsValid():
adm.updateInfo=update
if update.UpdateAvailable():
- wx.CallAfter(self.frame.OnUpdate)
+ wx.CallAfter(self.OnUpdate)
elif update.exception:
wx.CallAfter(wx.MessageBox,
xlt("Connection error while trying to retrieve update information from the update server.\nCheck network connectivity and proxy settings!"),
xlt("Communication error"), wx.ICON_EXCLAMATION)
-
+
+
def CheckAutoUpdate(frame):
if adm.updateCheckPeriod:
if not admVersion.revDate:
return
lastUpdate=adm.config.Read('LastUpdateCheck', 0)
- if not lastUpdate or lastUpdate+adm.updateCheckPeriod*24*60*60 < time.time():
+ if FORCE_UPDATECHECK or not lastUpdate or lastUpdate+adm.updateCheckPeriod*24*60*60 < time.time():
thread=UpdateThread(frame)
thread.start()
+class GithubUpdateCheck():
+ def __init__(self):
+ self.info=None
+ self.release=None
+ try:
+ response=requests.get(admVersion.RELEASE_CHECK_URL, timeout=onlineTimeout, proxies=adm.GetProxies())
+ self.info=response.json()
+ except Exception as ex:
+ self.exception = ex
+ self.message=xlt("Online update check failed.\n\nError reported:\n %s") % str(ex)
+ return
+ adm.config.Write('LastUpdateCheck', time.time())
+
+ def IsValid(self):
+ return self.info != None
+
+ def UpdateAvailable(self):
+ if self.info:
+ localVersion=admVersion.version
+ localMainVersion=localVersion[:localVersion.find('rc')]
+ localRC=(localVersion!=localMainVersion)
+ for release in self.info:
+ if not adm.allowPrereleases and release.get('prerelease'):
+ continue
+ if True:
+ upstreamVersion=release['tag_name']
+ upstreamMainVersion=upstreamVersion[:upstreamVersion.find(('rc'))]
+ upstreamRC=(upstreamVersion!=upstreamMainVersion)
+
+ if localMainVersion > upstreamMainVersion: # strange: local version is newer
+ return False
+ elif localMainVersion == upstreamMainVersion:
+ if not localRC: # already release
+ return False
+ if upstreamRC:
+ if localVersion >= upstreamVersion:
+ return False
+ self.release=release
+ return True
+
+ return False
+
+
+#################################################################
+# deprecated
+
def HttpGet(url, timeout=onlineTimeout):
# We're verifying all contents ourself using the admin4 public key
response=requests.get(url, timeout=timeout, proxies=adm.GetProxies(), verify=False)
response.raise_for_status()
return response
-
class OnlineUpdate:
startupCwd=os.getcwd()
diff --git a/UpdateDlg.xrc b/UpdateDlg.xrc
index e568d69..04e755e 100644
--- a/UpdateDlg.xrc
+++ b/UpdateDlg.xrc
@@ -96,14 +96,14 @@
- wxLEFT|wxRIGHT|wxALIGN_RIGHT
+ wxLEFT|wxRIGHT
10
- wxALIGN_RIGHT
+
wxTOP|wxBOTTOM|wxLEFT|wxRIGHT|wxGROW
@@ -111,4 +111,4 @@
-
\ No newline at end of file
+
diff --git a/adm.py b/adm.py
index 90d80fc..3f31267 100644
--- a/adm.py
+++ b/adm.py
@@ -36,6 +36,7 @@
confirmDeletes=True
updateCheckPeriod=7
+allowPrereleases=False
proxy=None
config=None
diff --git a/config.py b/config.py
index c30ff06..5ca674f 100644
--- a/config.py
+++ b/config.py
@@ -1,5 +1,5 @@
# The Admin4 Project
-# (c) 2013-2014 Andreas Pflug
+# (c) 2013-2022 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
diff --git a/version.py b/version.py
index c187b2b..e83b95b 100644
--- a/version.py
+++ b/version.py
@@ -58,15 +58,19 @@ def __eq__(self, cmp):
def __ne__(self, cmp):
return self.fullver() != cmp.fullver()
-version=Version(version)
-
requiredAdmVersion=Version(requiredAdmVersion)
libVersion=Version("3.0.0")
appName="Admin4"
-description="4th generation\nAdministration Tool\n\nHelp and manual: http://www.admin4.org/docs"
+RELEASE_CHECK_URL="https://api.github.com/repos/andreas-p/admin4/releases"
+RELEASE_URL="https://github.com/andreas-p/admin4/releases"
+
+description="""4th generation Administration Tool
+
+Help and manual: http://www.admin4.org/docs
+Releases: %s""" % RELEASE_URL
vendor="PSE"
vendorDisplay="PSE Consulting"
copyright="(c) 2013-2022 PSE Consulting Andreas Pflug"