Skip to content
Snippets Groups Projects

add option --path-to-project to lb-run

Merged Marco Clemencic requested to merge clemenci/LbScripts:LBCORE-1078 into master
+ 70
13
Compare changes
  • Side-by-side
  • Inline
Files
@@ -24,6 +24,8 @@ class NotFoundError(Error):
'''
Generic error for configuration elements that are not found.
'''
def __str__(self):
return 'cannot find {0}'.format(self.args[0])
class MissingManifestError(NotFoundError):
'''
@@ -61,21 +63,29 @@ def findProject(name, version, platform, allow_empty_version=False):
@param allow_empty_version: if True, we allow also the plain project name (without version)
@return path to the project binary directory
If name is None, version should be the path to the top directory of the project.
'''
log.debug('findProject(name=%r, version=%r, platform=%r, '
'allow_empty_version=%r)',
name, version, platform, allow_empty_version)
# standard project suffixes
suffixes = ['{0}_{1}'.format(name, version),
os.path.join(name.upper(), '{0}_{1}'.format(name.upper(), version)),
os.path.join(name.upper(), version),]
# special case: for the 'latest' version we allow the plain name
if allow_empty_version:
suffixes.insert(0, name)
if name:
# standard project suffixes
suffixes = ['{0}_{1}'.format(name, version),
os.path.join(name.upper(), '{0}_{1}'.format(name.upper(), version)),
os.path.join(name.upper(), version),]
# special case: for the 'latest' version we allow the plain name
if allow_empty_version:
suffixes.insert(0, name)
else:
# path to project used, no need for suffixes
suffixes = [os.curdir]
for d in [os.path.join(b, s, bindir)
for b in path
# if project name is None, version is the path to the top level directory
# of the project
for d in [os.path.normpath(os.path.join(b, s, bindir))
for b in (path if name else [version])
for s in suffixes
for bindir in (os.path.join('InstallArea', platform),
os.curdir)]:
@@ -290,3 +300,20 @@ def getLCGRelocation(manifest):
'LCG_releases_base': dirname(lcg_path)
if lcg_path.endswith('LCG_%s' % version)
else lcg_path}
def getProjectNameVersion(manifest):
'''
Get project name and version from a manifest.xml.
'''
from xml.dom.minidom import parse
log.debug('extracting project name from %s', manifest)
name, version = None, None
try:
m = parse(manifest)
project = m.getElementsByTagName('project')[0]
name = project.getAttribute('name')
version = project.getAttribute('version')
except (IndexError, AttributeError), exc:
log.debug('cannot extract project name or version: %s', exc)
return name, version
Loading