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


Python Search.set_show_retired方法代码示例

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


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

示例1: execute

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

        database = my.db_resource.get_database()

        from pyasm.search import Insert, Select, DbContainer, Search, Sql

        # get the data
        if not my.sobjects:
            search = Search("sthpw/search_object")

            # BAD assumption
            #search.add_filter("table", my.table)
            # create a search_type. This is bad assumption cuz it assumes project-specific search_type
            # should call set_search_type()
            if not my.search_type:
                my.search_type = "%s/%s" % (my.database, my.table)
            search.add_filter("search_type", my.search_type)

            my.search_type_obj = search.get_sobject()
            if not my.search_type_obj:
                if my.no_exception == False:
                    raise SqlException("Table [%s] does not have a corresponding search_type" % my.table)
                else:
                    return

            search_type = my.search_type_obj.get_base_key()
            search = Search(my.search_type)
            search.set_show_retired(True)
            my.sobjects = search.get_sobjects()
            
        # get the info for the table
        column_info = SearchType.get_column_info(my.search_type)

        for sobject in my.sobjects:
            print my.delimiter

            insert = Insert()
            insert.set_database(my.database)
            insert.set_table(my.table)

            data = sobject.data
            for name, value in data.items():

                if name in my.ignore_columns:
                    continue

                if not my.include_id and name == "id":
                    insert.set_value("id", '"%s_id_seq".nextval' % table, quoted=False)
                    #insert.set_value(name, value, quoted=False)
                elif value == None:
                    continue
                else:
                    # replace all of the \ with double \\
                    insert.set_value(name, value)

            print "%s" % insert.get_statement()
            print my.end_delimiter
            print
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:62,代码来源:sql_dumper.py

示例2: execute

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

        search = Search(Submission)
        search.set_show_retired(True)
        submissions = search.get_sobjects()

        for submission in submissions:
            snapshot = Snapshot.get_latest_by_sobject(submission, "publish")
            paths = snapshot.get_all_lib_paths()

            bins = submission.get_bins()
            if not bins:
                 print "Bin for submissin [%s] does not exist" % submission.get_id()
                 continue
            bin = bins[0]
            code = bin.get_code()
            type = bin.get_value("type")
            label = bin.get_value("label")

            for path in paths:
                if not os.path.exists(path):
                    print "WARNING: path '%s' does not exist" % path
                    continue

                dirname = os.path.dirname(path)
                basename = os.path.basename(path)
                
                new_dirname = "%s/%s/%s/%s" % (dirname,type,label,code)
                if not os.path.exists(new_dirname):
                    os.makedirs(new_dirname)

                new_path = "%s/%s" % (new_dirname, basename)

                print new_path
                FileUndo.move(path, new_path)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:37,代码来源:fix_submission.py

示例3: init_cache

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def init_cache(self):
        '''initialize the cache'''
        self.mtime = datetime.datetime.now()

        keys = self.caches.keys()
        self.caches = {}

        search = Search(self.search_type)
        search.set_show_retired(True)
        self.sobjects = search.get_sobjects()


        # build a search_key cache
        search_key_cache = {}
        search_keys = SearchKey.get_by_sobjects(self.sobjects)
        for search_key, sobject in zip(search_keys, self.sobjects):
            search_key_cache[search_key] = sobject
        self.caches['search_key'] = search_key_cache

        code_cache = {}
        for sobject in self.sobjects:
            code = sobject.get_code()
            code_cache[code] = sobject
        self.caches['code'] = code_cache 

        for key in keys:
            if key in ['search_key', 'code']:
                continue
            self.build_cache_by_column(key)
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:cache.py

示例4: get_sobjects_by_node

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def get_sobjects_by_node(my, node):
        # get the sobjects        
        search_type = my.xml.get_attribute(node, "search_type")
        expr = my.xml.get_attribute(node, "expression")
        code = my.xml.get_attribute(node, "code")


        if expr:
            sobjects = Search.eval(expr)

        elif search_type:
            search = Search(search_type)
            search.set_show_retired(True)
            if code:
                search.add_filter("code", code)


            # have some specific attributes for specific search types
            # can use wildcards like % and *
            if search_type == 'config/widget_config':
                view = Xml.get_attribute(node, "view")
                if view:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)

                    if view.find("%") != -1 or view.find("*") != -1:
                        view = view.replace("*", "%")
                        view = view.replace("/", ".")
                        search.add_filter("view", view, op="like")
                    else:
                        search.add_filter("view", view)

            elif search_type == 'config/url':
                url = Xml.get_attribute(node, "url")
                if url:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)
                    if url.find("%") != -1:
                        search.add_filter("url", url, op="like")
                    else:
                        search.add_filter("url", url)
 


            search.add_order_by("id")
            sobjects = search.get_sobjects()
        else:
            sobjects = []


        return sobjects
开发者ID:blezek,项目名称:TACTIC,代码行数:53,代码来源:plugin.py

示例5: execute_mms_oracle_dump

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def execute_mms_oracle_dump(my):
        assert my.db_resource
        assert my.table

        database = my.db_resource.get_database()

        if not my.sql_out_fp or not my.pl_sql_var_out_fp or not my.pl_sql_ins_out_fp:
            raise Exception("SQL and PL-SQL file pointers are required for generating output.")

        from pyasm.search import Insert, Select, DbContainer, Search, Sql

        # get the data
        if not my.sobjects:
            search = Search("sthpw/search_object")
            search.add_filter("table_name", my.table)
            my.search_type_obj = search.get_sobject()
            if not my.search_type_obj:
                if my.no_exception == False:
                    raise Exception("Table [%s] does not have a corresponding search_type" % my.table)
                else:
                    return

            search_type = my.search_type_obj.get_base_key()
            search = Search(search_type)
            search.set_show_retired(True)
            my.sobjects = search.get_sobjects()

        # get the info for the table
        column_info = my.search_type_obj.get_column_info()

        for sobject in my.sobjects:

            column_list = []
            value_list = []
            update_col_list = []
            update_map = {}

            timestamp_regex = re.compile("^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})")

            data = sobject.data
            sobject_id = data.get("id")
            do_pl_sql = False
            for name, value in data.items():
                if value == None:
                    continue
                else:
                    col_name = '"%s"' % name
                    column_list.append(col_name)

                    if isinstance(value, types.StringTypes):
                        if timestamp_regex.match(value):
                            value_list.append( "TO_TIMESTAMP('%s','RR-MM-DD HH24:MI:SS')" %
                                    str(value).split('.')[0][2:] )
                        else:
                            new_value = my.get_oracle_friendly_string_value( value )
                            if len(new_value) > 3800:
                            #{
                                do_pl_sql = True
                                var_name = "%s_%s_%s__var" % \
                                                ( my.table, col_name.replace('"',''), str(sobject_id).zfill(5) )

                                my.pl_sql_var_out_fp.write( "\n%s VARCHAR2(%s) := %s ;\n" %
                                                                (var_name, len(new_value), new_value) )
                                new_value = var_name
                            #}
                            value_list.append( new_value )


                    # elif type(value) == datetime.datetime:
                    #     value_list.append( "TO_TIMESTAMP('%s','RR-MM-DD HH24:MI:SS.FF')" %
                    #             str(value).split('.')[0][2:] )
                    else:
                        value_list.append( "%s" % value )

            if do_pl_sql:
                my.pl_sql_ins_out_fp.write( '\n' )
                from sql import Sql
                if database_type == "SQLServer":
                    my.pl_sql_ins_out_fp.write( 'INSERT INTO "%s" (%s) VALUES (%s);\n' %
                                        (my.database, my.table, ','.join(column_list), ','.join(value_list)) )
                else:
                    my.pl_sql_ins_out_fp.write( 'INSERT INTO "%s" (%s) VALUES (%s);\n' %
                                        (my.table, ','.join(column_list), ','.join(value_list)) )
            else:
                my.sql_out_fp.write( '\n' )
                from sql import Sql
                if database_type == "SQLServer":
                    my.sql_out_fp.write( 'INSERT INTO "%s" (%s) VALUES (%s);\n' %
                                        (my.database, my.table, ','.join(column_list), ','.join(value_list)) )
                else:
                    my.sql_out_fp.write( 'INSERT INTO "%s" (%s) VALUES (%s);\n' %
                                        (my.table, ','.join(column_list), ','.join(value_list)) )
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:94,代码来源:sql_dumper.py

示例6: dump_tactic_inserts

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def dump_tactic_inserts(my, path, mode='sql'):
        assert my.db_resource
        assert my.table

        database = my.db_resource.get_database()

        assert mode in ['sql', 'sobject']

        if path:
            import os
            dirname = os.path.dirname(path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
      
            #f = open(path, 'w')
            #f = codecs.open(path, 'a', 'utf-8')
            UTF8Writer = codecs.getwriter('utf8')
            f = UTF8Writer(open(path, 'ab'))
        else:
            import sys
            f = sys.stdout

        from pyasm.search import Insert, Select, DbContainer, Search, Sql

        # get the data
        if not my.sobjects:
            search = Search("sthpw/search_object")
            search.add_filter("table_name", my.table)
            search.add_order_by("id")
            my.search_type_obj = search.get_sobject()
            if not my.search_type_obj:
                if my.no_exception == False:
                    raise Exception("Table [%s] does not have a corresponding search_type" % my.table)
                else:
                    return

            search_type = my.search_type_obj.get_base_key()
            search = Search(search_type)
            search.set_show_retired(True)
            my.sobjects = search.get_sobjects()
            
        # get the info for the table
        from pyasm.search import SearchType, Sql
        column_info = SearchType.get_column_info(my.search_type)

        for sobject in my.sobjects:
            f.write( "%s\n" % my.delimiter )


            if mode == 'sobject':
                search_type = sobject.get_base_search_type()
                f.write("insert = SearchType.create('%s')\n" % search_type)
            else:
                f.write("insert.set_table('%s')\n" % my.table)

            data = sobject.get_data()
            for name, value in data.items():
                if name in my.ignore_columns:
                    continue

                if name == '_tmp_spt_rownum':
                    continue
                if not my.include_id and name == "id":
                    #insert.set_value("id", '"%s_id_seq".nextval' % table, quoted=False)
                    pass
                elif value == None:
                    continue
                else:
                    # This is not strong enough
                    #if value.startswith("{") and value.endswith("}"):
                    #    f.write("insert.set_expr_value('%s', \"\"\"%s\"\"\")\n" % (name, value))
                    if type(value) == types.IntType or \
                            type(value) == types.FloatType or \
                            type(value) == types.BooleanType or \
                            type(value) == types.LongType:

                        f.write("insert.set_value('%s', %s)\n" % (name, value))
                    else:    
                        # if the value contains triple double quotes, convert to
                        # triple quotes
                        if isinstance(value, datetime.datetime):
                            value = str(value)
                        elif isinstance(value, unicode):
                            #value = str(value)
                            value = value.encode("UTF-8")

                        # this fixes a problem with non-ascii characters
                        if isinstance(value, basestring):
                            quoted = value.startswith('"') and value.endswith('"')
                            value = repr(value)
                            quoted2 = value.startswith('"') and value.endswith('"')
                            if not quoted and quoted2:
                                value = value.strip('"')


                            # repr puts single quotes at the start and end
                            if value.startswith("'") and value.endswith("'"):
                                value = value[1:-1]
                            # and it puts a slash in front
                            value = value.replace(r"\'", "'")
#.........这里部分代码省略.........
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:103,代码来源:sql_dumper.py

示例7: get_data

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def get_data(self):
        """
        <element name='work_location' title='Originating Site'>
          <display class='tactic.ui.table.ExpressionElementWdg'>
            <expression>@GET(MMS/work_location.location)</expression>
            <alt_expression>@GET(MMS/work_location.id)</alt_expression>
            <order_by>work_location.location</order_by>
          </display>
        </element>
        """


        data = {}

        sobjects = self.sobjects
        if not sobjects:
            return data

        #template = "MMS/subtask.MMS/job.MMS/request.MMS/security_classification"
        template = self.get_option("template")
        keys = template.split(".")

        # get the sobjects (main search)
        search_type_obj = sobjects[0].get_search_type_obj()
        join_table = search_type_obj.get_table()
        search_type = search_type_obj.get_value("search_type")

        if keys[0] != search_type:
            keys.insert(0, search_type)

        search_ids = []
        for sobject in sobjects:
            search_id = sobject.get_id()
            search_ids.append(search_id)


        keys.reverse()

        # create main search
        search = Search(keys[0])
        table = search.get_table()

        # add the columns
        search.add_column("*", table=table)
        # add the id column from the joined table
        search.add_column("id", table=join_table, as_column='%s_id' % join_table)

        current_key = None
        for i in range(1, len(keys)):
            key = keys[i]
            namespace, table = key.split("/")
            search.add_join(key, current_key)

            current_key = key

        search.add_filters("id", search_ids, table=table)
        search.set_show_retired(True)

        results = search.get_sobjects()

        # make into a dictionary based on search id
        for result in results:
            id = result.get_value("%s_id" % join_table)
            data[id] = result
            print id, result.get_data()

        print "results: ", len(results)
        return data
开发者ID:mincau,项目名称:TACTIC,代码行数:70,代码来源:related_element_wdg.py

示例8: get_display

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

#.........这里部分代码省略.........

        # get all of the assets
        search = Search(self.search_type)
        
        if sobject_filter:
            sobject_filter.alter_search(search)

        if shot_filter:
            shot_statuses = shot_filter.get_statuses()
            shot_statuses_selected = shot_filter.get_values()
            if shot_statuses != shot_statuses_selected:
                search.add_filters("status", shot_filter.get_values() )

        assets = search.get_sobjects()
        
        if not assets:
            # drawing the empty table prevents the loss of some prefs data
            table = TableWdg("sthpw/task", self.task_view)
            #widget.add(HtmlElement.h3("No assets found"))
            widget.add(table)
            return widget

        # this assumes looking at one project only
        project_search_type = assets[0].get_search_type()
        
        ids = SObject.get_values(assets, 'id')

        # get all of the tasks
        search = Search("sthpw/task")
        if processed_start_date and start_date_wdg.get_value(True) != self.INVALID:
            search.add_where("(bid_start_date >= '%s' or actual_start_date >='%s')" \
                % (processed_start_date, processed_start_date))
        if processed_end_date and end_date_wdg.get_value(True) != self.INVALID:
            search.add_where("(bid_end_date <= '%s' or actual_end_date <='%s')" \
                % (processed_end_date, processed_end_date))

        # filter out sub pipeline tasks
        if not sub_task_cb.is_checked():
            search.add_regex_filter('process', '/', op='NEQ')

        search.add_filter("search_type", project_search_type)
        search.add_filters("search_id", ids )

        # order by the search ids of the asset as the were defined in the
        # previous search
        search.add_enum_order_by("search_id", ids)


        if user != "":
            search.add_filter("assigned", user)
        if milestone != "":
            search.add_filter("milestone_code", milestone)
        
        process_filter.alter_search(search)
        
        task_search_filter.alter_search(search)
       
        if not self.show_all_task_approvals:
            #task_filter = TaskStatusFilterWdg(task_pipeline="task")
            #widget.add(task_filter)
            task_statuses = task_filter.get_processes()
            task_statuses_selected = task_filter.get_values()
           
            # one way to show tasks with obsolete statuses when the user
            # check all the task status checkboxes
            if task_statuses != task_statuses_selected:
                search.add_filters("status", task_filter.get_values() )

            


        # filter for retired ...
        # NOTE: this must be above the search limit filter
        # because it uses a get count which commits the retired flag
        if retired_filter.get_value() == 'true':
            search.set_show_retired(True)

        
        # alter_search() will run set_search() implicitly
        search_limit.alter_search(search)

        # define the table
        table = TableWdg("sthpw/task", self.task_view)

        # get all of the tasks
        tasks = search.get_sobjects()
        sorted_tasks = self.process_tasks(tasks, search)

        widget.add( HtmlElement.br() )

        table.set_sobjects(sorted_tasks)

        # make some adjustments to the calendar widget
        calendar_wdg = table.get_widget("schedule")
        for name,value in self.calendar_options.items():
            calendar_wdg.set_option(name, value)

        widget.add(table)

        return widget
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:task_manager_wdg.py

示例9: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired [as 别名]
    def execute(my):
        error_list = []
        from pyasm.biz import Project
        Project.clear_cache()

        sthpw_search = Search("sthpw/project")
        sthpw_search.add_filter('code','sthpw')
        sthpw_search.set_show_retired(True)
        sthpw_proj = sthpw_search.get_sobject()

        search = Search("sthpw/project")
        if my.project_code:
            search.add_filter("code", my.project_code)
        else:
            #search.add_enum_order_by("type", ['sthpw','prod','game','design','simple', 'unittest'])
            search.add_enum_order_by("code", ['sthpw'])
        projects = search.get_sobjects()

        project_codes = SObject.get_values(projects, 'code')
        # append sthpw project in case it's retired
        if 'sthpw' not in project_codes and sthpw_proj:
            if not my.project_code:
                projects.insert(0, sthpw_proj)
            sthpw_proj.reactivate()



        current_dir = os.getcwd()
        tmp_dir = Environment.get_tmp_dir()
        output_file = '%s/upgrade_output.txt' % tmp_dir
        if not os.path.exists(tmp_dir):
            os.makedirs(tmp_dir)
        elif os.path.exists(output_file):
            os.unlink(output_file)
        ofile = open(output_file, 'w')

        import datetime
        ofile.write('Upgrade Time: %s\n\n' %datetime.datetime.now())



        # dynamically generate
        #sql = DbContainer.get(code)
        database_type = Sql.get_default_database_type()
        #if database_type in ['Sqlite', 'MySQL']:
        if database_type != "PostgreSQL":
            # general an upgrade
            import imp

            namespaces = ['default', 'simple', 'sthpw', 'config']
            for namespace in namespaces:
                if database_type == 'Sqlite':
                    from pyasm.search.upgrade.sqlite import convert_sqlite_upgrade
                    file_path = convert_sqlite_upgrade(namespace)
                elif database_type == 'MySQL':
                    from pyasm.search.upgrade.mysql import convert_mysql_upgrade
                    file_path = convert_mysql_upgrade(namespace)
                elif database_type == 'SQLServer':
                    from pyasm.search.upgrade.sqlserver import convert_sqlserver_upgrade
                    file_path = convert_sqlserver_upgrade(namespace)
                elif database_type == 'Oracle':
                    file_path = convert_oracle_upgrade(namespace)
                else:
                    raise Exception("Database type not implemented here")

                (path, name) = os.path.split(file_path)
                (name, ext) = os.path.splitext(name)
                (file, filename, data) = imp.find_module(name, [path])
                module = imp.load_module(name, file, filename, data)

                class_name = "%s%sUpgrade" % (database_type,namespace.capitalize())
                exec("%s = module.%s" % (class_name, class_name) )



        # load all the default modules
        from pyasm.search.upgrade.project import *

        for project in projects:
            
            code = project.get_code()
            if code == "sthpw":
                type = "sthpw"
            else:
                type = project.get_type()

            if not type:
                type = 'default'


            if not my.quiet:
                print project.get_code(), type
                print "-"*30

            # if the project is admin, the just ignore for now
            if code == 'admin':
                continue
            
            if not project.database_exists():
                ofile.write("*" * 80 + '\n')
#.........这里部分代码省略.........
开发者ID:blezek,项目名称:TACTIC,代码行数:103,代码来源:upgrade_db.py

示例10: Batch

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

import tacticenv
from pyasm.security import Batch, Login
from pyasm.search import Search, SearchType

Batch()

search = Search("sthpw/login")
search.add_filter("login", "admin")
admin = search.get_sobject()

password = Login.get_default_encrypted_password()

if not admin:
    search.set_show_retired(True)
    admin = search.get_sobject(redo=True)

if not admin:
    # create missing admin entry
    admin = SearchType.create('sthpw/login')
    admin.set_value('login','admin')

admin.set_value("password", password)
admin.commit()

print "Successfully reset admin password.  You will be prompted to change it on startup of TACTIC."
raw_input()

开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:reset_admin_password.py


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