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


Python DatabaseImpl.get方法代码示例

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


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

示例1: import_bootstrap

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
def import_bootstrap():
    print "Importing bootstrap ..."
    vendor = "SQLServer"

    impl = DatabaseImpl.get(vendor)
    impl.create_database("sthpw")


    upgrade_dir = Environment.get_upgrade_dir()

    for category in ['bootstrap', 'sthpw', 'config']:
        f = open("%s/%s/%s_schema.sql" % (upgrade_dir, vendor.lower(), category) )
        data = f.read()
        f.close()

        data = data.split(";")

        cmds = []
        for cmd in data:
            cmd = cmd.strip()
            if cmd == '':
                continue
            cmds.append(cmd)

        from pyasm.search import DbContainer
        sql = DbContainer.get("sthpw")
        for cmd in cmds:
            sql.do_update(cmd)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:30,代码来源:bootstrap_load.py

示例2: database_exists

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
    def database_exists(my):
        '''returns whether a database exists for this project'''
        if not my.get_value("code"):
            return False

        db_resource = my.get_project_db_resource()
        impl = DatabaseImpl.get()
        return impl.database_exists(db_resource)
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:10,代码来源:project.py

示例3: load_bootstrap

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
    def load_bootstrap(my):
        impl = DatabaseImpl.get()
        exists = impl.database_exists("sthpw")
        print "exists: ", exists

        vendor = impl.get_database_type()

        if not exists:
            print "Running bootstrap"

            install_dir = Environment.get_install_dir()
            python = Config.get_value("services", "python")
            if not python:
                python = "python"

            # create the database and inject the bootstrap data
            impl.create_database("sthpw")

            cmd = "%s %s/src/pyasm/search/upgrade/%s/bootstrap_load.py" % (python, install_dir, vendor.lower())
            os.system(cmd)
开发者ID:blezek,项目名称:TACTIC,代码行数:22,代码来源:db_config_wdg.py

示例4: init_cache

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
    def init_cache(my):
        from pyasm.search import DatabaseImpl, DbContainer
        my.caches = {}

        data = {}
        for table in my.tables:
            column_data = DatabaseImpl.get().get_column_info(my.database, table)
            data[table] = column_data
        my.caches['data'] = data

        # get the order columns
        columns = {}
        sql = DbContainer.get(my.database)
        for table in my.tables:
            column_list = sql.get_columns(table)
            columns[table] = column_list

        my.caches = {}
        my.caches['data'] = data
        my.caches['columns'] = columns
开发者ID:0-T-0,项目名称:TACTIC,代码行数:22,代码来源:cache_startup.py

示例5: test_postgres

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
    def test_postgres(my, vendor):
        web = WebContainer.get_web()

        defaults = DEFAULTS[vendor]

        default_server = defaults['server']
        default_port = defaults['port']
        default_user = defaults['user']
        default_password = defaults['password']

        server = web.get_form_value("server")
        if not server:
            server = default_server
        port = web.get_form_value("port")
        if not port:
            port = default_port
        else:
            port = int(port)
        user = web.get_form_value("user")
        if not user:
            user = default_user
        password = web.get_form_value("password")
        if not password:
            password = default_password


        # Need to access remote database
        create = False
        impl = DatabaseImpl.get(vendor)
        exists = impl.database_exists("sthpw", host=server, port=port)

        if not create:
            if not exists:
                my.info['error'] = "Database [sthpw] does not exist.  This is required for TACTIC to function."

                return

        else:
            print "Running bootstrap"

            install_dir = Environment.get_install_dir()
            python = Config.get_value("services", "python")
            if not python:
                python = "python"

            # create the database and inject the bootstrap data
            impl.create_database("sthpw", host=server, port=port)

            cmd = "%s %s/src/pyasm/search/upgrade/%s/bootstrap_load.py" % (python, install_dir, vendor.lower())
            os.system(cmd)




        from pyasm.search import Sql
        sql = Sql("sthpw", server, user, password=password, vendor=vendor, port=port)
        try:
            # attempt
            sql.connect()
            sql.do_query("select id from transaction_log limit 1")
        except Exception, e:
            my.info['error'] = "Could not connect to database with (vendor=%s, server=%s, user=%s, port=%s)" % (vendor, server, user, port)
            my.info['message'] = str(e)
            print e
开发者ID:blezek,项目名称:TACTIC,代码行数:66,代码来源:db_config_wdg.py

示例6: InstallException

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
        my.create_temp_directory()

        my.change_directory_ownership()

        my.install_win32_service()


        if install_db == False:
            print "TACTIC setup successful.  Next, the TACTIC database needs to be configured."
            return

        # dynamically load modules now that we know where they are
        from pyasm.search import DatabaseImpl, DbContainer

        # create the sthpw database
        database = DatabaseImpl.get()

     

        # check if database exists
        print "Creating database '%s' ..." % project_code
        print

        db_exists = False
        from pyasm.search import DatabaseException
        try:
            if database.database_exists(project_code):
                print "... already exists. Please remove first"
                raise InstallException("Database '%s' already exists" % project_code)
                db_exists = True
        except DatabaseException, e:
开发者ID:pombredanne,项目名称:TACTIC,代码行数:33,代码来源:install.py

示例7: get_database_type

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
 def get_database_type(my):
     db_resource = my.get_project_db_resource()
     impl = DatabaseImpl.get()
     return impl.get_database_type()
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:6,代码来源:project.py

示例8: execute

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

        if not self.sobject.is_insert():
            # do nothing
            return

        project = self.sobject
        project_code = project.get_code()
        project_type = project.get_base_type()

        database = DatabaseImpl.get()

        # check if database exists
        print "Creating database '%s' ..." % project_code

        if database.database_exists(project_code):
            print "... already exists"
        else:
            # create the datbase
            database.create_database(project_code)

        # import the appropriate schema
        database.import_schema(project_code, project_type)

        # import the appropriate data
        database.import_default_data(project_code, project_type)

        # copy files from the default template
        site_dir = Environment.get_site_dir()
        install_dir = Environment.get_install_dir()
        template_dir = "%s/src/tactic_sites/template" % install_dir
        template_dir = template_dir.replace("\\","/")
        project_dir = "%s/sites/%s" % (site_dir, project_code)
        project_dir = project_dir.replace("\\","/")


        # set the update of the database to current
        project.set_value("last_db_update", Sql.get_timestamp_now(), quoted=False)
        project.commit()



        # copy all of the files from the template to the template directory
        print "Creating project directories [%s]..." % project_dir
        if not os.path.exists(template_dir):
            print "... skipping: template dir [%s] does not exist" % template_dir
            return 

        if not os.path.exists(project_dir):
            for root, dirs, files in os.walk(template_dir):
                root = root.replace("\\","/")

                # ignore ".svn"
                if root.find("/.svn") != -1:
                    continue

                for file in files:
                    # ignore compiled python files
                    if file.endswith(".pyc"):
                        continue

                    old = "%s/%s" % (root, file)
                    new = old.replace(template_dir, project_dir)

                    dirname = os.path.dirname(new)
                    System().makedirs(dirname)

                    shutil.copyfile(old,new)
        else:
            print "... skipping.  Already exists."

        print "Done."
开发者ID:mincau,项目名称:TACTIC,代码行数:74,代码来源:edit_wdg_action.py

示例9: execute

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [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: import_template

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

        if my.path:
            base_dir = os.path.dirname(my.path)
        else:
            base_dir = Environment.get_template_dir()


        version = my.kwargs.get("version")
        if version:
            template_dir = "%s/%s-%s" % (base_dir, my.template_code, version)
        else:
            template_dir = "%s/%s" % (base_dir, my.template_code)

        template_dir = my.get_template_dir(template_dir)
        
        # if the directory does not exist then look for a zip file
        use_zip = False
        if not os.path.exists(template_dir):
            template_zip = "%s.zip" % (template_dir)
            if os.path.exists(template_zip):
                use_zip = True
            else:
                hint = "Please check if you have created the Template already using the Update button in the Template Project view."
                if version:
                    raise TacticException("No template found for [%s] version [%s]. %s" % (my.template_code, version, hint))
                else:
                    raise TacticException("No template found for [%s]. %s" % (my.template_code, hint))
                    



        # check to see if the database exists in the default
        # database implementation
        from pyasm.search import DbContainer, DatabaseImpl
        impl = DatabaseImpl.get()
        exists = impl.database_exists(my.project_code)

        # if the database already exists, then raise an exception
        if exists and my.new_project:
            msg = "WARNING: Database [%s] already exists" % my.project_code
            print msg
            raise TacticException(msg)


        # this is the overriding factor:
        if my.is_template == True:
            title = Common.get_display_title(my.project_code)
        elif my.is_template == False:
            title = Common.get_display_title(my.project_code)
        elif my.is_template == None:
            # these 2 is for old usage using the command line script create_template.py
            if my.template_project_code != my.project_code:
                my.is_template = False
                title = Common.get_display_title(my.project_code)
            else:
                my.is_template = True
                title = Common.get_display_title(my.template_project_code)


        # create a new project if this was desired
        if my.new_project == True:
            from create_project_cmd import CreateProjectCmd
            project_image_path = my.kwargs.get("project_image_path")

            # the project_type will get updated properly by the PluginInstaller
            # but that break the ties to the project_type entry created though,
            # which is ok
            creator = CreateProjectCmd(
                project_code=my.project_code,
                project_title=title,
                project_type=my.template_project_code,
                is_template=my.is_template,
                use_default_side_bar=False,
                project_image_path=project_image_path
            )
            creator.execute()


        # set the project
        Project.set_project(my.project_code)

        # import from a plugin
        if use_zip:
            kwargs = {
                'zip_path': template_zip,
                'code': my.project_code
            }

        else:
            kwargs = {
                'plugin_dir': template_dir
            }


        kwargs['filter_line_handler'] = my.filter_line_handler
        kwargs['filter_sobject_handler'] = my.filter_sobject_handler

        from plugin import PluginCreator, PluginInstaller
        installer = PluginInstaller( **kwargs )
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:project_template_cmd.py

示例11: get_database_type

# 需要导入模块: from pyasm.search import DatabaseImpl [as 别名]
# 或者: from pyasm.search.DatabaseImpl import get [as 别名]
 def get_database_type(self):
     db_resource = self.get_project_db_resource()
     impl = DatabaseImpl.get()
     return impl.get_database_type()
开发者ID:mincau,项目名称:TACTIC,代码行数:6,代码来源:project.py


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