-# Copyright 2015-2016 Intel Corporation.
+# Copyright 2015-2017 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
import subprocess
import locale
import re
+import distro
from conf import settings as S
+from tools.version import Version
def match_line(file_name, pattern):
""" loops through given file and returns first line matching given pattern
:returns: Return distro name as a string
"""
- return ' '.join(platform.dist())
+ return ' '.join(distro.linux_distribution())
def get_kernel():
"""Get kernel version.
return None
# This function uses long switch per purpose, so let us suppress pylint warning too-many-branches
-# pylint: disable=R0912
+# pylint: disable=too-many-branches, too-many-statements
def get_version(app_name):
""" Get version of given application and its git tag
'loopback_testpmd' : os.path.join(S.getValue('TOOLS')['dpdk_src'],
'lib/librte_eal/common/include/rte_version.h'),
'ixnet' : os.path.join(S.getValue('TRAFFICGEN_IXNET_LIB_PATH'), 'pkgIndex.tcl'),
+ 'ixia' : os.path.join(S.getValue('TRAFFICGEN_IXIA_ROOT_DIR'), 'lib/ixTcl1.0/ixTclHal.tcl'),
}
app_version = match_line(app_version_file['ixnet'], 'package provide IxTclNetwork')
if app_version:
app_version = app_version.split(' ')[3]
+ elif app_name.lower() == 'ixia':
+ app_version = match_line(app_version_file['ixia'], 'package provide IxTclHal')
+ if app_version:
+ app_version = app_version.split(' ')[3]
elif app_name.lower() == 'xena':
try:
app_version = S.getValue('XENA_VERSION')
app_version = 'NA'
app_git_tag = 'NA'
- return {'name' : app_name, 'version' : app_version, 'git_tag' : app_git_tag}
+ return Version(app_name, app_version, app_git_tag)
def get_loopback_version(loopback_app_name):
""" Get version of given guest loopback application and its git tag
version or git tag are not known or not applicaple, than None is returned for any unknown value
"""
version = get_version("loopback_{}".format(loopback_app_name))
- version['name'] = loopback_app_name
+ version.set_value('name', loopback_app_name)
return version