Exemplo n.º 1
0
 def setup(self):
     """
     Setup the temporary job handlers (dirs, global setting, ...)
     """
     output.reconfigure(self.config)
     assert self.tmpdir is None, "Job.setup() already called"
     if self.config.get("run.dry_run.enabled"):  # Create the dry-run dirs
         if self.config.get("run.results_dir") is None:
             tmp_dir = tempfile.mkdtemp(prefix="avocado-dry-run-")
             self.config["run.results_dir"] = tmp_dir
     self._setup_job_results()
     self.result = result.Result(self.unique_id, self.logfile)
     self.__start_job_logging()
     self._setup_job_category()
     # Use "logdir" in case "keep_tmp" is enabled
     if self.config.get("run.keep_tmp"):
         self._base_tmpdir = self.logdir
     else:
         self._base_tmpdir = tempfile.mkdtemp(prefix="avocado_tmp_")
         self.__keep_tmpdir = False
     self.tmpdir = tempfile.mkdtemp(prefix="avocado_job_", dir=self._base_tmpdir)
Exemplo n.º 2
0
    def __init__(self):

        # Catch all libc runtime errors to STDERR
        os.environ['LIBC_FATAL_STDERR_'] = '1'

        self._cli_dispatcher = None
        self._cli_cmd_dispatcher = None

        self._setup_signals()
        self.parser = Parser()
        self.parser.start()
        output.early_start()

        show = getattr(self.parser.args, 'core.show')
        reconfigure_settings = {'core.paginator': False, 'core.show': show}
        try:
            self._load_cli_plugins()
            self._configure_cli_plugins()
            self.parser.finish()
            settings.merge_with_configs()
            settings.merge_with_arguments(self.parser.config)
            self.parser.config.update(settings.as_dict())
            self._run_cli_plugins()
        except SystemExit as detail:
            # If someone tries to exit Avocado, we should first close the
            # STD_OUTPUT and only then exit.
            output.reconfigure(reconfigure_settings)
            STD_OUTPUT.close()
            sys.exit(detail.code)
        except:
            # For any other exception we also need to close the STD_OUTPUT.
            output.reconfigure(reconfigure_settings)
            STD_OUTPUT.close()
            raise
        else:
            # In case of no exceptions, we just reconfigure the output.
            output.reconfigure(self.parser.config)
Exemplo n.º 3
0
    def __init__(self):

        # Catch all libc runtime errors to STDERR
        os.environ['LIBC_FATAL_STDERR_'] = '1'

        signal.signal(signal.SIGTSTP, signal.SIG_IGN)   # ignore ctrl+z
        self.parser = Parser()
        output.early_start()
        try:
            self.cli_dispatcher = CLIDispatcher()
            self.cli_cmd_dispatcher = CLICmdDispatcher()
            output.log_plugin_failures(self.cli_dispatcher.load_failures +
                                       self.cli_cmd_dispatcher.load_failures)
            self.parser.start()
            if self.cli_cmd_dispatcher.extensions:
                self.cli_cmd_dispatcher.map_method('configure', self.parser)
            if self.cli_dispatcher.extensions:
                self.cli_dispatcher.map_method('configure', self.parser)
            self.parser.finish()
            if self.cli_dispatcher.extensions:
                self.cli_dispatcher.map_method('run', self.parser.args)
        except SystemExit as e:
            # If someone tries to exit Avocado, we should first close the
            # STD_OUTPUT and only then exit.
            setattr(self.parser.args, 'paginator', 'off')
            output.reconfigure(self.parser.args)
            STD_OUTPUT.close()
            sys.exit(e.code)
        except:
            # For any other exception we also need to close the STD_OUTPUT.
            setattr(self.parser.args, 'paginator', 'off')
            output.reconfigure(self.parser.args)
            STD_OUTPUT.close()
            raise
        else:
            # In case of no exceptions, we just reconfigure the output.
            output.reconfigure(self.parser.args)