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


Python TaskControl.process方法代码示例

本文整理汇总了Python中doit.control.TaskControl.process方法的典型用法代码示例。如果您正苦于以下问题:Python TaskControl.process方法的具体用法?Python TaskControl.process怎么用?Python TaskControl.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在doit.control.TaskControl的用法示例。


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

示例1: testSystemExitRaises

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testSystemExitRaises(self, reporter, RunnerClass, depfile):
     t1 = Task("x", [_exit])
     my_runner = RunnerClass(depfile.name, reporter)
     tc = TaskControl([t1])
     tc.process(None)
     pytest.raises(SystemExit, my_runner.run_tasks, tc)
     my_runner.finish()
开发者ID:SchuylerGoodman,项目名称:topicalguide,代码行数:9,代码来源:test_runner.py

示例2: test_delayed_creation

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
    def test_delayed_creation(self):
        def creator():
            yield {'name': 'foo1', 'actions': None, 'file_dep': ['bar']}
            yield {'name': 'foo2', 'actions': None, 'targets': ['bar']}

        delayed_loader = DelayedLoader(creator, executed='t2')
        tasks = [Task('t0', None, task_dep=['t1']),
                 Task('t1', None, loader=delayed_loader),
                 Task('t2', None)]

        control = TaskControl(tasks)
        control.process(['t0'])
        disp = control.task_dispatcher()
        gen = disp.generator
        nt2 = next(gen)
        assert nt2.task.name == "t2"

        # wait for t2 to be executed
        assert "hold on" == next(gen)
        assert "hold on" == next(gen) # hold until t2 is done

        # delayed creation of tasks for t1 does not mess existing info
        assert disp.nodes['t1'].waiting_me == set([disp.nodes['t0']])
        nf2 = gen.send(nt2)
        assert disp.nodes['t1'].waiting_me == set([disp.nodes['t0']])

        assert nf2.task.name == "t1:foo2"
        nf1 = gen.send(nf2)
        assert nf1.task.name == "t1:foo1"
        assert nf1.task.task_dep == ['t1:foo2'] # implicit dep added
        nt1 = gen.send(nf1)
        assert nt1.task.name == "t1"
        nt0 = gen.send(nt1)
        assert nt0.task.name == "t0"
        pytest.raises(StopIteration, lambda gen: next(gen), gen)
开发者ID:JohannesBuchner,项目名称:doit,代码行数:37,代码来源:test_control.py

示例3: testDetectCyclicReference

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testDetectCyclicReference(self):
     tasks = [Task("taskX",None,task_dep=["taskY"]),
              Task("taskY",None,task_dep=["taskX"])]
     tc = TaskControl(tasks)
     tc.process(None)
     gen = tc._add_task(0, "taskX", False)
     py.test.raises(InvalidDodoFile, gen.next)
开发者ID:jergason,项目名称:topicalguide,代码行数:9,代码来源:test_control.py

示例4: doit_auto

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
def doit_auto(dependency_file, task_list, filter_tasks, loop_callback=None):
    """Re-execute tasks automatically a depedency changes

    @param filter_tasks (list -str): print only tasks from this list
    @loop_callback: used to stop loop on unittests
    """
    task_control = TaskControl(task_list)
    task_control.process(filter_tasks)
    tasks_to_run = list(set([t for t in task_control.task_dispatcher(True)]))
    watch_tasks = [t.name for t in tasks_to_run]
    watch_files = list(itertools.chain(*[s.file_dep for s in tasks_to_run]))
    watch_files = list(set(watch_files))

    class DoitAutoRun(FileModifyWatcher):
        """Execute doit on event handler of file changes """
        def handle_event(self, event):
            doit_run(dependency_file, task_list, sys.stdout,
                     watch_tasks, reporter='executed-only')
            # reset run_status
            for task in task_list:
                task.run_status = None

    file_watcher = DoitAutoRun(watch_files)
    # always run once when started
    file_watcher.handle_event(None)
    file_watcher.loop(loop_callback)
开发者ID:jergason,项目名称:topicalguide,代码行数:28,代码来源:cmds.py

示例5: testChangeOrder_AddJustOnce

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testChangeOrder_AddJustOnce(self):
     tasks = [Task("taskX",None,task_dep=["taskY"]),
              Task("taskY",None,)]
     tc = TaskControl(tasks)
     tc.process(None)
     assert [tasks[1], tasks[0]] == [x for x in tc._add_task(0, 'taskX', False)]
     # both tasks were already added. so no tasks left..
     assert [] == [x for x in tc._add_task(0, 'taskY', False)]
开发者ID:jergason,项目名称:topicalguide,代码行数:10,代码来源:test_control.py

示例6: testSetupInvalid

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testSetupInvalid(self):
     tasks = [Task("taskX",None,setup=["taskZZZZZZZZ"]),
              Task("taskY",None,)]
     tc = TaskControl(tasks)
     tc.process(['taskX'])
     gen = tc._add_task(0, 'taskX', False)
     assert tasks[0] == gen.next() # tasks with setup are yield twice
     tasks[0].run_status = 'run' # should be executed
     py.test.raises(InvalidTask, gen.next) # execute setup before
开发者ID:jergason,项目名称:topicalguide,代码行数:11,代码来源:test_control.py

示例7: test_reporter_runtime_error

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_reporter_runtime_error(self, reporter):
     t1 = Task('t1', [], setup=['make_invalid'])
     my_runner = runner.Runner(TESTDB, reporter)
     tc = TaskControl([t1])
     tc.process(None)
     my_runner.run_all(tc)
     assert ('start', t1) == reporter.log.pop(0)
     assert ('runtime_error',) == reporter.log.pop(0)
     assert not reporter.log
开发者ID:jergason,项目名称:topicalguide,代码行数:11,代码来源:test_runner.py

示例8: test_successRunOnce

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_successRunOnce(self, reporter, RunnerClass):
     tasks = [Task("taskX", [my_print], run_once=True)]
     my_runner = RunnerClass(TESTDB, reporter)
     tc = TaskControl(tasks)
     tc.process(None)
     my_runner.run_tasks(tc)
     assert runner.SUCCESS == my_runner.finish()
     d = Dependency(TESTDB)
     assert '1' == d._get('taskX', 'run-once:')
开发者ID:jergason,项目名称:topicalguide,代码行数:11,代码来源:test_runner.py

示例9: test_include_setup

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_include_setup(self):
     tasks = [Task("t1", None, task_dep=["t2"]),
              Task("t2", None,)]
     control = TaskControl(tasks)
     control.process(['t1'])
     gen = control.task_dispatcher(include_setup=True).generator
     # dont wait for tasks
     assert tasks[0] == gen.send(None).task
     assert tasks[1] == gen.send(None).task
     pytest.raises(StopIteration, gen.send, None)
开发者ID:swayf,项目名称:doit,代码行数:12,代码来源:test_control.py

示例10: testSetupTasksDontRun

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testSetupTasksDontRun(self):
     tasks = [Task("taskX",None,setup=["taskY"]),
              Task("taskY",None,)]
     tc = TaskControl(tasks)
     tc.process(['taskX'])
     gen = tc._add_task(0, 'taskX', False)
     assert tasks[0] == gen.next()
     # X is up-to-date
     tasks[0].run_status = 'up-to-date'
     py.test.raises(StopIteration, gen.next)
开发者ID:jergason,项目名称:topicalguide,代码行数:12,代码来源:test_control.py

示例11: testParallel

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def testParallel(self):
     tasks = [Task("taskX",None,task_dep=["taskY"]),
              Task("taskY",None)]
     tc = TaskControl(tasks)
     tc.process(None)
     gen1 = tc._add_task(0, "taskX", False)
     assert tasks[1] == gen1.next()
     # gen2 wont get any task, because it was already being processed
     gen2 = tc._add_task(1, "taskY", False)
     py.test.raises(StopIteration, gen2.next)
开发者ID:jergason,项目名称:topicalguide,代码行数:12,代码来源:test_control.py

示例12: test_run_task

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_run_task(self, reporter, depfile):
     t1 = Task('t1', [])
     t2 = Task('t2', [])
     tc = TaskControl([t1, t2])
     tc.process(None)
     run = runner.MRunner(depfile.name, reporter)
     run._run_tasks_init(tc)
     assert t1 == run.get_next_task()
     assert t2 == run.get_next_task()
     assert None == run.get_next_task()
开发者ID:SchuylerGoodman,项目名称:topicalguide,代码行数:12,代码来源:test_runner.py

示例13: test_stop_running

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_stop_running(self, reporter):
     t1 = Task('t1', [])
     t2 = Task('t2', [])
     tc = TaskControl([t1, t2])
     tc.process(None)
     run = runner.MRunner(TESTDB, reporter)
     run._run_tasks_init(tc)
     assert t1 == run.get_next_task()
     run._stop_running = True
     assert None == run.get_next_task()
开发者ID:jergason,项目名称:topicalguide,代码行数:12,代码来源:test_runner.py

示例14: test_teardown

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
 def test_teardown(self, reporter, RunnerClass):
     t1 = Task('t1', [], teardown=[ok])
     t2 = Task('t2', [])
     my_runner = RunnerClass(TESTDB, reporter)
     tc = TaskControl([t1, t2])
     tc.process(None)
     assert [] == my_runner.teardown_list
     my_runner.run_tasks(tc)
     my_runner.finish()
     assert ('teardown', t1) == reporter.log[-1]
开发者ID:jergason,项目名称:topicalguide,代码行数:12,代码来源:test_runner.py

示例15: doit_run

# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import process [as 别名]
def doit_run(dependency_file, task_list, output, options=None,
             verbosity=None, always_execute=False, continue_=False,
             reporter='default', num_process=0):
    """
    @param reporter: (str) one of provided reporters or ...
                     (class) user defined reporter class (can only be specified
           from DOIT_CONFIG - never from command line)
    """
    # get tasks to be executed
    task_control = TaskControl(task_list)
    task_control.process(options)

    # reporter
    if isinstance(reporter, str):
        if reporter not in REPORTERS:
            msg = ("No reporter named '%s'."
                   " Type 'doit help run' to see a list "
                   "of available reporters.")
            raise InvalidCommand(msg % reporter)
        reporter_cls = REPORTERS[reporter]
    else:
        # user defined class
        reporter_cls = reporter

    # verbosity
    if verbosity is None:
        use_verbosity = Task.DEFAULT_VERBOSITY
    else:
        use_verbosity = verbosity
    show_out = use_verbosity < 2 # show on error report

    # outstream
    if isinstance(output, str):
        outstream = open(output, 'w')
    else: # outfile is a file-like object (like StringIO or sys.stdout)
        outstream = output

    # run
    try:
        # FIXME stderr will be shown twice in case of task error/failure
        reporter_obj = reporter_cls(outstream, {'show_out':show_out,
                                                'show_err': True})

        if num_process == 0:
            runner = Runner(dependency_file, reporter_obj, continue_,
                            always_execute, verbosity)
        else:
            runner = MRunner(dependency_file, reporter_obj, continue_,
                               always_execute, verbosity, num_process)

        return runner.run_all(task_control)
    finally:
        if isinstance(output, str):
            outstream.close()
开发者ID:jergason,项目名称:topicalguide,代码行数:56,代码来源:cmds.py


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