def _check_paths(name, paths): for p in paths: exe = path.join(p, name) if path.isfile(exe): return True if os.name == 'nt': if path.isfile('%s.exe' % (exe)): return True return False
def _find_covoar(self): covoar_exe = 'covoar' tester_dir = path.dirname(path.abspath(sys.argv[0])) base = path.dirname(tester_dir) exe = path.join(self.prefix, 'share', 'rtems', 'tester', 'bin', covoar_exe) if path.isfile(exe): return exe exe = path.join(base, 'build', 'tester', 'covoar', covoar_exe) if path.isfile(exe): return exe raise error.general('coverage: %s not found'% (covoar_exe))
def find_executables(files): executables = [] for f in files: if not path.isfile(f): raise error.general('executable is not a file: %s' % (f)) executables += [f] return sorted(executables)
def __init__(self, index, total, report, executable, rtems_tools, bsp, bsp_config, opts): self.index = index self.total = total self.report = report self.bsp = bsp self.bsp_config = bsp_config self.opts = copy.copy(opts) self.opts.defaults['test_index'] = str(index) self.opts.defaults['test_total'] = str(total) self.opts.defaults['bsp'] = bsp self.opts.defaults['bsp_arch'] = '%%{%s_arch}' % (bsp) self.opts.defaults['bsp_opts'] = '%%{%s_opts}' % (bsp) if not path.isfile(executable): raise error.general('cannot find executable: %s' % (executable)) self.opts.defaults['test_executable'] = executable self.opts.defaults['test_executable_name'] = path.basename(executable) if rtems_tools: rtems_tools_bin = path.join(self.opts.defaults.expand(rtems_tools), 'bin') if not path.isdir(rtems_tools_bin): raise error.general('cannot find RTEMS tools path: %s' % (rtems_tools_bin)) self.opts.defaults['rtems_tools'] = rtems_tools_bin self.config = config.file(self.report, self.bsp_config, self.opts)
def find_executables(paths, glob): executables = [] for p in paths: if path.isfile(p): executables += [p] elif path.isdir(p): for root, dirs, files in os.walk(p, followlinks = True): for f in files: if fnmatch.fnmatch(f.lower(), glob): executables += [path.join(root, f)] return sorted(executables)
def find_executables(paths): executables = [] for p in paths: if path.isfile(p): executables += [p] elif path.isdir(p): for root, dirs, files in os.walk(p, followlinks = True): for f in files: if f.lower().endswith('.exe'): executables += [path.join(root, f)] return sorted(executables)
def find_executables(paths, glob): executables = [] for p in paths: if path.isfile(p): executables += [p] elif path.isdir(p): for root, dirs, files in os.walk(p, followlinks=True): for f in files: if fnmatch.fnmatch(f.lower(), glob): executables += [path.join(root, f)] return sorted(executables)
def __call__(self, parser, namespace, value, option_string=None): current = getattr(namespace, self.dest) if not isinstance(current, list) and current is not None: raise argparse.ArgumentError( self, ' already provided: %s, have %s' % (value, current)) if not path.isfile(value): raise argparse.ArgumentError(self, 'is not a valid file: %s' % (value)) if not path.isreadable(value): raise argparse.ArgumentError(self, 'is not readable: %s' % (value)) if current is not None: value = current + [value] setattr(namespace, self.dest, value)
def find_executables(paths, glob): executables = [] for p in paths: if path.isfile(p): executables += [p] elif path.isdir(p): for root, dirs, files in os.walk(p, followlinks=True): for f in files: if fnmatch.fnmatch(f.lower(), glob): executables += [path.join(root, f)] norun = re.compile('.*\.norun.*') executables = [e for e in executables if not norun.match(e)] return sorted(executables)
def _check_exe(_opts, macro, value, constraint, silent=False): if len(value) == 0 or constraint == 'none': return True orig_value = value if path.isabspath(value): if path.isfile(value): return True if os.name == 'nt': if path.isfile('%s.exe' % (value)): return True value = path.basename(value) absexe = True else: absexe = False paths = os.environ['PATH'].split(os.pathsep) if _check_paths(value, paths): if absexe: if not silent: log.notice( 'warning: exe: absolute exe found in path: (%s) %s' % (macro, orig_value)) return True if constraint == 'optional': if not silent: log.trace('warning: exe: optional exe not found: (%s) %s' % (macro, orig_value)) return True if not silent: log.notice('error: exe: not found: (%s) %s' % (macro, orig_value)) return False
def __call__(self, parser, namespace, value, option_string=None): current = getattr(namespace, self.dest) if current is None: current = [] if isinstance(value, list): values = value else: values = [values] for value in values: if not path.isfile(value) and not path.isdir(value): err = 'is not a valid file or directory: %s' % (value) raise argparse.ArgumentError(self, err) if not path.isreadable(value): raise argparse.ArgumentError(self, 'is not readable: %s' % (value)) current += [value] setattr(namespace, self.dest, current)
def __init__(self, index, total, report, executable, rtems_tools, bsp, bsp_config, opts): self.index = index self.total = total self.report = report self.bsp = bsp self.bsp_config = bsp_config self.opts = copy.copy(opts) self.opts.defaults['test_index'] = str(index) self.opts.defaults['test_total'] = str(total) self.opts.defaults['bsp'] = bsp self.opts.defaults['bsp_arch'] = '%%{%s_arch}' % (bsp) self.opts.defaults['bsp_opts'] = '%%{%s_opts}' % (bsp) if not path.isfile(executable): raise error.general('cannot find executable: %s' % (executable)) self.opts.defaults['test_executable'] = executable if rtems_tools: rtems_tools_bin = path.join(self.opts.defaults.expand(rtems_tools), 'bin') if not path.isdir(rtems_tools_bin): raise error.general('cannot find RTEMS tools path: %s' % (rtems_tools_bin)) self.opts.defaults['rtems_tools'] = rtems_tools_bin self.config = config.file(self.report, self.bsp_config, self.opts)