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


Python Search.add_limit方法代码示例

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


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

示例1: execute

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


        pattern = "C:/test/{episode}/{shot}/image####.jpg"

        frame_util = FrameUtil(pattern)

        search = Search(Shot)
        search.add_limit(10)
        shots = search.get_sobjects()

        # prerun flash as a separate nonblockin process
        conn = FlashConnection()
        conn.run_flash()
        
        conn.download_jsfl("common.jsfl")
        conn.download_jsfl("load2.jsfl")


        for shot in shots:

            shot_code = shot.get_code()
            episode_code = shot.get_value("episode_code")

            info = { 'episode': episode_code, 'shot': shot_code }

            frame_dir, frame_pattern = frame_util.find_pattern(info)
            start_frame, end_frame, by_frame = frame_util.get_frame_range(info)

            if start_frame == 0 and end_frame == 0:
                print "Skipping: no frames found for shot '%s'" % shot_code
                continue

            src_path = "%s/%s" % (frame_dir, frame_pattern)
            src_path = src_path.replace("(.*)", "####")
            print "src_path: ", src_path
            print "start_frame: ", start_frame
            print "end_frame: ", end_frame

            load_jsfl = "%s/JSFL/load2.jsfl" % local_dir
            a = conn.get_jsfl(load_jsfl, "include", "common.jsfl", "%s/JSFL" % local_dir)
            b = conn.get_jsfl(load_jsfl, "init_session")
            c = conn.get_jsfl(load_jsfl, "import_leica", src_path, "Leica", start_frame, end_frame)

            exec_path = "%s/temp/exec.jsfl" % local_dir
            f = open(exec_path, "wb")
            f.write(a + "\n")
            f.write(b + "\n")
            f.write(c + "\n")
            f.close()
            os.system(exec_path)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:55,代码来源:build.py

示例2: get_next_job

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]
    def get_next_job(job_search_type="sthpw/queue", queue_type=None, server_code=None):

        sql = DbContainer.get("sthpw")

        search_type_obj = SearchType.get(job_search_type)
        table = search_type_obj.get_table()

        # get the entire queue
        search = Search(job_search_type)
        if queue_type:
            search.add_filter("queue", queue_type)
        if server_code:
            search.add_filter("server_code", server_code)
        search.add_filter("state", "pending")

        search.add_order_by("priority")
        search.add_order_by("timestamp")


        chunk = 10
        search.add_limit(chunk)

        queues = search.get_sobjects()
        queue_id = 0

        for queue in queues:

            queue_id = queue.get_id()

            # attempt to lock this queue
            # have to do this manually
            update = """UPDATE "%s" SET state = 'locked' where id = '%s' and state = 'pending'""" % (table, queue_id)

            sql.do_update(update)
            row_count = sql.get_row_count()

            if row_count == 1:
                break
            else:
                queue_id = 0

        if queue_id:
            queue = Search.get_by_id(job_search_type, queue_id)
            return queue
        else:
            return None
开发者ID:mincau,项目名称:TACTIC,代码行数:48,代码来源:queue.py

示例3: get_next_job

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]
    def get_next_job(queue_type=None):

        sql = DbContainer.get("sthpw")

        # get the entire queue
        search = Search("sthpw/queue")
        if queue_type:
            search.add_filter("queue", queue_type)
        search.add_filter("state", "pending")
        search.add_order_by("timestamp")

        chunk = 10
        search.add_limit(chunk)

        queues = search.get_sobjects()
        queue_id = 0

        for queue in queues:

            queue_id = queue.get_id()

            # attempt to lock this queue
            # have to do this manually
            update = "UPDATE queue SET state = 'locked' where id = '%s' and state = 'pending'" % queue_id

            sql.do_update(update)
            row_count = sql.get_row_count()

            if row_count == 1:
                break
            else:
                queue_id = 0

        if queue_id:
            queue = Search.get_by_id("sthpw/queue", queue_id)
            return queue
        else:
            return None
开发者ID:funic,项目名称:TACTIC,代码行数:40,代码来源:queue.py

示例4: preprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]
    def preprocess(my):
        my.max_value = 0
        my.min_value = 0
        my.steps = 0

        web = WebContainer.get_web()
        my.width = web.get_form_value("width")
        if not my.width:
            my.width = my.kwargs.get("width")


        my.chart_type = web.get_form_value("chart_type")
        if not my.chart_type:
            my.chart_type = my.kwargs.get("chart_type")
        if not my.chart_type:
            my.chart_type = 'bar'


        my.x_axis = web.get_form_value("x_axis")
        if not my.x_axis:
            my.x_axis = my.kwargs.get("x_axis")
        if not my.x_axis:
            my.x_axis = 'code'


        # FIXME: which should override???
        my.y_axis = web.get_form_values("y_axis")
        if not my.y_axis:
            my.y_axis = my.kwargs.get("y_axis")

        if my.y_axis:
            my.elements = my.y_axis
        else:
            my.elements = my.kwargs.get("elements")
            if not my.elements:
                my.elements = web.get_form_value("elements")

        if isinstance(my.elements,basestring):
            if my.elements:
                my.elements = my.elements.split('|')
            else:
                my.elements = []




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


        my.search_keys = my.kwargs.get("search_keys")
        if my.search_type and my.search_type.startswith("@SOBJECT("):
            my.sobjects = Search.eval(my.search_type)
        elif my.search_keys:
            if isinstance(my.search_keys, basestring):
                my.search_keys = eval(my.search_keys)
            my.sobjects = Search.get_by_search_keys(my.search_keys)
        else:
            search = Search(my.search_type)
            search.add_limit(100)
            my.sobjects = search.get_sobjects()

        # get the definition
        sobjects = my.sobjects
        if sobjects:
            sobject = sobjects[0]
            search_type = sobject.get_search_type()
            view = 'definition'

            from pyasm.widget import WidgetConfigView
            my.config = WidgetConfigView.get_by_search_type(search_type, view)
        else:
            my.config = None


        my.widgets = {}
开发者ID:0-T-0,项目名称:TACTIC,代码行数:79,代码来源:bar_chart_wdg.py

示例5: preprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]
    def preprocess(self):
        self.max_value = 0
        self.min_value = 0
        self.steps = 0

        web = WebContainer.get_web()
        self.width = web.get_form_value("width")
        if not self.width:
            self.width = self.kwargs.get("width")


        self.chart_type = web.get_form_value("chart_type")
        if not self.chart_type:
            self.chart_type = self.kwargs.get("chart_type")
        if not self.chart_type:
            self.chart_type = 'bar'


        self.x_axis = web.get_form_value("x_axis")
        if not self.x_axis:
            self.x_axis = self.kwargs.get("x_axis")
        if not self.x_axis:
            self.x_axis = 'code'


        # FIXME: which should override???
        self.y_axis = web.get_form_values("y_axis")
        if not self.y_axis:
            self.y_axis = self.kwargs.get("y_axis")

        if self.y_axis:
            self.elements = self.y_axis
        else:
            self.elements = self.kwargs.get("elements")
            if not self.elements:
                self.elements = web.get_form_value("elements")

        if isinstance(self.elements,basestring):
            if self.elements:
                self.elements = self.elements.split('|')
            else:
                self.elements = []


        self.colors = self.kwargs.get("colors")
        if not self.colors:
            self.colors = [
                'rgba(0,255,0,0.5)',
                'rgba(0,0,255,0.5)',
                'rgba(255,0,0,0.5)',
                'rgba(255,255,0,0.5)',
                'rgba(0,255,255,0.5)',
                'rgba(255,0,255,0.5)',
            ]
            while len(self.elements) >= len(self.colors):
                self.colors.extend(self.colors)
        else:
            if isinstance(self.colors,basestring):
                self.colors = self.colors.split("|")


        chart_type = self.kwargs.get("chart_type")
        if chart_type:
            self.chart_types = [chart_type for x in self.elements]
        else:
            self.chart_types = self.kwargs.get("chart_types")
            if not self.chart_types:
                self.chart_types = ['bar' for x in self.elements]



        expression = web.get_form_value("expression")
        if not expression:
            expression = self.kwargs.get("expression")



        self.search_type = web.get_form_value("search_type")
        if not self.search_type:
            self.search_type = self.kwargs.get("search_type")

        self.search_keys = self.kwargs.get("search_keys")


        if expression:
            self.sobjects = Search.eval(expression)
        elif self.search_type and self.search_type.startswith("@SOBJECT("):
            self.sobjects = Search.eval(self.search_type)
        elif self.search_keys:
            if isinstance(self.search_keys, basestring):
                self.search_keys = eval(self.search_keys)
            self.sobjects = Search.get_by_search_keys(self.search_keys)
        else:
            search = Search(self.search_type)
            search.add_limit(100)
            self.sobjects = search.get_sobjects()


        if not self.sobjects:
            return
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:sobject_chart_wdg.py

示例6: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]
    def execute(my):
        search = Search("sthpw/file")
        search.add_limit(1000)
        search.add_where("relative_dir is NULL")
        search.add_order_by("code")
        files = search.get_sobjects()

        for file in files:

            snapshot_code = file.get_value("snapshot_code")

            snapshot = Snapshot.get_by_code(snapshot_code)
            if not snapshot:
                if WARNING: print "WARNING: Snapshot [%s] not found for file [%s]" % (snapshot_code, file.get_code() )
                continue

            try:
                file_name = file.get_value("file_name")
                if WARNING:
                    lib_dir = snapshot.get_lib_dir()
                    path = "%s/%s" % (lib_dir, file_name)

                    if not os.path.exists(path):
                        print "WARNING: path [%s] does not exist" % path

                file_type = snapshot.get_type_by_file_name(file_name)

                relative_dir = snapshot.get_relative_dir(file_type=file_type)

                cur_relative_dir = file.get_value("relative_dir")
                if cur_relative_dir and cur_relative_dir != relative_dir:
                    if WARNING: print "WARNING: current [%s] and build relative dir [%s] are not equal" % (cur_relative_dir, relative_dir)

                    #answer = raw_input("Fix (y/n): ")
                    #if answer == "n":
                    #    continue
                    #continue


                if cur_relative_dir != relative_dir:
                    file.set_value("relative_dir", relative_dir)
                    file.commit()



            except SObjectNotFoundException, e:
                # Remove some dangling unittest
                if snapshot_code.endswith("UNI"):
                    file.delete()
                    snapshot.delete()
                else:
                    if WARNING:
                        print "WARNING: Error getting directory for snapshot [%s] for file [%s]" % (snapshot_code, file.get_code() )
                        print "\t", e.__str__()

                continue

            except TacticException, e:
                print "WARNING: Problem found on file [%s]" % file.get_code()
                print "\t", e.__str__()
                continue
开发者ID:0-T-0,项目名称:TACTIC,代码行数:63,代码来源:fix_relative_dir.py

示例7: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_limit [as 别名]

#.........这里部分代码省略.........
        selected_process_names = []
        step = 0
        
        for idx, value in enumerate(self.process_names):
            checkbox_name = 'note_process_cb'
            if self.child_mode:
                selected_process_names.append(value)
                #break
            cb = CheckboxWdg(checkbox_name, label=value)

           
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)
            #cb.set_persistence()

            cb.add_behavior({
                'type': 'click_up',
                'cbjs_action': '''
                    spt.input.save_selected(bvr, '%s','%s');
                ''' % (checkbox_name, key)
            }) 

            # only 1 is selected in child_mode
            if cb.is_checked():
                selected_process_names.append(value)


            if idx == 0 or idx == 10 * step:
                # add a new inner div
                inner_div = self._get_inner_div()
                process_div.add(inner_div, 'inner%s'%step)
                step += 1
                
            inner_div.add(cb)

            inner_div.add("<br/>")
            

        # if less than 10, make it wider
        if len(self.process_names) < 10:
            inner_div.add_style('width: 100px')

        # add a master private checkbox
        if not self.child_mode:
            checkbox_name = 'note_master_private_cb'
            cb = CheckboxWdg(checkbox_name, label='make notes private')
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.add_behavior({ 
                'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_uber_notes_top");
                    var tbody = top.getElements('.spt_table_tbody')[2];
                    var inputs = spt.api.Utility.get_inputs(tbody,'is_private');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                    spt.input.save_selected(bvr, '%s','%s');
                    '''%(checkbox_name, key)
                    })

            cb_span = DivWdg(cb, css='small')
            cb_span.add_styles('border-left: 1px dotted #bbb; margin-left: 10px')
            span.add(cb_span)

        main_config_view = self._get_main_config(view, selected_process_names)
        
        sobject_dict = {}

        # TODO: do a union all search or by order number = 1
        for value in selected_process_names:
            search = Search('sthpw/note')
            search.add_filter('project_code', Project.get_project_code())
            search.add_filter('context', value)
            search.add_filter('search_type',self.parent_search_type)
            search.add_filter('search_id',self.parent_search_id)
            search.add_order_by('timestamp desc')
            search.add_limit(1)
            sobject = search.get_sobject()
            if sobject:
                sobject_dict[value] = sobject
        #sobjects = search.get_sobjects()
        # virtual sobject for placeholder, we can put more than 1 maybe?
        sobject = SearchType.create('sthpw/note')

        edit_config = self._get_edit_config('edit', selected_process_names)
        edit_configs = {'sthpw/note': edit_config}
        Container.put("CellEditWdg:configs", edit_configs)

        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table',
            config=main_config_view, aux_info={'sobjects': sobject_dict, 'parent': self.parent}, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': self.search_key} )
        table.set_sobject(sobject)

        top.add(table)


        return super(NoteSheetWdg, self).get_display()
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:note_wdg.py

示例8: get_display

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

        category = "FreeformWdg"
        view = my.get_input_value("view")

        sobject = my.get_input_value("sobject")
        if not sobject and my.sobjects:
            sobject = my.sobjects[0]
        if not view:
            view = 'freeform'

        if sobject:
            search_key = sobject.get_search_key()
            search_type = sobject.get_base_search_type()

        else:
            search_key = my.get_input_value("search_key")
            search_type = my.get_input_value("search_type")

        if sobject:
            pass
        elif search_key:
            sobject = Search.get_by_search_key(search_key)
        elif search_type:
            search = Search(search_type)
            search.add_limit(1)
            sobject = search.get_sobject()
        else:
            sobject = None


        top = DivWdg()
        top.add_class("spt_freeform_top")


        search = Search("config/widget_config")
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        else:
            config_xml = ""

        if not config_xml:
            top.add("No definition found")
            return top

        config = WidgetConfig.get(view=view, xml=config_xml)
        view_attrs = config.get_view_attributes()


        bgcolor = view_attrs.get("bgcolor")
        if not bgcolor:
            bgcolor = my.get_default_background()

        if bgcolor:
            top.add_style("background", bgcolor)


        # draw the layout
        freeform_layout = my.get_canvas_display(search_type, view, config, sobject) 
        top.add(freeform_layout)

        return top
开发者ID:0-T-0,项目名称:TACTIC,代码行数:67,代码来源:freeform_layout_wdg.py


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