当前位置: 首页>>代码示例>>Python>>正文


Python session.SessionState类代码示例

本文整理汇总了Python中plainbox.impl.session.SessionState的典型用法代码示例。如果您正苦于以下问题:Python SessionState类的具体用法?Python SessionState怎么用?Python SessionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SessionState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_realistic_test_session

 def make_realistic_test_session(self, session_dir):
     # Create a more realistic session with two jobs but with richer set
     # of data in the actual jobs and results.
     job_a = JobDefinition({
         'plugin': 'shell',
         'name': 'job_a',
         'command': 'echo testing && true',
         'requires': 'job_b.ready == "yes"'
     })
     job_b = JobDefinition({
         'plugin': 'resource',
         'name': 'job_b',
         'command': 'echo ready: yes'
     })
     session = SessionState([job_a, job_b])
     session.update_desired_job_list([job_a, job_b])
     result_a = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_PASS,
         'return_code': 0,
         'io_log': [(0, 'stdout', b'testing\n')],
     })
     result_b = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_PASS,
         'return_code': 0,
         'comments': 'foo',
         'io_log': [(0, 'stdout', b'ready: yes\n')],
     })
     session.update_job_result(job_a, result_a)
     session.update_job_result(job_b, result_b)
     return session
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:30,代码来源:test_init.py

示例2: make_realistic_test_session

 def make_realistic_test_session(self):
     # Create a more realistic session with two jobs but with richer set
     # of data in the actual jobs and results.
     job_a = JobDefinition({
         'plugin': 'shell',
         'name': 'job_a',
         'command': 'echo testing && true',
         'requires': 'job_b.ready == "yes"'
     })
     job_b = JobDefinition({
         'plugin': 'resource',
         'name': 'job_b',
         'command': 'echo ready: yes'
     })
     session = SessionState([job_a, job_b])
     session.update_desired_job_list([job_a, job_b])
     result_a = JobResult({
         'job': job_a,
         'outcome': 'pass',
         'return_code': 0,
         'io_log': (
             IOLogRecord(0, 'stdout', 'testing\n'),
         )
     })
     result_b = JobResult({
         'job': job_b,
         'outcome': 'pass',
         'return_code': 0,
         'io_log': (
             IOLogRecord(0, 'stdout', 'ready: yes\n'),
         )
     })
     session.update_job_result(job_a, result_a)
     session.update_job_result(job_b, result_b)
     return session
开发者ID:yphus,项目名称:checkbox,代码行数:35,代码来源:test_init.py

示例3: test_get_estimated_duration_manual

 def test_get_estimated_duration_manual(self):
     two_seconds = make_job("two_seconds", plugin="manual",
                            command="farboo",
                            estimated_duration=2.0)
     shell_job = make_job("shell_job", plugin="shell",
                          command="boofar",
                          estimated_duration=0.6)
     session = SessionState([two_seconds, shell_job])
     session.update_desired_job_list([two_seconds, shell_job])
     self.assertEqual(session.get_estimated_duration(), (0.6, 32.0))
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:10,代码来源:test_state.py

示例4: test_get_estimated_duration_automated_unknown

 def test_get_estimated_duration_automated_unknown(self):
     three_seconds = make_job("three_seconds", plugin="shell",
                              command="frob",
                              estimated_duration=3.0)
     no_estimated_duration = make_job("no_estimated_duration",
                                      plugin="shell",
                                      command="borf")
     session = SessionState([three_seconds, no_estimated_duration])
     session.update_desired_job_list([three_seconds, no_estimated_duration])
     self.assertEqual(session.get_estimated_duration(), (None, 0.0))
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:10,代码来源:test_state.py

示例5: test_get_estimated_duration_manual_unknown

 def test_get_estimated_duration_manual_unknown(self):
     four_seconds = make_job("four_seconds", plugin="shell",
                             command="fibble",
                             estimated_duration=4.0)
     no_estimated_duration = make_job("no_estimated_duration",
                                      plugin="user-verify",
                                      command="bibble")
     session = SessionState([four_seconds, no_estimated_duration])
     session.update_desired_job_list([four_seconds, no_estimated_duration])
     self.assertEqual(session.get_estimated_duration(), (4.0, None))
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:10,代码来源:test_state.py

示例6: make_test_session

 def make_test_session(self):
     # Create a small session with two jobs and two results
     job_a = make_job('job_a')
     job_b = make_job('job_b')
     session = SessionState([job_a, job_b])
     session.update_desired_job_list([job_a, job_b])
     result_a = make_job_result(job_a, 'pass')
     result_b = make_job_result(job_b, 'fail')
     session.update_job_result(job_a, result_a)
     session.update_job_result(job_b, result_b)
     return session
开发者ID:yphus,项目名称:checkbox,代码行数:11,代码来源:test_init.py

示例7: test_get_estimated_duration_auto

 def test_get_estimated_duration_auto(self):
     # Define jobs with an estimated duration
     one_second = make_job("one_second", plugin="shell",
                           command="foobar",
                           estimated_duration=1.0)
     half_second = make_job("half_second", plugin="shell",
                            command="barfoo",
                            estimated_duration=0.5)
     session = SessionState([one_second, half_second])
     session.update_desired_job_list([one_second, half_second])
     self.assertEqual(session.get_estimated_duration(), (1.5, 0.0))
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:11,代码来源:test_state.py

示例8: make_test_session

 def make_test_session(self):
     # Create a small session with two jobs and two results
     job_a = make_job('job_a')
     job_b = make_job('job_b')
     session = SessionState([job_a, job_b])
     session.update_desired_job_list([job_a, job_b])
     result_a = make_job_result(outcome=IJobResult.OUTCOME_PASS)
     result_b = make_job_result(outcome=IJobResult.OUTCOME_FAIL)
     session.update_job_result(job_a, result_a)
     session.update_job_result(job_b, result_b)
     return session
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:11,代码来源:test_init.py

示例9: test_crash_in_update_desired_job_list

 def test_crash_in_update_desired_job_list(self):
     # This checks if a DependencyError can cause crash
     # update_desired_job_list() with a ValueError, in certain conditions.
     A = make_job('A', depends='X')
     L = make_job('L', plugin='local')
     session = SessionState([A, L])
     problems = session.update_desired_job_list([A, L])
     # We should get exactly one DependencyMissingError related to job A and
     # the undefined job X (that is presumably defined by the local job L)
     self.assertEqual(len(problems), 1)
     self.assertIsInstance(problems[0], DependencyMissingError)
     self.assertIs(problems[0].affected_job, A)
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:12,代码来源:test_state.py

示例10: test_resume_session

 def test_resume_session(self):
     # All of the tests below are using one session. The session has four
     # jobs, Job A depends on a resource provided by job R which has no
     # dependencies at all. Both Job X and Y depend on job A.
     #
     # A -(resource dependency)-> R
     #
     # X -(direct dependency) -> A
     #
     # Y -(direct dependency) -> A
     self.job_A = make_job("A", requires="R.attr == 'value'")
     self.job_A_expr = self.job_A.get_resource_program().expression_list[0]
     self.job_R = make_job("R", plugin="resource")
     self.job_X = make_job("X", depends='A')
     self.job_Y = make_job("Y", depends='A')
     self.job_list = [self.job_A, self.job_R, self.job_X, self.job_Y]
     # Create a new session (session_dir is empty)
     self.session = SessionState(self.job_list)
     result_R = JobResult({
         'job': self.job_R,
         'io_log': make_io_log(((0, 'stdout', b"attr: value\n"),),
                               self._sandbox)
     })
     result_A = JobResult({
         'job': self.job_A,
         'outcome': JobResult.OUTCOME_PASS
     })
     result_X = JobResult({
         'job': self.job_X,
         'outcome': JobResult.OUTCOME_PASS
     })
     # Job Y can't start as it requires job A
     self.assertFalse(self.job_state('Y').can_start())
     self.session.update_desired_job_list([self.job_X, self.job_Y])
     self.session.open()
     self.session.update_job_result(self.job_R, result_R)
     self.session.update_job_result(self.job_A, result_A)
     self.session.update_job_result(self.job_X, result_X)
     self.session.persistent_save()
     self.session.close()
     # Create a new session (session_dir should contain session data)
     self.session = SessionState(self.job_list)
     self.session.open()
     # Resume the previous session
     self.session.resume()
     # This time job Y can start
     self.assertTrue(self.job_state('Y').can_start())
     self.session.close()
开发者ID:bladernr,项目名称:checkbox,代码行数:48,代码来源:test_session.py

示例11: run

 def run(self):
     # Compute the run list, this can give us notification about problems in
     # the selected jobs. Currently we just display each problem
     # Create a session that handles most of the stuff needed to run jobs
     try:
         self.session = SessionState(self.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 self.session.open():
         self._set_job_selection()
         self.runner = JobRunner(
             self.session.session_dir,
             self.session.jobs_io_log_dir,
             command_io_delegate=self,
             outcome_callback=None,  # SRU runs are never interactive
             dry_run=self.ns.dry_run
         )
         self._run_all_jobs()
         if self.config.fallback_file is not Unset:
             self._save_results()
         self._submit_results()
     # FIXME: sensible return value
     return 0
开发者ID:bladernr,项目名称:checkbox,代码行数:31,代码来源:sru.py

示例12: __init__

 def __init__(self, provider_list, config, ns):
     super().__init__(provider_list, config)
     self.ns = ns
     self.job_list = self.get_job_list(ns)
     self.desired_job_list = self._get_matching_job_list(ns, self.job_list)
     self.session = SessionState(self.job_list)
     self.problem_list = self.session.update_desired_job_list(
         self.desired_job_list)
开发者ID:Roadmaster,项目名称:checkbox,代码行数:8,代码来源:analyze.py

示例13: _run_jobs

    def _run_jobs(self, ns, job_list, exporter, transport=None):
        # Compute the run list, this can give us notification about problems in
        # the selected jobs. Currently we just display each problem
        matching_job_list = self._get_matching_job_list(ns, job_list)
        print("[ Analyzing Jobs ]".center(80, '='))
        # 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():
            if session.previous_session_file():
                if self.ask_for_resume():
                    session.resume()
                else:
                    session.clean()
            self._update_desired_job_list(session, matching_job_list)
            if (sys.stdin.isatty() and sys.stdout.isatty() and not
                    ns.not_interactive):
                outcome_callback = self.ask_for_outcome
            else:
                outcome_callback = None
            runner = JobRunner(
                session.session_dir,
                session.jobs_io_log_dir,
                outcome_callback=outcome_callback,
                dry_run=ns.dry_run
            )
            self._run_jobs_with_session(ns, session, runner)
            # Get a stream with exported session data.
            exported_stream = io.BytesIO()
            data_subset = exporter.get_session_data_subset(session)
            exporter.dump(data_subset, exported_stream)
            exported_stream.seek(0)  # Need to rewind the file, puagh
            # Write the stream to file if requested
            self._save_results(ns.output_file, exported_stream)
            # Invoke the transport?
            if transport:
                exported_stream.seek(0)
                try:
                    transport.send(exported_stream.read())
                except InvalidSchema as exc:
                    print("Invalid destination URL: {0}".format(exc))
                except ConnectionError as exc:
                    print(("Unable to connect "
                           "to destination URL: {0}").format(exc))
                except HTTPError as exc:
                    print(("Server returned an error when "
                           "receiving or processing: {0}").format(exc))

        # FIXME: sensible return value
        return 0
开发者ID:bladernr,项目名称:checkbox,代码行数:60,代码来源:run.py

示例14: test_set_resource_list

 def test_set_resource_list(self):
     # Define an empty session
     session = SessionState([])
     # Define a resource
     old_res = Resource({'attr': 'old value'})
     # Set the resource list with the old resource
     # So here the old result is stored into a new 'R' resource
     session.set_resource_list('R', [old_res])
     # Ensure that it worked
     self.assertEqual(session._resource_map, {'R': [old_res]})
     # Define another resource
     new_res = Resource({'attr': 'new value'})
     # Now we present the second result for the same job
     session.set_resource_list('R', [new_res])
     # What should happen here is that the R resource is entirely replaced
     # by the data from the new result. The data should not be merged or
     # appended in any way.
     self.assertEqual(session._resource_map, {'R': [new_res]})
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:18,代码来源:test_state.py

示例15: test_add_job

 def test_add_job(self):
     # Define a job
     job = make_job("A")
     # Define an empty session
     session = SessionState([])
     # Add the job to the session
     session.add_job(job)
     # The job got added to job list
     self.assertIn(job, session.job_list)
     # The job got added to job state map
     self.assertIs(session.job_state_map[job.name].job, job)
     # The job is not added to the desired job list
     self.assertNotIn(job, session.desired_job_list)
     # The job is not in the run list
     self.assertNotIn(job, session.run_list)
     # The job is not selected to run
     self.assertEqual(
         session.job_state_map[job.name].readiness_inhibitor_list,
         [UndesiredJobReadinessInhibitor])
开发者ID:jds2001,项目名称:ocp-checkbox,代码行数:19,代码来源:test_state.py


注:本文中的plainbox.impl.session.SessionState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。