• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python biz.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

    def execute(my):

        input = my.get_input()
       
        search_key = input.get("search_key")
        update_data = input.get("update_data")

        if not search_key or search_key.startswith('sthpw/'):
            return

        mode = input.get("mode")
        if mode not in ['insert']:
            return


        sobject = my.get_caller()
        pipeline_code = sobject.get_value("pipeline_code", no_exception=True)

        if not pipeline_code:
            return

        from pyasm.biz import Pipeline, Task
        from pyasm.search import SearchType

        pipeline = Pipeline.get_by_code(pipeline_code)
        if not pipeline:
            return

        if pipeline.get_value("autocreate_tasks", no_exception=True) not in ['true', True]:
            return

        #import time
        #start = time.time()
        Task.add_initial_tasks(sobject, pipeline_code=pipeline_code, skip_duplicate=True, mode='standard')
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:pipeline_task_trigger.py


示例2: postprocess

    def postprocess(self):
        value = self.get_value()
        if not value:
            return

        from pyasm.biz import Task
        Task.add_initial_tasks(self.sobject)
开发者ID:mincau,项目名称:TACTIC,代码行数:7,代码来源:edit_wdg_action.py


示例3: _test_parent_search

    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,代码行数:27,代码来源:search_test.py


示例4: postprocess

    def postprocess(my):
        web = WebContainer.get_web()
        add_initial_tasks = web.get_form_value("add_initial_tasks")

        if add_initial_tasks != "on":
            return

        Task.add_initial_tasks(my.sobject)
开发者ID:hellios78,项目名称:TACTIC,代码行数:8,代码来源:asset_task_creator_wdg.py


示例5: execute

 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,代码行数:9,代码来源:command_test.py


示例6: execute

 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,代码行数:9,代码来源:command_test.py


示例7: execute

    def execute(my):
        print "EXECUTING sample command"

        # create the render
        render = SearchType.create("prod/render")
        render.set_parent(my.prev_command.sobject)
        render.set_value("pipeline_code", "turntable")
        render.commit()
        Task.add_initial_tasks(render)

        prev_sobject = my.prev_command.sobject
        prev_process = "model"
        this_sobject = my.prev_command.sobject
        this_process = "turntable"

        # get the deliverable
        snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process)
        if not snapshot:
            return

        # once we have this snapshot, open the file and process
        lib_dir = snapshot.get_lib_dir()
        file_name = snapshot.get_name_by_type("maya")

        file_path = "%s/%s" % (lib_dir, file_name)

        f = open( file_path, 'r')
        lines = f.readlines()
        f.close()

        tmp_dir = Environment.get_tmp_dir()
        new_file_name = "whatever.new"
        new_file_path = "%s/%s" % (tmp_dir, new_file_name)

        f2 = open( new_file_path, 'wb')
        for i, line in enumerate(lines):
            line = "%s - %s" % ( i,line)
            f2.write(line)
        f2.close()

        file_paths = [new_file_path]
        file_types = ['maya']

        from pyasm.checkin import FileCheckin
        checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process)
        checkin.execute()

        my.set_event_name("task/approved")
        my.set_process("preprocess")
        my.set_pipeline_code("turntable")
        my.sobjects = [render]

        # ???
        my.sobject = render


        my.set_as_approved()
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:57,代码来源:command.py


示例8: _test_child_search

    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,代码行数:56,代码来源:search_test.py


示例9: execute

    def execute(self):
        self.search_key_list = self.kwargs.get('search_key_list')
        web = WebContainer.get_web()
        skip_duplicated = web.get_form_value('skip_duplicated') == 'on'
        pipeline_mode = web.get_form_value('pipeline_mode')

        sobjects = SearchKey.get_by_search_keys(self.search_key_list)
        count = 0
        offset = 0
        for sobject in sobjects:
            if isinstance(sobject, Task):
                raise TacticException('Creation of task for [Task] is not allowed')
            sk = SearchKey.get_by_sobject(sobject)
            if not sobject.has_value('pipeline_code'):
                #raise TacticException('Creation of task is not allowed for item with no pipeline_code attribute.')
                pipeline_code = '__default__'
                sobject.set_value("pipeline_code", pipeline_code)
            else:
                pipeline_code = sobject.get_value('pipeline_code')
            input_name = '%s|task_process'% pipeline_code
            
            contexts = []
            process_names = web.get_form_values(input_name)
            process_names = [name for name in process_names if name]
            if pipeline_mode == 'context':
                # when pipeline_mode is context, we only specify contexts
                # in add_initial_tasks
                contexts = process_names[:]
                process_names = []
            tasks = Task.add_initial_tasks(sobject, sobject.get_value('pipeline_code'),
                    processes=process_names, contexts=contexts, skip_duplicate=skip_duplicated, mode=pipeline_mode, start_offset=offset)

            count += len(tasks)
            offset += 5
        self.add_description("%s Tasks added in total." % count)
开发者ID:mincau,项目名称:TACTIC,代码行数:35,代码来源:task_wdg.py


示例10: _test_child_search

    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,代码行数:47,代码来源:search_test.py


示例11: set_all_tasks

 def set_all_tasks(my, sobject, process, status):
     tasks = Task.get_by_sobject(sobject, process=process)
     title = status.replace("-", " ")
     title = title.replace("_", " ")
     title = Common.get_display_title(title)
     for task in tasks:
         task.set_value("status", title)
         task.commit()
开发者ID:nuxping,项目名称:TACTIC,代码行数:8,代码来源:workflow.py


示例12: _test_approval

    def _test_approval(my):

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

        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
          <process type="approval" name="b"/>
          <process type="action" name="c"/>
          <connect from="a" to="b"/>
          <connect from="b" to="c"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)

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

        # ensure there are not tasks
        tasks = Task.get_by_sobject(sobject, process="b")
        my.assertEquals(0, len(tasks))


        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)

        # ensure there are not tasks
        tasks = Task.get_by_sobject(sobject, process="b")
        my.assertEquals(1, len(tasks))

        task = tasks[0]
        my.assertEquals("b", task.get("process"))

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


示例13: handle_td

    def handle_td(my, td):
        sobject = my.get_current_sobject()

        value = my.get_value()
        color = Task.get_default_color(value)

        if color:
           td.add_style("background-color: %s" % color)

        super(SObjectStatusElementWdg, my).handle_td(td)
开发者ID:asmboom,项目名称:TACTIC,代码行数:10,代码来源:misc_input_wdg.py


示例14: set_as_approved

    def set_as_approved(my):
        '''convinience function that sets task for this process as approved'''
        my.set_event_name("task/approved")

        # get the task associated with this process
        tasks = Task.get_by_sobjects(my.sobjects, my.process_name)

        for task in tasks:
            task.set_value("status", "Approved")
            task.commit()
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:10,代码来源:command.py


示例15: execute

    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,代码行数:42,代码来源:pipeline_task_trigger.py


示例16: execute

    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,代码行数:20,代码来源:pipeline_task_trigger.py


示例17: get_by_code

    def get_by_code(cls, code, allow_default=False):
        '''it is fatal not to have a pipeline, so put a default'''
        if not code:
            return None

        # first look at project specific pipeline
        pipeline = Search.get_by_code("config/pipeline", code)

        if not pipeline:
            pipeline = super(Pipeline,cls).get_by_code(code)

        if not pipeline and code == 'task':
            # Create a default task pipeline
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "task")
            from pyasm.biz import Task
            xml = Task.get_default_task_xml()
            pipeline.set_value("pipeline", xml)
            pipeline.set_pipeline(xml)
            pipeline.set_value("search_type", "sthpw/task")
            #pipeline.commit()


        if not pipeline and allow_default:
            search = Search(cls)
            search.add_filter('code', 'default')
            pipeline = search.get_sobject()
            if not pipeline:
                
                pipeline = cls.create('default',  \
                    'default pipeline', '')

                xml = pipeline.get_xml_value("pipeline")

                # create a default process for the table
                root = xml.get_root_node()
                element = xml.create_element("process")
                Xml.set_attribute(element,"name", "default_process")
                Xml.append_child(root, element)

                pipeline.set_value('pipeline', xml.get_xml())
                pipeline.commit()
                
                # set the pipeline
                pipeline.set_pipeline(pipeline.get_value('pipeline'))
                Environment.add_warning("pipeline autogenerated", \
                    "[default] pipeline has just been created.")
        # Sometimes, a pipeline is instantiated without calling set_pipeline()
        # to be looked into
        if pipeline and not pipeline.get_processes():
            pipeline.set_pipeline(pipeline.get_value('pipeline'))
        return pipeline
开发者ID:funic,项目名称:TACTIC,代码行数:52,代码来源:pipeline.py


示例18: _test_multi_task

    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,代码行数:37,代码来源:workflow_test.py


示例19: handle_pending

    def handle_pending(my):
        my.log_message(my.sobject, my.process, "pending")

        search = Search("config/process")        
        search.add_filter("process", my.process)
        search.add_filter("pipeline_code", my.pipeline.get_code())
        process_sobj = search.get_sobject()

        workflow = process_sobj.get_json_value("workflow")
        if workflow:
            assigned = workflow.get("assigned")
        else:
            assigned = None


        # check to see if the tasks exist and if they don't then create one
        tasks = Task.get_by_sobject(my.sobject, process=my.process)
        if not tasks:
            tasks = Task.add_initial_tasks(my.sobject, processes=[my.process], assigned=assigned)
        else:
            my.set_all_tasks(my.sobject, my.process, "pending")


        Trigger.call(my, "process|action", my.input)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:24,代码来源:workflow.py


示例20: preprocess

    def preprocess(my):

        # get the tasks and reorder by search_key
        tasks = Task.get_by_sobjects(my.sobjects)
        my.tasks_dict = {}
        for task in tasks:
            search_type = task.get_value("search_type")
            search_id = task.get_value("search_id")
            search_key = "%s|%s" % (search_type, search_id)

            sobject_tasks = my.tasks_dict.get(search_key)
            if not sobject_tasks:
                sobject_tasks = []
                my.tasks_dict[search_key] = sobject_tasks

            sobject_tasks.append(task)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:16,代码来源:layout_summary_wdg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python checkin.FileCheckin类代码示例发布时间:2022-05-25
下一篇:
Python biz.Snapshot类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap