def on_complete(self, pypy=None): if self.log_file: IO.write(self.log_file, self.content) # finish after update if self.update_format and (not self.complete_format and not self.color_complete_format): printf.finish_rewrite() # print regular messages for fmt in ensure_iterable(self.complete_format): printf.out(fmt, monitor=self) # print messages if error if self.pypy.with_error(): for fmt in ensure_iterable(self.error_complete_format): printf.error(fmt, monitor=self) # print regular color messages based on result for fmt in ensure_iterable(self.color_complete_format): if self.pypy.returncode() == 0: printf.success(fmt, monitor=self) elif self.pypy.returncode() is None: printf.warning(fmt, monitor=self) else: printf.error(fmt, monitor=self) with printf: if printf.verbosity() is printf.OutputVerbosity.FULL: printf.sep() printf.out('Output from file {self.pypy.full_output}'.format( **locals())) printf.opt(raw=True).stream( format_n_lines(self.content, pypy.was_successful())) elif printf.verbosity( ) is printf.OutputVerbosity.SMART and pypy.with_error(): printf.sep() printf.out( 'Last 50 lines from file {self.pypy.full_output}'.format( **locals())) printf.opt(raw=True).stream( format_n_lines(self.content, success=False, n_lines=-50)) elif printf.verbosity( ) is printf.OutputVerbosity.MINIMAL and pypy.with_error(): printf.sep() printf.out( 'Last 50 lines from file {self.pypy.full_output}'.format( **locals())) printf.opt(raw=True).stream( format_n_lines(self.content, success=False, n_lines=-50))
def __init__(self, command, name='exec-thread'): super(BinExecutor, self).__init__(name) BinExecutor.threads.append(self) self.command = [str(x) for x in ensure_iterable(command)] self.process = None self.broken = False self.output = OutputMode.hidden_output()
def __init__(self, command, name='exec-thread'): super(BinExecutor, self).__init__(name) BinExecutor.threads.append(self) self.command = [str(x) for x in ensure_iterable(command)] self.process = None self.broken = False self.output = OutputMode.hidden_output() self.exception = "Unknown error"
def on_update(self, pypy=None): self._check_limits() if self.terminated: return for fmt in ensure_iterable(self.update_format): if printf.tty(): printf.rewrite(fmt, monitor=self) else: printf.out(fmt, monitor=self)
def get_args(): global arg_options, arg_others, arg_rest proc = ensure_iterable(arg_options.get('cpu')) time_limit = arg_options.get('time_limit') memory_limit = arg_options.get('memory_limit') # set default values if not set proc = proc if proc else DEFAULTS.get('proc') time_limit = time_limit if time_limit else DEFAULTS.get('time_limit') memory_limit = memory_limit if memory_limit else DEFAULTS.get('memory_limit') return proc, time_limit, memory_limit
def __init__(self, yaml_config_file, missing_policy=MISSING_POLICY_CREATE_DEFAULT): self.yaml_config_file = yaml_config_file self.root = Paths.dirname(self.yaml_config_file) self.yamls = self._get_all_yamls() self.cases = list() self.common_config = None self.missing_policy = missing_policy # create dummy case for every yaml file in folder if not Paths.exists(self.yaml_config_file): self.common_config = deepcopy(yamlc.DEFAULTS) for y in self.yamls: dummy_case = deepcopy(yamlc.DEFAULTS) dummy_case['files'] = [y] self.cases.append(dummy_case) else: # setup common config values self.yaml_config = self._read_yaml() self.common_config = self.merge( yamlc.DEFAULTS, self.yaml_config.get('common_config', {})) # first process files which are specified in test_cases missing = [Paths.basename(y) for y in self.yamls] for case in self.yaml_config.get(yamlc.TAG_TEST_CASES, []): case_config = self.merge(self.common_config, case) # ensure that value are array case_config[yamlc.TAG_FILES] = ensure_iterable( case_config.get(yamlc.TAG_FILES, [])) # keep correct order self.cases.append(case_config) for f in case_config[yamlc.TAG_FILES]: if f in missing: missing.remove(f) # process rest (dummy case) if missing_policy == self.MISSING_POLICY_CREATE_DEFAULT: for y in missing: dummy_case = deepcopy(self.common_config) dummy_case[yamlc.TAG_FILES] = [y] self.cases.append(dummy_case)
def _run(self): """ Run method for this module """ self.proc = ensure_iterable(self.arg_options.get('cpu')) self.time_limit = self.arg_options.get('time_limit') self.memory_limit = self.arg_options.get('memory_limit') # set default values if not set self.proc = self.proc if self.proc else DEFAULTS.get('proc') self.time_limit = self.time_limit if self.time_limit else DEFAULTS.get('time_limit') self.memory_limit = self.memory_limit if self.memory_limit else DEFAULTS.get('memory_limit') # run local or pbs mode if self.arg_options.queue: return self.run_pbs_mode() else: return self.run_local_mode()
def _run(self): """ Run method for this module """ self.proc = ensure_iterable(self.arg_options.cpu) self.time_limit = self.arg_options.time_limit self.memory_limit = self.arg_options.memory_limit # set default values if not set self.proc = self.proc if self.proc else DEFAULTS.get('proc') self.time_limit = self.time_limit if self.time_limit else DEFAULTS.get( 'time_limit') self.memory_limit = self.memory_limit if self.memory_limit else DEFAULTS.get( 'memory_limit') # run local or pbs mode if self.arg_options.queue: return self.run_pbs_mode() else: return self.run_local_mode()
def __init__(self, yaml_config_file): self.yaml_config_file = yaml_config_file self.root = Paths.dirname(self.yaml_config_file) self.yamls = self._get_all_yamls() self.cases = list() self.common_config = None # create dummy case for every yaml file in folder if not Paths.exists(self.yaml_config_file): self.common_config = deepcopy(yamlc.DEFAULTS) for y in self.yamls: dummy_case = deepcopy(yamlc.DEFAULTS) dummy_case['files'] = [y] self.cases.append(dummy_case) else: # setup common config values self.yaml_config = self._read_yaml() self.common_config = self.merge( yamlc.DEFAULTS, self.yaml_config.get('common_config', {})) # first process files which are specified in test_cases missing = [Paths.basename(y) for y in self.yamls] for case in self.yaml_config.get(yamlc.TAG_TEST_CASES, []): case_config = self.merge(self.common_config, case) # ensure that value is array case_config[yamlc.TAG_FILES] = ensure_iterable( case_config.get(yamlc.TAG_FILES, [])) # keep correct order self.cases.append(case_config) for f in case_config[yamlc.TAG_FILES]: if f in missing: missing.remove(f) # process rest (dummy case) for y in missing: dummy_case = deepcopy(self.common_config) dummy_case[yamlc.TAG_FILES] = [y] self.cases.append(dummy_case)
def on_start(self, pypy=None): self.process = self.pypy.executor.process for fmt in ensure_iterable(self.start_format): printf.out(fmt, monitor=self)