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


Python Search.get_by_code方法代码示例

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


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

示例1: execute

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

        process = my.input.get("process")
        sobject = my.input.get("sobject")
        pipeline = my.input.get("pipeline")

        process_obj = pipeline.get_process(process)
        node_type = process_obj.get_type()
        #print "complete: ", process, node_type

        status = my.get_status()

        # run a nodes complete trigger
        #event = "process|complete|%s" % process
        #Trigger.call(my, event, output=my.input)
        my.run_callback(pipeline, process, status)

        process_obj = pipeline.get_process(process)
        node_type = process_obj.get_type()

        if node_type in ["action", "approval", "manual", "node", "hierarchy"]:
            # call the process|pending event for all output processes
            output_processes = pipeline.get_output_processes(process)
            for output_process in output_processes:
                output_process = output_process.get_name()

                output = {
                    'pipeline': pipeline,
                    'sobject': sobject,
                    'process': output_process
                }

                event = "process|pending"
                Trigger.call(my, event, output)

        if node_type in ["action", "condition"]:
            my.set_all_tasks(sobject, process, "complete")


        parent_process = pipeline.get_value("parent_process")
        #print "parent: ", parent_process
        if parent_process:
            output_processes = pipeline.get_output_processes(process)
            if not output_processes:
                # look at the parent pipelline
                parent_process_sobj = Search.get_by_code("config/process", parent_process)
                parent_pipeline_code = parent_process_sobj.get_value("pipeline_code")
                parent_pipeline = Search.get_by_code("sthpw/pipeline", parent_pipeline_code)
                parent_process = parent_process_sobj.get_value("process")

                output = {
                    'pipeline': parent_pipeline,
                    'sobject': sobject,
                    'process': parent_process,
                }

                event = "process|complete"
                Trigger.call(my, event, output)
开发者ID:nuxping,项目名称:TACTIC,代码行数:60,代码来源:workflow.py

示例2: GET

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def GET(my):
        method = my.kwargs.get("method")
        print my.kwargs
        print "method: ", method
        print "expression: ", my.kwargs.get("expression")


        # /rest/get_by_code/cars/CAR00009

        # /rest/query?search_type=sthpw/cars
        if method == "query":
            code = my.kwargs.get("data")
            from pyasm.search import Search
            sobject = Search.get_by_code(search_type, code)
            sobject_dict = sobject.get_sobject_dict()
            return sobject_dict

        # /rest/expression/@SOBJECT(sthpw/task)
        elif method == "expression":
            expression = my.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)

        # /rest/simple_checkin?search_key=dfadfdsas&data={}
        elif method == "expression":
            expression = my.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)


        return {}
开发者ID:0-T-0,项目名称:TACTIC,代码行数:33,代码来源:rest_handler.py

示例3: get_ref_obj

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def get_ref_obj(self, sobject):
        search_type = sobject.get_value("search_type")
        search_code = sobject.get_value("search_code", no_exception=True)
        if not search_code:
            search_id = sobject.get_value("search_code")
        else:
            search_id = None

        key = SearchKey.build_search_key(search_type, search_code)

        ref_sobject = self.ref_sobj_dict.get(str(key))
        if not ref_sobject:
            try:
                if search_code:
                    ref_sobject = Search.get_by_code(search_type, search_code)
                else:
                    ref_sobject = Search.get_by_id(search_type, search_id)

                if not ref_sobject:
                    return None
            except SearchException as e:
                print e.__str__()
                return None

        return ref_sobject
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:group_element_wdg.py

示例4: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def execute(my):
        my.search_type = my.kwargs.get("search_type")
        my.element_name = my.kwargs.get("element_name")
        assert my.search_type
        assert my.element_name

        interval = my.kwargs.get('interval')
        if not interval:
            interval = 120

        data_type = my.kwargs.get('data_type')
        if not data_type:
            data_type = 'float'

        class_name = 'tactic.ui.app.aggregate_wdg.AggregateCmd'
        priority = None

        user = Environment.get_user_name()

        # these interval jobs need to have a specific code
        code = "aggregate|%s|%s" % (my.search_type, my.element_name)

        # check to see if the job exists
        job = Search.get_by_code("sthpw/queue", code)
        if not job:
            job = SearchType.create("sthpw/queue")
            job.set_value("code", code)

            job.set_value("project_code", Project.get_project_code() )
            job.set_value("class_name", class_name)
            job.set_value("command", class_name)
            job.set_value("login", user) 
            job.set_value("queue", 'interval')

            # this is meaningless
            job.set_value("priority", 9999)

            # not sure what to do here if it already exists
            job.set_value("state", 'pending')



            # add a column to the table
            from pyasm.command import ColumnAddCmd
            from pyasm.search import AlterTable
            column_name = my.element_name
            cmd = ColumnAddCmd(my.search_type, column_name, data_type)
            cmd.execute()

            # modify the table
            #alter = AlterTable(my.search_type)
            #alter.modify(my.search_type, data_type)
            #print alter.get_statements()


        job.set_value("serialized", str(my.kwargs) )
        job.set_value("interval", interval)
        job.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:60,代码来源:aggregate_wdg.py

示例5: __init__

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def __init__(self, notification, sobject, parent, command, input):
        self.notification = notification
        self.sobject = sobject
        self.command = command
        self.parent = parent
        self.input = input

        # Introduce an environment that can be reflected
        self.env_sobjects = {
            'sobject': self.sobject
        }

        snapshot = self.input.get('snapshot')
        if snapshot:
            self.env_sobjects['snapshot'] = Search.get_by_code("sthpw/snapshot", snapshot.get("code"))
        note = self.input.get('note')
        if note:
            self.env_sobjects['note'] = Search.get_by_code("sthpw/note", note.get("code"))
开发者ID:mincau,项目名称:TACTIC,代码行数:20,代码来源:email_handler.py

示例6: get_by_code

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    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,代码行数:54,代码来源:pipeline.py

示例7: __init__

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def __init__(my, **kwargs):
        my.kwargs = kwargs

        # NOTE: this search key is to find the server, not the transactions
        search_key = my.kwargs.get("search_key")
        if not search_key:
            server_code = my.kwargs.get("server_code")
            my.server_sobj = Search.get_by_code("sthpw/sync_server", server_code)
        else:
            my.server_sobj = Search.get_by_search_key(search_key)


        my.start_expr = my.kwargs.get("start_expr")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:15,代码来源:sync_utils.py

示例8: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def execute(self):

        sandbox_dir = "/home/apache/inhance_asset_library"
        rule_code = "6SIMULATION"


        rule_code = self.kwargs.get("rule_code")
        rule = Search.get_by_code("config/ingest_rule", rule_code)


        cmd = IngestionCmd(rule=rule, session_base_dir=sandbox_dir)

        cmd.execute()
开发者ID:mincau,项目名称:TACTIC,代码行数:15,代码来源:ingestion_cmd.py

示例9: alter_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def alter_search(my, search):
        if not my.select:
            return
        if not my.parent_type:
            return
        if not my.schema:
            return

        parent_code = my.select.get_value()
        parent = Search.get_by_code(my.parent_type, parent_code)
        if not parent:
            return
        parent.children_alter_search(search, my.search_type)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:15,代码来源:filter_wdg.py

示例10: delete

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def delete(my):

        code = my.kwargs.get("code")
        assert code

        server = Search.get_by_code("sthpw/sync_server", code)
        print server.get_data()

        base_dir = server.get_value("base_dir")

        server.delete()

        if os.path.exists(base_dir):
            shutil.rmtree(base_dir)
开发者ID:blezek,项目名称:TACTIC,代码行数:16,代码来源:share_wdg.py

示例11: handle_pending

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def handle_pending(my):
        my.log_message(my.sobject, my.process, "pending")

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



        # use child process
        subpipeline_code = process_sobj.get_value("subpipeline_code")
        if subpipeline_code:
            subpipeline = Search.get_by_code("sthpw/pipeline", subpipeline_code)
        else:
            search = Search("sthpw/pipeline")
            search.add_filter("parent_process", process_code)
            subpipeline = search.get_sobject()

        if not subpipeline:
            return


        # get the input nodes
        child_processes = subpipeline.get_processes(type=['input'])

        if not child_processes:
            child_processes = subpipeline.get_processes()

        if child_processes:
            first_process = child_processes[0]
            first_name = first_process.get_name()

            full_name = "%s.%s" % (my.process, first_name)

            input = {
                    'pipeline': subpipeline,
                    'sobject': my.sobject,
                    'process': full_name,
            }

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

示例12: check_inputs

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def check_inputs(my):
        pipeline = my.input.get("pipeline")
        process = my.input.get("process")
        sobject = my.input.get("sobject")

        print "check_input: ", process

        # first check the inputs.  If there is only one input, then
        # skip this check
        input_processes = pipeline.get_input_processes(process)
        if len(input_processes) <= 1:
            return True


        # TODO: what about dependencies??

        # check all of the input processes to see if they are all complete
        complete = True
        for input_process in input_processes:
            key = "%s|%s|status" % (sobject.get_search_key(), input_process.get_name())
            message_sobj = Search.get_by_code("sthpw/message", key)
            if message_sobj:
                message = message_sobj.get_json_value("message")
                if message != "complete":
                    complete = False
                    break
            else:
                # look for some other means to determine if this is done
                search = Search("sthpw/task")
                search.add_parent_filter(sobject)
                search.add_filter("process", input_process.get_name())
                task = search.get_sobject()
                if task:
                    task_status = task.get("status")
                    if status.lower() != "complete":
                        complete = False
                        break

        print "complete: ", complete
        if not complete:
            return False
        else:
            return True
开发者ID:jayvdb,项目名称:TACTIC,代码行数:45,代码来源:workflow.py

示例13: get_snapshot_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def get_snapshot_search(my):
        web = WebContainer.get_web()

        args = web.get_form_args()

        if not my.search_type:
            my.search_type = args.get('search_type')
            my.search_id = args.get('search_id')

        if not my.search_type:
            my.search_type = web.get_form_value("search_type")
            my.search_id = web.get_form_value("search_id")

        # add all of the asset snapshots
        #instance = ShotInstance.get_by_id(my.search_id)
        instance = Search.get_by_id(my.search_type, my.search_id)
        #asset = instance.get_asset(my.asset_search_type)
        asset_code = instance.get_value("asset_code")
        asset = Search.get_by_code(my.asset_search_type, asset_code)
        asset_search_type = ''
        asset_id = ''
        if asset: 
            asset_id = asset.get_id()
            asset_search_type = asset.get_search_type()

        snapshot_type = "sthpw/snapshot" 
        search = Search(snapshot_type)
        where = "(search_id = '%s' and search_type ='%s')" % \
            (my.search_id, my.search_type)
        
        where2 = "(search_id = '%s' and search_type ='%s')" % \
            (asset_id, asset_search_type)
        if asset_search_type and asset_id:
            search.add_where("(%s or %s)" % (where,where2) )
        else:
            search.add_where(where)
        # ignore icon checkins
        search.add_where("context != 'icon'")

        search.add_order_by("timestamp desc")
        return search
开发者ID:0-T-0,项目名称:TACTIC,代码行数:43,代码来源:asset_history_wdg.py

示例14: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def get_display(my):

        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_share_item")

        my.server_code = my.kwargs.get("server_code")
        if not my.server_code:
            top.add("No server selected")
            return top



        my.server = Search.get_by_code("sthpw/sync_server", my.server_code)
        my.base_dir = my.server.get_value("base_dir")


        title_wdg = DivWdg()
        top.add( title_wdg )
        title_wdg.add( my.server_code )
        title_wdg.add_style("padding: 10px")
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_border()
        title_wdg.add_style("margin: -6px -6px 10px -6px")
        title_wdg.add_style("font-weight: bold")

        description = my.server.get_value("description")
        title_wdg.add(" &nbsp; <i style='font-size: 9px; opacity: 0.5'>( %s )</i>" % description )




        from tactic.ui.container import TabWdg
        tab = TabWdg(selected="Info", show_add=False)
        top.add(tab)
        tab.add(my.get_info_wdg())
        tab.add(my.get_files_wdg())

        tab.add( my.get_tools_wdg() )

        return top
开发者ID:blezek,项目名称:TACTIC,代码行数:43,代码来源:share_wdg.py

示例15: handle_complete

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_code [as 别名]
    def handle_complete(my):
        my.log_message(my.sobject, my.process, "complete")

        my.run_callback(my.pipeline, my.process, "complete")


        search = Search("config/process")        
        search.add_filter("subpipeline_code", my.pipeline.get_code())
        if my.process_parts:
            search.add_filter("process", my.process_parts[0])
        supprocess_sobj = search.get_sobject()
        suppipeline_code = supprocess_sobj.get_value("pipeline_code")
        supprocess = supprocess_sobj.get_value("process")

        suppipeline = Search.get_by_code("sthpw/pipeline", suppipeline_code)
        output = {
            'pipeline': suppipeline,
            'sobject': my.sobject,
            'process': supprocess
        }

        event = "process|complete"
        Trigger.call(my, event, output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:25,代码来源:workflow.py


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