Skip to content
Snippets Groups Projects

Fixed sorting of listed versions in lb-dev/lb-run

Merged Marco Clemencic requested to merge clemenci/LbScripts:LBCORE-1001 into master
+ 22
5
Compare changes
  • Side-by-side
  • Inline
Files
@@ -11,11 +11,12 @@
__author__ = 'Marco Clemencic <marco.clemencic@cern.ch>'
import os
import re
import logging
# FIXME: when we drop Python 2.4, this should become 'from . import path'
from LbConfiguration.SP2 import path, Error
from LbConfiguration.SP2.version import DEFAULT_VERSION, expandVersionAlias
from LbConfiguration.SP2.version import DEFAULT_VERSION, versionKey
log = logging.getLogger(__name__)
@@ -121,7 +122,7 @@ def listVersions(name, platform):
for filename in files
if filename.startswith(prefix) and
isValidVersion(name, filename[prefixlen:])],
reverse=True):
reverse=True, key=versionKey):
version, fullpath = entry
if (version not in found_versions and
os.path.isdir(os.path.join(fullpath, bindir))):
@@ -136,7 +137,7 @@ def listVersions(name, platform):
if filename.startswith(prefix_u) and
isValidVersion(name,
filename[prefixlen:])],
reverse=True):
reverse=True, key=versionKey):
version, fullpath = entry
if (version not in found_versions and
os.path.isdir(os.path.join(fullpath, bindir))):
@@ -173,8 +174,7 @@ def findDataPackage(name, version):
if not versions:
raise MissingDataPackageError(name, version, path)
# sort the versions found
versions.sort(key=lambda x: tuple(map(int, findall(r'\d+', x[0]))),
reverse=True)
versions.sort(key=versionKey, reverse=True)
v, p = versions[0]
return os.path.join(p, v)
Loading