Example #1
0
 def _get_job(self):
     job_list = get_matching_job_list(self.provider.get_builtin_jobs(),
                                      NameJobQualifier(self.job_name))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #2
0
 def _run_jobs_with_session(self, ns, session, runner):
     # TODO: run all resource jobs concurrently with multiprocessing
     # TODO: make local job discovery nicer, it would be best if
     # desired_jobs could be managed entirely internally by SesionState. In
     # such case the list of jobs to run would be changed during iteration
     # but would be otherwise okay).
     print("[ Running All Jobs ]".center(80, '='))
     again = True
     while again:
         again = False
         for job in session.run_list:
             # Skip jobs that already have result, this is only needed when
             # we run over the list of jobs again, after discovering new
             # jobs via the local job output
             if session.job_state_map[job.name].result.outcome is not None:
                 continue
             self._run_single_job_with_session(ns, session, runner, job)
             session.persistent_save()
             if job.plugin == "local":
                 # After each local job runs rebuild the list of matching
                 # jobs and run everything again
                 desired_job_list = []
                 for whitelist in self.whitelists:
                     desired_job_list.extend(
                         get_matching_job_list(session.job_list, whitelist))
                 self._update_desired_job_list(session, desired_job_list)
                 again = True
                 break
Example #3
0
 def _get_job(self):
     job_list = get_matching_job_list(
         self.get_job_list(None),
         JobIdQualifier(self.job_id))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #4
0
 def _set_job_selection(self):
     desired_job_list = get_matching_job_list(self.job_list, self.whitelist)
     problem_list = self.session.update_desired_job_list(desired_job_list)
     if problem_list:
         logger.warning("There were some problems with the selected jobs")
         for problem in problem_list:
             logger.warning("- %s", problem)
         logger.warning("Problematic jobs will not be considered")
Example #5
0
 def _set_job_selection(self):
     desired_job_list = get_matching_job_list(self.job_list, self.whitelist)
     problem_list = self.session.update_desired_job_list(desired_job_list)
     if problem_list:
         logger.warning("There were some problems with the selected jobs")
         for problem in problem_list:
             logger.warning("- %s", problem)
         logger.warning("Problematic jobs will not be considered")
Example #6
0
 def _get_job(self):
     job_list = get_matching_job_list(
         self.get_job_list(None),
         NameJobQualifier(self.job_name))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #7
0
 def _get_job(self):
     job_list = get_matching_job_list(
         self.get_job_list(None),
         JobIdQualifier(self.job_id, Origin.get_caller_origin()))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #8
0
 def _get_job(self):
     job_list = get_matching_job_list(
         self.provider.get_builtin_jobs(),
         NameJobQualifier(self.job_name))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #9
0
    def _run_jobs(self, ns, job_list):
        # Create a session that handles most of the stuff needed to run jobs
        try:
            session = SessionState(job_list)
        except DependencyDuplicateError as exc:
            # Handle possible DependencyDuplicateError that can happen if
            # someone is using plainbox for job development.
            print("The job database you are currently using is broken")
            print("At least two jobs contend for the name {0}".format(
                exc.job.name))
            print("First job defined in: {0}".format(exc.job.origin))
            print("Second job defined in: {0}".format(
                exc.duplicate_job.origin))
            raise SystemExit(exc)
        with session.open():
            desired_job_list = []
            for whitelist in self.whitelists:
                desired_job_list.extend(get_matching_job_list(job_list,
                                                              whitelist))
            self._update_desired_job_list(session, desired_job_list)
            if session.previous_session_file():
                if self.is_interactive and self.ask_for_resume():
                    session.resume()
                    self._maybe_skip_last_job_after_resume(session)
                else:
                    session.clean()
            session.metadata.title = " ".join(sys.argv)
            session.persistent_save()
            # Ask the password before anything else in order to run jobs
            # requiring privileges
            if self.is_interactive and self._auth_warmup_needed(session):
                print("[ Authentication ]".center(80, '='))
                return_code = authenticate_warmup()
                if return_code:
                    raise SystemExit(return_code)
            runner = JobRunner(
                session.session_dir, self.provider_list,
                session.jobs_io_log_dir)
            self._run_jobs_with_session(ns, session, runner)
            self.save_results(session)
            session.remove()

        # FIXME: sensible return value
        return 0
Example #10
0
 def test_get_matching_job_list(self):
     job_list = [make_job('foo'), make_job('froz'), make_job('barg')]
     self.assertEqual(
         get_matching_job_list(job_list, RegExpJobQualifier('f.*')),
         [make_job('foo'), make_job('froz')])
Example #11
0
 def _get_job(self):
     job_list = get_matching_job_list(self.get_job_list(None), JobIdQualifier(self.job_id))
     if len(job_list) == 0:
         return None
     else:
         return job_list[0]
Example #12
0
 def test_get_matching_job_list(self):
     origin = mock.Mock(name='origin', spec_set=Origin)
     job_list = [make_job('foo'), make_job('froz'), make_job('barg')]
     self.assertEqual(
         get_matching_job_list(job_list, RegExpJobQualifier('f.*', origin)),
         [make_job('foo'), make_job('froz')])