mirror of https://github.com/ARMmbed/mbed-os.git
Midified way singletest script is checking for installed modules required by test suite
parent
dd973760c1
commit
ccac8f8339
|
|
@ -47,27 +47,26 @@ File format example: muts_all.json:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# Check if 'prettytable' module is installed
|
# Be sure that the tools directory is in the search path
|
||||||
try:
|
|
||||||
from prettytable import PrettyTable
|
|
||||||
except ImportError, e:
|
|
||||||
print "Error: Can't import 'prettytable' module: %s"% e
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
# Check if 'serial' module is installed
|
|
||||||
try:
|
|
||||||
from serial import Serial
|
|
||||||
except ImportError, e:
|
|
||||||
print "Error: Can't import 'serial' module: %s"% e
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from os.path import join, abspath, dirname
|
from os.path import join, abspath, dirname
|
||||||
|
|
||||||
# Be sure that the tools directory is in the search path
|
|
||||||
ROOT = abspath(join(dirname(__file__), ".."))
|
ROOT = abspath(join(dirname(__file__), ".."))
|
||||||
sys.path.insert(0, ROOT)
|
sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
|
|
||||||
|
# Check: Extra modules which are required by core test suite
|
||||||
|
from workspace_tools.utils import check_required_modules
|
||||||
|
|
||||||
|
if not check_required_modules(['prettytable', 'serial']):
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
|
|
||||||
|
# We can import this extra modules
|
||||||
|
from serial import Serial
|
||||||
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
|
|
||||||
# Imports related to mbed build api
|
# Imports related to mbed build api
|
||||||
from workspace_tools.build_api import mcu_toolchain_matrix
|
from workspace_tools.build_api import mcu_toolchain_matrix
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
from subprocess import Popen, PIPE, STDOUT, call
|
|
||||||
from os import listdir, remove, makedirs
|
from os import listdir, remove, makedirs
|
||||||
from os.path import isdir, join, exists, split, relpath, splitext
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
from os.path import isdir, join, exists, split, relpath, splitext
|
||||||
|
from subprocess import Popen, PIPE, STDOUT, call
|
||||||
|
|
||||||
|
|
||||||
def cmd(l, check=True, verbose=False, shell=False, cwd=None):
|
def cmd(l, check=True, verbose=False, shell=False, cwd=None):
|
||||||
|
|
@ -37,8 +37,7 @@ def run_cmd(command, wd=None, redirect=False):
|
||||||
|
|
||||||
|
|
||||||
def run_cmd_ext(command):
|
def run_cmd_ext(command):
|
||||||
import subprocess
|
p = Popen(command, stdout=PIPE, stderr=PIPE)
|
||||||
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
_stdout, _stderr = p.communicate()
|
_stdout, _stderr = p.communicate()
|
||||||
return _stdout, _stderr, p.returncode
|
return _stdout, _stderr, p.returncode
|
||||||
|
|
||||||
|
|
@ -99,3 +98,25 @@ def args_error(parser, message):
|
||||||
def construct_enum(**enums):
|
def construct_enum(**enums):
|
||||||
""" Create your own pseudo-enums """
|
""" Create your own pseudo-enums """
|
||||||
return type('Enum', (), enums)
|
return type('Enum', (), enums)
|
||||||
|
|
||||||
|
|
||||||
|
def check_required_modules(required_modules, verbose=True):
|
||||||
|
""" Function checks for Python modules which should be "importable" (installed)
|
||||||
|
before test suite can be used.
|
||||||
|
@return returns True if all modules are installed already
|
||||||
|
"""
|
||||||
|
import imp
|
||||||
|
all_modules_found = True
|
||||||
|
not_installed_modules = []
|
||||||
|
for module_name in required_modules:
|
||||||
|
try:
|
||||||
|
imp.find_module(module_name)
|
||||||
|
except ImportError as e:
|
||||||
|
all_modules_found = False
|
||||||
|
not_installed_modules.append(module_name)
|
||||||
|
if verbose:
|
||||||
|
print "Error message: %s"% e
|
||||||
|
if verbose:
|
||||||
|
if not all_modules_found:
|
||||||
|
print "Module(s) %s not installed. Please install required module(s) before using this script."% (', '.join(not_installed_modules))
|
||||||
|
return all_modules_found
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue