Fixed an issue in the versionIsNewer() method of UserInterface caused by the new versioning scheme. maintenance

Thu, 19 Jan 2017 19:45:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 19 Jan 2017 19:45:32 +0100
branch
maintenance
changeset 5431
24a4167cd14d
parent 5418
9a20eb429092
child 5432
8dded0af006d

Fixed an issue in the versionIsNewer() method of UserInterface caused by the new versioning scheme.
(grafted from bb3bebb6d6bb871ca1dd8c58c19439f92725232f)

UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/UI/UserInterface.py	Thu Jan 12 19:21:16 2017 +0100
+++ b/UI/UserInterface.py	Thu Jan 19 19:45:32 2017 +0100
@@ -41,7 +41,7 @@
     except ImportError:
         WEBENGINE_AVAILABLE = False
 
-from .Info import Version, BugAddress, Program, FeatureAddress
+from .Info import Version, VersionOnly, BugAddress, Program, FeatureAddress
 from . import Config
 
 from E5Gui.E5SingleApplication import E5SingleApplicationServer
@@ -6325,7 +6325,7 @@
         """
         if self.isOnline():
             if not manual:
-                if Version.startswith("@@"):
+                if VersionOnly.startswith("@@"):
                     return
                 else:
                     period = Preferences.getUI("PerformVersionCheck")
@@ -6485,9 +6485,9 @@
         """
         url = ""
         try:
-            if "-snapshot-" in Version:
+            if "-snapshot-" in VersionOnly:
                 # check snapshot version
-                if versions[2][0] == "6" and versions[2] > Version:
+                if versions[2][0] == "6" and versions[2] > VersionOnly:
                     res = E5MessageBox.yesNo(
                         self,
                         self.tr("Update available"),
@@ -6498,7 +6498,7 @@
                         .format(versions[2], versions[3]),
                         yesDefault=True)
                     url = res and versions[3] or ''
-                elif versions[0] > Version:
+                elif versions[0] > VersionOnly:
                     res = E5MessageBox.yesNo(
                         self,
                         self.tr("Update available"),
@@ -6519,7 +6519,7 @@
                                 """ eric6"""))
             else:
                 # check release version
-                if versions[0] > Version:
+                if versions[0] > VersionOnly:
                     res = E5MessageBox.yesNo(
                         self,
                         self.tr("Update available"),
@@ -6640,19 +6640,47 @@
         @return flag indicating, that the version is newer than the required
             one (boolean)
         """
-        if Version.startswith("@@"):
+        if VersionOnly.startswith("@@"):
             # development version, always newer
             return True
         
-        if "-snapshot-" in Version:
+        if VersionOnly.startswith("rev_"):
+            # installed from cloned sources, always newer
+            return True
+        
+        if "-snapshot-" in VersionOnly:
             # check snapshot version
             if snapshot is None:
                 return True
             else:
-                vers = Version.split("-snapshot-")[1]
-                return vers.split()[0] > snapshot
-        
-        return Version.split()[0] > required
+                vers = VersionOnly.split("-snapshot-")[1]
+                return vers > snapshot
+        
+        versionTuple = self.__versionToTuple(VersionOnly)
+        if isinstance(required, str):
+            required = self.__versionToTuple(required)
+        return versionTuple > required
+    
+    def __versionToTuple(self, version):
+        """
+        Private method to convert a version string into a tuple.
+        
+        @param version version string
+        @type str
+        @return version tuple
+        @rtype tuple of int and str
+        """
+        versionParts = []
+        for part in version.split("."):
+            part = part.strip()
+            if part:
+                try:
+                    part = int(part)
+                except ValueError:
+                    # not an integer
+                    pass
+                versionParts.append(part)
+        return tuple(versionParts)
     
     #################################
     ## Below are some utility methods

eric ide

mercurial