Module: check_mk
Branch: master
Commit: fa7c6459c9b95098ca2e542fe915f389e239a387
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa7c6459c9b950…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 19 07:32:01 2018 +0100
Moved cmp_version() from lib to utils
Change-Id: I7478a2d6837dc9c5c95813e45b647644dd62e115
---
web/htdocs/lib.py | 8 --------
web/htdocs/werks.py | 5 +++--
web/plugins/views/inventory.py | 4 ++--
web/plugins/visuals/inventory.py | 7 ++++---
4 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 7a57927..3c37a73 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -156,11 +156,3 @@ def num_split(s):
parts.append(part)
return tuple(parts)
-
-
-def cmp_version(a, b):
- if a == None or b == None:
- return cmp(a, b)
- aa = map(tryint, a.split("."))
- bb = map(tryint, b.split("."))
- return cmp(aa, bb)
diff --git a/web/htdocs/werks.py b/web/htdocs/werks.py
index 8e86a45..05cc0d2 100644
--- a/web/htdocs/werks.py
+++ b/web/htdocs/werks.py
@@ -27,6 +27,7 @@
# Functions for parsing Werks and showing the users a browsable change
# log
+import utils
import config, os, table
import re
from lib import *
@@ -376,10 +377,10 @@ def werk_matches_options(werk, werk_table_options):
return False
from_version, to_version = werk_table_options["version"]
- if from_version and cmp_version(werk["version"], from_version) < 0:
+ if from_version and utils.cmp_version(werk["version"], from_version) <
0:
return False
- if to_version and cmp_version(werk["version"], to_version) > 0:
+ if to_version and utils.cmp_version(werk["version"], to_version) > 0:
return False
if werk_table_options["content"]:
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index 68604fb..dce6a50 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -749,9 +749,9 @@ inventory_displayhints.update({
".software.packages:*.arch" : { "title" :
_("Architecture"), },
".software.packages:*.package_type" : { "title" :
_("Type"), },
".software.packages:*.summary" : { "title" :
_("Description"), },
- ".software.packages:*.version" : { "title" :
_("Version"), "sort" : visuals.cmp_version, "filter" :
visuals.FilterInvtableVersion },
+ ".software.packages:*.version" : { "title" :
_("Version"), "sort" : utils.cmp_version, "filter" :
visuals.FilterInvtableVersion },
".software.packages:*.vendor" : { "title" :
_("Publisher"), },
- ".software.packages:*.package_version" : { "title" :
_("Package Version"), "sort" : visuals.cmp_version, "filter"
: visuals.FilterInvtableVersion },
+ ".software.packages:*.package_version" : { "title" :
_("Package Version"), "sort" : utils.cmp_version, "filter" :
visuals.FilterInvtableVersion },
".software.packages:*.install_date" : { "title" :
_("Install Date"), "paint" : "date"},
".software.packages:*.size" : { "title" :
_("Size"), "paint" : "count" },
".software.packages:*.path" : { "title" :
_("Path"), },
diff --git a/web/plugins/visuals/inventory.py b/web/plugins/visuals/inventory.py
index 45ae28d..facba90 100644
--- a/web/plugins/visuals/inventory.py
+++ b/web/plugins/visuals/inventory.py
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import utils
import inventory
import cmk.defines as defines
@@ -316,9 +317,9 @@ class FilterInvtableVersion(Filter):
new_rows = []
for row in rows:
version = row.get(self.name, "")
- if from_version and cmp_version(version, from_version) == -1:
+ if from_version and utils.cmp_version(version, from_version) == -1:
continue
- if to_version and cmp_version(version, to_version) == 1:
+ if to_version and utils.cmp_version(version, to_version) == 1:
continue
new_rows.append(row)
@@ -546,7 +547,7 @@ class FilterInvHasSoftwarePackage(Filter):
return a != b and not self.version_is_higher(a, b)
def version_is_higher(self, a, b):
- return cmp_version(a, b) == 1
+ return utils.cmp_version(a, b) == 1
declare_filter(801, FilterInvHasSoftwarePackage())