From 5a4c0f83da084c211ed424ea40b6f64efe71e425 Mon Sep 17 00:00:00 2001 From: lxnay Date: Sat, 26 Jul 2008 07:22:05 +0000 Subject: [PATCH] Entropy/entropyTools: - compareVersions() do not raise an exception when ver1 or ver2 are None git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2313 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropyTools.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index c6789c319..425608e02 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -333,6 +333,8 @@ def getfd(filespec, readOnly = 0): def execWithRedirect(argv, stdin = 0, stdout = 1, stderr = 2, root = '/', newPgrp = 0, ignoreTermSigs = 0): + import signal + childpid = os.fork() etpSys['killpids'].add(childpid) if (not childpid): @@ -1069,13 +1071,21 @@ def compareVersions(ver1, ver2): if ver1 == ver2: return 0 #mykey=ver1+":"+ver2 - match1 = ver_regexp.match(ver1) - match2 = ver_regexp.match(ver2) + match1 = None + match2 = None + if ver1: + match1 = ver_regexp.match(ver1) + if ver2: + match2 = ver_regexp.match(ver2) # checking that the versions are valid - if not match1 or not match1.groups(): + if not match1: return None,0 - if not match2 or not match2.groups(): + elif not match1.groups(): + return None,0 + elif not match2: + return None,1 + elif not match2.groups(): return None,1 # building lists of the version parts before the suffix