def print_cmdline(task_description, property_file): task_description = task_def_file.name + " " + task_description with log_if_unsupported("task from " + task_description): cmdline = model.cmdline_for_run( tool, executable, [], input_files, task_def_file.name, property_file, copy.deepcopy(task.get("options")), no_limits, ) print_list("Command line for " + task_description, cmdline)
def print_tool_info(name): print_value('Name of tool module', name) tool_module, tool = model.load_tool_info(name) print_value('Full name of tool module', tool_module) print_value('Name of tool', tool.name()) executable = tool.executable() print_value('Executable', executable) if not os.path.isabs(executable): print_value('Executable (absolute path)', os.path.abspath(executable)) try: print_value('Version', tool.version(executable)) except: logging.warning('Determining version failed:', exc_info=1) working_directory = tool.working_directory(executable) print_value('Working directory', working_directory) if not os.path.isabs(working_directory): print_value('Working directory (absolute path)', os.path.abspath(working_directory)) program_files = list(tool.program_files(executable)) if program_files: print_multiline_list('Program files', program_files) print_multiline_list('Program files (absolute paths)', map(os.path.abspath, program_files)) else: logging.warning('Tool module specifies no program files.') environment = tool.environment(executable) new_environment = environment.pop('newEnv', {}) if new_environment: print_multiline_list('Additional environment variables', ('{}={}'.format(variable, value) for (variable, value) in new_environment.items())) append_environment = environment.pop('additionalEnv', {}) if append_environment: print_multiline_list('Appended environment variables', ('{}=${{{}}}{}'.format(variable, variable, value) for (variable, value) in append_environment.items())) if environment: logging.warning( 'Tool module returned invalid entries for environment, these will be ignored: “%s”', environment) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], None, {}) print_list('Minimal command line', cmdline) if not 'INPUT.FILE' in ' '.join(cmdline): logging.warning('Tool module ignores input file.') except: logging.warning('Tool module does not support tasks without options, ' 'property file, and resource limits:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, ['-SOME_OPTION'], ['INPUT.FILE'], None, {}) print_list('Command line with parameter', cmdline) if not '-SOME_OPTION' in cmdline: logging.warning('Tool module ignores command-line options.') except: logging.warning('Tool module does not support tasks with command-line options:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], 'PROPERTY.PRP', {}) print_list('Command line with property file', cmdline) if not 'PROPERTY.PRP' in ' '.join(cmdline): logging.warning('Tool module ignores property file.') except: logging.warning('Tool module does not support tasks with property file:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT1.FILE', 'INPUT2.FILE'], None, {}) print_list('Command line with multiple input files', cmdline) if 'INPUT1.FILE' in ' '.join(cmdline) and not 'INPUT2.FILE' in ' '.join(cmdline): logging.warning('Tool module ignores all but first input file.') except: logging.warning('Tool module does not support tasks with multiple input files:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], None, {model.SOFTTIMELIMIT: 123}) print_list('Command line CPU-time limit', cmdline) except: logging.warning('Tool module does not support tasks with CPU-time limit:', exc_info=1) return tool
def print_tool_info(tool): print_multiline_text("Documentation of tool module", inspect.getdoc(tool)) print_value("Name of tool", tool.name()) executable = tool.executable() print_value("Executable", executable) if not os.path.isabs(executable): print_value("Executable (absolute path)", os.path.abspath(executable)) else: logging.warning( "Path to executable is absolute, this might be problematic " "in scenarios where runs are distributed to other machines.") try: print_value("Version", tool.version(executable)) except: logging.warning("Determining version failed:", exc_info=1) working_directory = tool.working_directory(executable) print_value("Working directory", working_directory) if not os.path.isabs(working_directory): print_value("Working directory (absolute path)", os.path.abspath(working_directory)) program_files = list(tool.program_files(executable)) if program_files: print_multiline_list("Program files", program_files) print_multiline_list("Program files (absolute paths)", map(os.path.abspath, program_files)) else: logging.warning("Tool module specifies no program files.") environment = tool.environment(executable) new_environment = environment.pop("newEnv", {}) if new_environment: print_multiline_list( "Additional environment variables", ("{}={}".format(variable, value) for (variable, value) in new_environment.items()), ) append_environment = environment.pop("additionalEnv", {}) if append_environment: print_multiline_list( "Appended environment variables", ("{}=${{{}}}{}".format(variable, variable, value) for (variable, value) in append_environment.items()), ) if environment: logging.warning( "Tool module returned invalid entries for environment, these will be ignored: “%s”", environment, ) with log_if_unsupported( "tasks without options, property file, and resource limits"): cmdline = model.cmdline_for_run(tool, executable, [], ["INPUT.FILE"], None, {}) print_list("Minimal command line", cmdline) if not "INPUT.FILE" in " ".join(cmdline): logging.warning("Tool module ignores input file.") with log_if_unsupported("tasks with command-line options"): cmdline = model.cmdline_for_run(tool, executable, ["-SOME_OPTION"], ["INPUT.FILE"], None, {}) print_list("Command line with parameter", cmdline) if not "-SOME_OPTION" in cmdline: logging.warning("Tool module ignores command-line options.") with log_if_unsupported("tasks with property file"): cmdline = model.cmdline_for_run(tool, executable, [], ["INPUT.FILE"], "PROPERTY.PRP", {}) print_list("Command line with property file", cmdline) if not "PROPERTY.PRP" in " ".join(cmdline): logging.warning("Tool module ignores property file.") with log_if_unsupported("tasks with multiple input files"): cmdline = model.cmdline_for_run(tool, executable, [], ["INPUT1.FILE", "INPUT2.FILE"], None, {}) print_list("Command line with multiple input files", cmdline) if "INPUT1.FILE" in " ".join( cmdline) and not "INPUT2.FILE" in " ".join(cmdline): logging.warning("Tool module ignores all but first input file.") with log_if_unsupported("tasks with CPU-time limit"): cmdline = model.cmdline_for_run(tool, executable, [], ["INPUT.FILE"], None, {model.SOFTTIMELIMIT: 123}) print_list("Command line CPU-time limit", cmdline) return tool
def print_standard_task_cmdlines(tool, executable): """Print command lines resulting from a few different dummy tasks""" no_limits = CURRENT_BASETOOL.ResourceLimits() with log_if_unsupported( "tasks without options, property file, and resource limits" ): cmdline = model.cmdline_for_run( tool, executable, [], ["INPUT.FILE"], None, None, None, no_limits ) print_list("Minimal command line", cmdline) if "INPUT.FILE" not in " ".join(cmdline): logging.warning("Tool module ignores input file.") with log_if_unsupported("tasks with command-line options"): cmdline = model.cmdline_for_run( tool, executable, ["-SOME_OPTION"], ["INPUT.FILE"], None, None, None, no_limits, ) print_list("Command line with parameter", cmdline) if "-SOME_OPTION" not in cmdline: logging.warning("Tool module ignores command-line options.") with log_if_unsupported("tasks with property file"): cmdline = model.cmdline_for_run( tool, executable, [], ["INPUT.FILE"], None, "PROPERTY.PRP", None, no_limits ) print_list("Command line with property file", cmdline) if "PROPERTY.PRP" not in " ".join(cmdline): logging.warning("Tool module ignores property file.") with log_if_unsupported("tasks with multiple input files"): cmdline = model.cmdline_for_run( tool, executable, [], ["INPUT1.FILE", "INPUT2.FILE"], None, None, None, no_limits, ) print_list("Command line with multiple input files", cmdline) if "INPUT1.FILE" in " ".join(cmdline) and "INPUT2.FILE" not in " ".join( cmdline ): logging.warning("Tool module ignores all but first input file.") with log_if_unsupported("tasks with CPU-time limit"): cmdline = model.cmdline_for_run( tool, executable, [], ["INPUT.FILE"], None, None, None, CURRENT_BASETOOL.ResourceLimits(cputime=123), ) print_list("Command line CPU-time limit", cmdline) with log_if_unsupported("SV-Benchmarks task"): cmdline = model.cmdline_for_run( tool, executable, [], ["INPUT.FILE"], None, "PROPERTY.PRP", {"language": "C", "data_model": "ILP32"}, CURRENT_BASETOOL.ResourceLimits(cputime=900, cputime_hard=1000), ) print_list("Command line SV-Benchmarks task", cmdline) # This will return the last command line that did not trigger an exception return cmdline
def print_tool_info(name): print_value('Name of tool module', name) tool_module, tool = model.load_tool_info(name) print_value('Full name of tool module', tool_module) print_value('Name of tool', tool.name()) executable = tool.executable() print_value('Executable', executable) if not os.path.isabs(executable): print_value('Executable (absolute path)', os.path.abspath(executable)) try: print_value('Version', tool.version(executable)) except: logging.warning('Determining version failed:', exc_info=1) working_directory = tool.working_directory(executable) print_value('Working directory', working_directory) if not os.path.isabs(working_directory): print_value('Working directory (absolute path)', os.path.abspath(working_directory)) program_files = list(tool.program_files(executable)) if program_files: print_multiline_list('Program files', program_files) print_multiline_list('Program files (absolute paths)', map(os.path.abspath, program_files)) else: logging.warning('Tool module specifies no program files.') environment = tool.environment(executable) new_environment = environment.pop('newEnv', {}) if new_environment: print_multiline_list( 'Additional environment variables', ('{}={}'.format(variable, value) for (variable, value) in new_environment.items())) append_environment = environment.pop('additionalEnv', {}) if append_environment: print_multiline_list( 'Appended environment variables', ('{}=${{{}}}{}'.format(variable, variable, value) for (variable, value) in append_environment.items())) if environment: logging.warning( 'Tool module returned invalid entries for environment, these will be ignored: “%s”', environment) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], None, {}) print_list('Minimal command line', cmdline) if not 'INPUT.FILE' in ' '.join(cmdline): logging.warning('Tool module ignores input file.') except: logging.warning( 'Tool module does not support tasks without options, ' 'property file, and resource limits:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, ['-SOME_OPTION'], ['INPUT.FILE'], None, {}) print_list('Command line with parameter', cmdline) if not '-SOME_OPTION' in cmdline: logging.warning('Tool module ignores command-line options.') except: logging.warning( 'Tool module does not support tasks with command-line options:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], 'PROPERTY.PRP', {}) print_list('Command line with property file', cmdline) if not 'PROPERTY.PRP' in ' '.join(cmdline): logging.warning('Tool module ignores property file.') except: logging.warning( 'Tool module does not support tasks with property file: %s', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT1.FILE', 'INPUT2.FILE'], None, {}) print_list('Command line with multiple input files', cmdline) if 'INPUT1.FILE' in ' '.join( cmdline) and not 'INPUT2.FILE' in ' '.join(cmdline): logging.warning('Tool module ignores all but first input file.') except: logging.warning( 'Tool module does not support tasks with multiple input files:', exc_info=1) try: cmdline = model.cmdline_for_run(tool, executable, [], ['INPUT.FILE'], None, {model.SOFTTIMELIMIT: 123}) print_list('Command line CPU-time limit', cmdline) except: logging.warning( 'Tool module does not support tasks with CPU-time limit:', exc_info=1) return tool