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


Python Task.create方法代码示例

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


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

示例1: _test_parent_search

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_parent_search(self):
        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','burt')
        person.commit()

        person2 = SearchType.create('unittest/person')
        person2.set_value('name_first','sean')
        person2.commit()
 
        person_search = Search('unittest/person')
        person_search.add_filters('id', [person.get_id(), person2.get_id()])
        for xrange in (1, 50):
            Task.create(person, 'process_CC','some task', 'admin', context='process_CC')
        for xrange in (1, 50):
            Task.create(person2, 'process_DD','some task', 'admin')
        
        # find parent of tasks
        search2 = Search('sthpw/task')
        search2.add_relationship_filters([person,person2])
        tasks = search2.get_sobjects()
        
        search3 = Search('sthpw/task')
        search3.add_relationship_search_filter(person_search)
        tasks2 = search3.get_sobjects()
        
        self.assertEquals(SObject.get_values(tasks, 'id'), SObject.get_values(tasks2, 'id'))
开发者ID:mincau,项目名称:TACTIC,代码行数:29,代码来源:search_test.py

示例2: execute

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
 def execute(self):
     person = SearchType.create('unittest/person')
     person.set_value('name_first', 'john')
     person.commit(triggers=False)
     person2 = SearchType.create('unittest/person')
     person2.set_value('name_first', 'zoe')
     person2.commit(triggers=False)
     task = Task.create(person, "unittest_person", "hello")
     task = Task.create(person2, "unittest_person", "hello")
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:command_test.py

示例3: execute

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
 def execute(my):
     person = SearchType.create("unittest/person")
     person.set_value("name_first", "john")
     person.commit(triggers=False)
     person2 = SearchType.create("unittest/person")
     person2.set_value("name_first", "zoe")
     person2.commit(triggers=False)
     task = Task.create(person, "unittest_person", "hello")
     task = Task.create(person2, "unittest_person", "hello")
开发者ID:hellios78,项目名称:TACTIC,代码行数:11,代码来源:command_test.py

示例4: _test_child_search

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_child_search(self):

        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','pete')
        person.commit()
        for xrange in (1, 50):
            Task.create(person, 'process_AA','some task', 'admin', context='process_AA')
        person2 = SearchType.create('unittest/person')
        person2.set_value('name_first','jamie')
        person2.commit()

        person2_tasks = []
        for xrange in (1, 50):
            person2_tasks.append(Task.create(person2, 'process_BB','some task', 'admin', context='process_BB'))
        task_search = Search('sthpw/task')
        task_search.add_filters('process', ['process_AA', 'process_BB'])
        tasks = task_search.get_sobjects()
        search2 = Search('unittest/person')
        search2.add_relationship_filters(tasks)
        persons = search2.get_sobjects()
        
        search3 = Search('unittest/person')
        search3.add_relationship_search_filter(task_search)
        persons_fast = search3.get_sobjects()
        
        self.assertEquals(SObject.get_values(persons, 'id'), SObject.get_values(persons_fast, 'id'))
        self.assertEquals(SObject.get_values(persons_fast, 'name_first'), ['pete','jamie'])

        # if I retire all the tasks for person2
        for task in tasks:
            if task.get_value('process') =='process_BB':
                task.retire()

        task_search = Search('sthpw/task')
        task_search.add_filters('process', ['process_AA', 'process_BB'])
        tasks = task_search.get_sobjects()
        search4 = Search('unittest/person')
        search4.add_relationship_search_filter(task_search)
        persons_fast = search4.get_sobjects()
        
        search2 = Search('unittest/person')
        search2.add_relationship_filters(tasks)
        persons = search2.get_sobjects()

        self.assertEquals(SObject.get_values(persons, 'id'), SObject.get_values(persons_fast, 'id'))
        self.assertEquals(SObject.get_values(persons_fast, 'name_first'), ['pete'])

        # test add_filters() with an empty array
        task_search = Search('sthpw/task')
        task_search.add_filters('process', [])
        tasks = task_search.get_sobjects()
        self.assertEquals(tasks, [])
        expected = '''SELECT %s"task".* FROM %s"task" WHERE "task"."id" is NULL AND ("task"."s_status" != 'retired' or "task"."s_status" is NULL) ORDER BY "task"."search_type", "task"."search_code"'''%(self.sthpw_prefix, self.sthpw_prefix)
        statement = task_search.get_statement()
        self.assertEquals(statement, expected)
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:search_test.py

示例5: _test_child_search

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_child_search(my):

        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','pete')
        person.commit()
        for xrange in (1, 50):
            Task.create(person, 'process_AA','some task', 'admin', context='process_AA')
        person2 = SearchType.create('unittest/person')
        person2.set_value('name_first','jamie')
        person2.commit()

        person2_tasks = []
        for xrange in (1, 50):
            person2_tasks.append(Task.create(person2, 'process_BB','some task', 'admin', context='process_BB'))
        task_search = Search('sthpw/task')
        task_search.add_filters('process', ['process_AA', 'process_BB'])
        tasks = task_search.get_sobjects()
        search2 = Search('unittest/person')
        search2.add_relationship_filters(tasks)
        persons = search2.get_sobjects()
        
        search3 = Search('unittest/person')
        search3.add_relationship_search_filter(task_search)
        persons_fast = search3.get_sobjects()
        
        my.assertEquals(SObject.get_values(persons, 'id'), SObject.get_values(persons_fast, 'id'))
        my.assertEquals(SObject.get_values(persons_fast, 'name_first'), ['pete','jamie'])

        # if I retire all the tasks for person2
        for task in tasks:
            if task.get_value('process') =='process_BB':
                task.retire()

        task_search = Search('sthpw/task')
        task_search.add_filters('process', ['process_AA', 'process_BB'])
        tasks = task_search.get_sobjects()
        search4 = Search('unittest/person')
        search4.add_relationship_search_filter(task_search)
        persons_fast = search4.get_sobjects()
        
        search2 = Search('unittest/person')
        search2.add_relationship_filters(tasks)
        persons = search2.get_sobjects()

        my.assertEquals(SObject.get_values(persons, 'id'), SObject.get_values(persons_fast, 'id'))
        my.assertEquals(SObject.get_values(persons_fast, 'name_first'), ['pete'])
开发者ID:blezek,项目名称:TACTIC,代码行数:49,代码来源:search_test.py

示例6: execute

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def execute(self):
        input = self.get_input()

        search_key = input.get("search_key")
        task = Search.get_by_search_key(search_key)
        parent = task.get_parent()
        if not parent:
            raise TacticException("Task parent not found.")

        # get the definition of the trigger
        trigger_sobj = self.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        try:
            data = jsonloads(data)
        except:
            raise TacticException("Incorrect formatting of trigger [%s]." % trigger_sobj.get_value("code"))

        # check against source status if present 
        src_status = data.get("src_status")
        if src_status:
            task_status = task.get_value("status")
            if task_status != src_status:
                return

        process_names = data.get("output")
        if not process_names:
            return

        # only create new task if another of the same
        # process does not already exist
        search = Search("sthpw/task")
        search.add_filters("process", process_names)
        search.add_parent_filter(parent)
        search.add_project_filter()
        tasks = search.get_sobjects()
        existing_processes = [x.get_value("process") for x in tasks]
       
        for process in process_names:
            if process in existing_processes:    
                continue
            else:
                Task.create(parent, process, start_date=None, end_date=None)
开发者ID:mincau,项目名称:TACTIC,代码行数:44,代码来源:pipeline_task_trigger.py

示例7: execute

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def execute(my):
        input = my.get_input()

        search_key = input.get("search_key")
        task = Search.get_by_search_key(search_key)

        parent = task.get_parent()

        # get the definition of the trigger
        trigger_sobj = my.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        data = jsonloads(data)

        process = data.get("output")
        description = ""

        # FIXME:
        # find out if there is already a task of that process

        Task.create(parent, process, description, start_date=None, end_date=None)
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:22,代码来源:pipeline_task_trigger.py

示例8: _test_multi_task

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_multi_task(self):

        # create a dummy sobject
        sobject = SearchType.create("unittest/person")

        pipeline_xml = '''
        <pipeline>
          <process name="a"/>
          <process type="action" name="b"/>
          <connect from="a" to="b"/>
        </pipeline>
        '''

        pipeline, processes = self.get_pipeline(pipeline_xml)

        sobject.set_value("pipeline_code", pipeline.get_code() )
        sobject.commit()

        for process_name, process in processes.items():
            process.set_json_value("workflow", {
                'on_complete': '''
                sobject.set_value('name_first', '%s')
                ''' % process_name,
            } )
            process.commit()
 

        task = Task.create(sobject, process="a", description="Test Task")
        task2 = Task.create(sobject, process="a", description="Test Task 2")

        task.set_value("status", "complete")
        task.commit()
        self.assertEquals( False, "b" == sobject.get_value("name_first"))

        task2.set_value("status", "complete")
        task2.commit()
        self.assertEquals( True, "b" == sobject.get_value("name_first"))
开发者ID:mincau,项目名称:TACTIC,代码行数:39,代码来源:workflow_test.py

示例9: _test_task

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_task(my):

        # create a dummy sobject
        sobject = SearchType.create("unittest/person")



        pipeline_xml = '''
        <pipeline>
          <process name="a"/>
          <process type="action" name="b"/>
          <connect from="a" to="b"/>
        </pipeline>
        '''

        pipeline, processes = my.get_pipeline(pipeline_xml)

        sobject.set_value("pipeline_code", pipeline.get_code() )
        sobject.commit()

        for process_name, process in processes.items():
            process.set_json_value("workflow", {
                #'on_in_progress': '''
                #sobject.set_value('name_first', '%s')
                #''' % process_name,
                'on_complete': '''
                sobject.set_value('name_first', '%s')
                ''' % process_name,
            } )
            process.commit()
 

        task = Task.create(sobject, process="a", description="Test Task")

        # TODO: not quite sure if this should be related to "action"
        #task.set_value("status", "in_progress")
        #task.commit()
        #my.assertEquals( "in_progress", sobject.get_value("name_first"))

        task.set_value("status", "complete")
        task.commit()
        my.assertEquals( "b", sobject.get_value("name_first"))
开发者ID:jayvdb,项目名称:TACTIC,代码行数:44,代码来源:workflow_test.py

示例10: execute

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def execute(my):

        left_cb , right_cb = my.get_checkbox_cols()
        
        web = WebContainer.get_web()


        select_shots = web.get_form_values(right_cb.CB_NAME)
        if not select_shots:
            return

        select_tasks = web.get_form_values("sthpw_task")
        if not select_tasks:
            return

        # get all of the shots
        shots = []
        for shot_search_key in select_shots:
            shot = Search.get_by_search_key(shot_search_key)
            shots.append(shot)

        # get all of the tasks
        tasks = []
        for task_search_key in select_tasks:
            task = Search.get_by_search_key(task_search_key)
            tasks.append(task)


        # copy these tasks into the selected shots
        from pyasm.biz import Task
        for shot in shots:
            for task in tasks:
                # extract the properties of each task
                process = task.get_value("process")
                description = task.get_value("description")
                assigned = task.get_value("assigned")
                supe = task.get_value("supervisor")
                # create a new tasks
                new_task = Task.create(shot, process, description, assigned=assigned,\
                        supervisor=supe)
                my.sobjects.append(new_task)
        my.add_description("Added template tasks to shot(s)")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:44,代码来源:shot_instance_adder_wdg.py

示例11: _test_multi_db_subselect

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_multi_db_subselect(self):

        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="a")


        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin2')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="b")


        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin3')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="c")




        # find people by carin that have a task "subselect"
        search_person = Search("unittest/person")
        search_task = Search("sthpw/task")
        search_person.add_relationship_search_filter(search_task,use_multidb=False)
        search_task.add_filter("process", "subselect")

        sobjects = search_person.get_sobjects()
        self.assertEquals(len(sobjects), 3)


        # find people by carin that have a task "subselect", using
        # subselect
        search_person = Search("unittest/person")
        search_task = Search("sthpw/task")
        search_person.add_relationship_search_filter(search_task,use_multidb=True)
        search_task.add_filter("process", "subselect")

        sobjects = search_person.get_sobjects()
        self.assertEquals(len(sobjects), 3)


        # find task that carin has
        search_task = Search("sthpw/task")
        search_person = Search("unittest/person")
        search_person.add_filter('name_first','carin')
        search_task.add_relationship_search_filter(search_person,use_multidb=True)

        sobjects = search_task.get_sobjects()



        # test an order by on a task status (cross database join)
        # Note this will not work on Postgres or SQLite which do not 
        # support cross database joins
        search_person = Search("unittest/person")
        search_person.add_order_by("sthpw/task.status", direction="desc")
        statement = search_person.get_statement()

        can_join = DatabaseImpl.can_search_types_join( \
                "unittest/person", "sthpw/task")

        if can_join:
            expected = '''SELECT %s"person".* FROM %s"person" LEFT OUTER JOIN %s"task" ON "person"."code" = "task"."search_code" WHERE "task"."search_type" = 'unittest/person?project=unittest' ORDER BY "task"."status" desc''' % (self.prefix, self.prefix, self.sthpw_prefix)
            self.assertEquals(expected, statement)
            
            sobjects = search_person.get_sobjects()
            names = [x.get_value("name_first") for x in sobjects]
            expected = ['carin3','carint2','carin']
            self.assertEquals(expected, names)
开发者ID:mincau,项目名称:TACTIC,代码行数:76,代码来源:search_test.py

示例12: _test_multi_db_subselect

# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import create [as 别名]
    def _test_multi_db_subselect(my):

        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="a")


        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin2')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="b")


        from pyasm.biz import Task
        person = SearchType.create('unittest/person')
        person.set_value('name_first','carin3')
        person.commit()
        Task.create(person, 'subselect','some task', 'admin', status="c")




        # find people by carin that have a task "subselect"
        search_person = Search("unittest/person")
        search_task = Search("sthpw/task")
        search_person.add_relationship_search_filter(search_task,use_multidb=False)
        search_task.add_filter("process", "subselect")

        sobjects = search_person.get_sobjects()
        my.assertEquals(len(sobjects), 3)


        # find people by carin that have a task "subselect", using
        # subselect
        search_person = Search("unittest/person")
        search_task = Search("sthpw/task")
        search_person.add_relationship_search_filter(search_task,use_multidb=True)
        search_task.add_filter("process", "subselect")

        sobjects = search_person.get_sobjects()
        my.assertEquals(len(sobjects), 3)


        # find task that carin has
        search_task = Search("sthpw/task")
        search_person = Search("unittest/person")
        search_person.add_filter('name_first','carin')
        search_task.add_relationship_search_filter(search_person,use_multidb=True)

        sobjects = search_task.get_sobjects()



        # test an order by on a task status
        search_person = Search("unittest/person")
        search_person.add_order_by("sthpw/task.status", direction="desc")
        statement = search_person.get_statement()
        expected = '''SELECT %s."person".* FROM %s."person" LEFT OUTER JOIN "sthpw"."task" ON "person"."code" = "task"."search_code" WHERE "task"."search_type" = 'unittest/person?project=unittest' ORDER BY "task"."status" desc''' % (my.prefix, my.prefix)
        my.assertEquals(expected, statement)
        
        sobjects = search_person.get_sobjects()
        names = [x.get_value("name_first") for x in sobjects]
        expected = ['carin3','carint2','carin']
        my.assertEquals(expected, names)
开发者ID:blezek,项目名称:TACTIC,代码行数:69,代码来源:search_test.py


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