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


Python Config.set_value方法代码示例

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


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

示例1: execute

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

        # save prefix
        local_prefix = self.get_value("local_prefix")
        self.server_prefix = Config.get_value("install", "server")

        if not local_prefix and not self.server_prefix:
            raise TacticException("Cannot have empty local server prefix")

        if local_prefix and local_prefix != self.server_prefix:
            Config.set_value("install", "server", local_prefix)

            Config.save_config()

        self.project_code = self.get_value("project")
        if not self.project_code:
            self.project_code = Project.get_project_code()


        # create a share
        share = SearchType.create("sthpw/sync_server")
        self.handle_info(share)
        self.handle_sync_mode(share)

        share.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:sync_settings_wdg.py

示例2: _test_cache

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def _test_cache(self):
        from pyasm.common import Config

        Config.set_value("security", "mode", "cache", no_exception=True)
        #Config.set_value("security", "authenticate_class", "pyasm.security.authenticate_test.AutocreateAuthenticate", no_exception=True)
        Config.set_value("security", "authenticate_class", "pyasm.security.mms_authenticate.MMSAuthenticate", no_exception=True)
        mode = Config.get_value("security", "authenticate_class", use_cache=False)

        mode = Config.get_value("security", "mode", use_cache=False)
        self.assertEquals(mode, "cache")


        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertEquals(None, login)


        from pyasm.search import Transaction
        transaction = Transaction.get(create=True)
        transaction.start()

        self.security.login_user("foofoo", "wow")

        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertNotEquals(None, login)
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:authenticate_test.py

示例3: _test_base_dir_alias

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def _test_base_dir_alias(my):

        Config.set_value("checkin", "asset_base_dir", {
            'default': '/tmp/tactic/default',
            'alias': '/tmp/tactic/alias',
            'alias2': '/tmp/tactic/alias2',
        });
        asset_dict = Environment.get_asset_dirs()
        default_dir = asset_dict.get("default")
        my.assertEquals( "/tmp/tactic/default", default_dir)

        aliases = asset_dict.keys()
        # "plugins" is assumed in some branch 
        if 'plugins' in aliases:
            my.assertEquals( 4, len(aliases))
        else:
            my.assertEquals( 3, len(aliases))
        my.assertNotEquals( None, "alias" in aliases )

        # create a naming
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "alias")
        naming.set_value("dir_naming", "alias")
        naming.set_value("file_naming", "text.txt")
        naming.set_value("base_dir_alias", "alias")
        naming.commit()

        # create 2nd naming where 
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "alias2")
        naming.set_value("dir_naming", "alias2")
        naming.set_value("base_dir_alias", "alias2")
        naming.set_value("file_naming", "text.txt")
        naming.set_value("checkin_type", "auto")
        naming.commit()

        my.clear_naming()

        # create a new test.txt file
        for context in ['alias', 'alias2']:
            file_path = "./test.txt"
            file = open(file_path, 'w')
            file.write("whatever")
            file.close()

            checkin = FileCheckin(my.person, file_path, context=context)
            checkin.execute()
            snapshot = checkin.get_snapshot()

            lib_dir = snapshot.get_lib_dir()
            expected = "/tmp/tactic/%s/%s" % (context, context)
            my.assertEquals(expected, lib_dir)

            path = "%s/text.txt" % (lib_dir)
            exists = os.path.exists(path)
            my.assertEquals(True, exists)
开发者ID:hellios78,项目名称:TACTIC,代码行数:60,代码来源:checkin_test.py

示例4: configure_palette

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_palette(my):

        web = WebContainer.get_web()
        palette = web.get_form_value("look/palette")

        if palette:
            Config.set_value("look", "palette", palette)
        else:
            Config.set_value("look", "palette", "")
开发者ID:blezek,项目名称:TACTIC,代码行数:11,代码来源:db_config_wdg.py

示例5: configure_palette

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_palette(my):
        my.section = 'Look and Feel'
        web = WebContainer.get_web()
        palette = web.get_form_value("look/palette")

        if palette:
            Config.set_value("look", "palette", palette)
        else:
            Config.set_value("look", "palette", "")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:db_config_wdg.py

示例6: configure_services

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_services(my):

        web = WebContainer.get_web()

        options = ['server', '_user', '_password', '_port', '_tls_enabled','_sender_disabled']
        for option in options:
            server = web.get_form_value("services/mail%s" %option)

            if server:
                Config.set_value("services", "mail%s" %option, server)
            else:
                #Config.remove("services", "mail%s"%option)
                Config.set_value("services", "mail%s"%option,  "")
开发者ID:blezek,项目名称:TACTIC,代码行数:15,代码来源:db_config_wdg.py

示例7: configure_gen_services

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_gen_services(my):
        my.section = 'Services'
        web = WebContainer.get_web()

        options = ['process_count', 'process_time_alive', 'thread_count', 'python_path','rsync']
        for option in options:
            value = web.get_form_value("services/%s" %option)

            if value:
                Config.set_value("services", option, value)
            else:
                
                Config.set_value("services", option,  "")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:15,代码来源:db_config_wdg.py

示例8: configure_security

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_security(my):
        my.section = 'Security'
        web = WebContainer.get_web()

        options = ['allow_guest','ticket_expiry','authenticate_mode',
            'authenticate_class','authenticate_version','auto_create_user',
            'api_require_password','api_password','max_login_attempt','account_logout_duration']
        for option in options:
            security_value = web.get_form_value("security/%s" %option)

            if security_value:
                Config.set_value("security", option, security_value)
            else:
                Config.set_value("security", option,  "")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:16,代码来源:db_config_wdg.py

示例9: configure_asset_dir

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_asset_dir(my):

        web = WebContainer.get_web()
        keys = web.get_form_keys()
        option_list = []
        for key in keys:
            if key.startswith('checkin/'):
                key = key.replace('checkin/','')
                option_list.append(key)
  
        asset_dir = web.get_form_value("checkin/asset_base_dir")
        if asset_dir != None:
            if asset_dir and not os.path.exists(asset_dir):
                os.makedirs(asset_dir)
            Config.set_value("checkin", "asset_base_dir", asset_dir)

        if 'asset_base_dir' in option_list:
            option_list.remove('asset_base_dir')

        for item_dir in option_list:
            item_in_list=web.get_form_value('checkin/%s'%item_dir)
            if item_in_list:
                Config.set_value("checkin", '%s'%item_dir, item_in_list)
            else:
                Config.set_value("checkin", '%s'%item_dir, "")
开发者ID:blezek,项目名称:TACTIC,代码行数:27,代码来源:db_config_wdg.py

示例10: _test_autocreate

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def _test_autocreate(self):
        from pyasm.common import Config

        Config.set_value("security", "mode", "autocreate", no_exception=True)
        Config.set_value("security", "authenticate_class", "pyasm.security.authenticate_test.AutocreateAuthenticate", no_exception=True)

        mode = Config.get_value("security", "mode", use_cache=False)
        self.assertEquals(mode, "autocreate")



        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertEquals(None, login)


        from pyasm.search import Transaction
        transaction = Transaction.get(create=True)
        transaction.start()

        self.security.login_user("foofoo", "wow")

        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertNotEquals(None, login)

        email = login.get_value("email")
        self.assertEquals("[email protected]", email)

        transaction.rollback()

        # after rollback, this user should not exist
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertEquals(None, login)
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:authenticate_test.py

示例11: execute

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def execute(self):
        web = WebContainer.get_web()

        xml_string = Config.get_xml_data().to_string()

        keys = web.get_form_keys()
        for key in keys:
            value = web.get_form_value(key)

            is_config_key = key.find("/") != -1

            if key == "database/password":
                self.handle_password()

            elif is_config_key:
                module_name, key = key.split("/")
                Config.set_value(module_name, key, value )


        xml_string2 = Config.get_xml_data().to_string()

        if xml_string2 != xml_string:
            Config.save_config()
开发者ID:mincau,项目名称:TACTIC,代码行数:25,代码来源:setup_manager_wdg.py

示例12: configure_install

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_install(my):

        web = WebContainer.get_web()

        default_project = web.get_form_value("install/default_project")
        tmp_dir = web.get_form_value("install/tmp_dir")
        if tmp_dir:
            Config.set_value("install", "tmp_dir", tmp_dir)
        else:
            Config.set_value("install", "tmp_dir", '')

        if default_project:
            Config.set_value("install", "default_project", default_project)
        else:
            Config.remove("install", "default_project")
开发者ID:blezek,项目名称:TACTIC,代码行数:17,代码来源:db_config_wdg.py

示例13: configure_db

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def configure_db(my):

        web = WebContainer.get_web()

        vendor = web.get_form_value("database/vendor")

        if vendor == 'Sqlite':
            # take the current files and copy them to the database folder
            db_dir = web.get_form_value("database/sqlite_db_dir")
            if not db_dir:
                raise TacticException("No Folder configured for Sqlite Database")

            if not os.path.exists(db_dir):
                os.makedirs(db_dir)

            # check to see if the sthpw database is in this folder
            sthpw_path = "%s/sthpw.db" % (db_dir)
            if not os.path.exists(sthpw_path):
                # copy the default database over
                install_dir = Environment.get_install_dir()
                template_db = "%s/src/install/start/db/sthpw.db" % install_dir
                shutil.copy(template_db, db_dir)

            Config.set_value("database", "sqlite_db_dir", db_dir)

            Config.remove("database", "server")
            Config.remove("database", "port")
            Config.remove("database", "user")
            Config.remove("database", "password")


        else:
            defaults = DEFAULTS[vendor]

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

            Config.remove("database", "sqlite_db_dir")

            # get the info
            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


            if server:
                Config.set_value("database", "server", server)
            else:
                #Config.remove("database", "server")
                Config.set_value("database", "server", "")

            if port:
                Config.set_value("database", "port", port)
            else:
                #Config.remove("database", "port")
                Config.set_value("database", "port", "")

            if user:
                Config.set_value("database", "user", user)
            else:
                #Config.remove("database", "user")
                Config.set_value("database", "user", "")

            if password:
                Config.set_value("database", "password", password)
            else:
                Config.set_value("database", "password", "")
                #Config.remove("database", "password")

        # save the database
        Config.set_value("database", "vendor", vendor)
开发者ID:blezek,项目名称:TACTIC,代码行数:86,代码来源:db_config_wdg.py

示例14: ask_questions

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import set_value [as 别名]
    def ask_questions(my):

        # set vendor
        default_vendor = Config.get_value("database", "vendor")
        print
        print "Please enter the database vendor (PostgreSQL or Oracle):"
        print
        while 1:
            if not default_vendor:
                default_vendor = "PostgreSQL"
            vendor = raw_input("(%s) -> " % default_vendor)
            if not vendor:
                vendor = default_vendor
            print

            if vendor in ['PostgreSQL', 'Oracle']:
                break
            else:
                print "ERROR: Vendor must one of 'PostgreSQL' or 'Oracle'"
                print


        # set server
        default_server = Config.get_value("database", "server")
        if not default_server:
            default_server = "localhost"
        print
        print "Please enter database server hostname or IP address:"
        print
        server = raw_input("(%s) -> " % default_server)
        if not server:
            server = default_server
        print



        # set the user
        default_user = Config.get_value("database", "user")
        if not default_user:
            default_user = "__EMPTY__"
        print
        print "Please enter user name accessing the database:"
        if vendor == "Oracle":
            print "    (To access Oracle using schema names, type '__EMPTY__')"
        print
        user = raw_input("(%s) -> " % default_user)
        if not user:
            user = default_user
        print



        # set password
        from pyasm.search import DbPasswordUtil
        current_password = DbPasswordUtil.get_password()
        password = 0
        password2 = 1
        print
        print "Please enter database password:"
        print "  (ENTER to keep password, '__EMPTY__' for empty password)"

        import getpass
        while password != password2:
            print
            password = getpass.getpass("Enter Password -> ")

            if password:
                password2 = getpass.getpass("Confirm Password -> ")
            else:
                password = current_password
                password2 = password
                break

            print

            if password == password2:
                break
            else:
                print "ERROR: Passwords do not match"


        # Summary:
        print
        print "Vendor:   [%s]" % vendor
        print "Server:   [%s]" % server
        print "User:     [%s]" % user
        print

        ok = raw_input("Save to config (N/y) -> ")
        if ok.lower() != "y":
            print "Aborted"
            return


        # save the info
        from pyasm.search import DbPasswordUtil
        DbPasswordUtil.set_password(password)

        Config.set_value("database", "vendor", vendor)
        Config.set_value("database", "server", server)
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:change_db_info.py

示例15: execute

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

        project_code = self.kwargs.get('project_code')
        project_title = self.kwargs.get('project_title')
        project_type = self.kwargs.get('project_type')
        project_description = self.kwargs.get("description")
        if not project_type:
            project_type = "simple"

        is_template = self.kwargs.get('is_template')
        project_theme = self.kwargs.get('project_theme')

        use_default_side_bar = self.kwargs.get('use_default_side_bar')
        if use_default_side_bar in [False, 'false']:
            use_default_side_bar = False
        else:
            use_default_side_bar = True


        assert project_code
        assert project_type
        if project_type:
            # check to see if it exists
            search = Search("sthpw/project_type")
            search.add_filter("code", project_type)
            project_type_sobj = search.get_sobject()
            if not project_type_sobj:

                # just create a default one in this case if it is named
                # after the project code
                if not is_template and project_type == project_code:
                    project_type = 'default'
                    
                # create a new project type
                search = Search("sthpw/project_type")
                search.add_filter("code", project_type)
                project_type_sobj = search.get_sobject()
                if not project_type_sobj:
                    project_type_sobj = SearchType.create("sthpw/project_type")
                    project_type_sobj.set_value("code", project_type)
                    project_type_sobj.set_value("type", "simple")

                    project_type_sobj.commit()

        # set the current project to Admin
        Project.set_project("admin")


        # create a new project sobject
        project = SearchType.create("sthpw/project")
        project.set_value("code", project_code)
        project.set_value("title", project_title)
        project.set_value("type", project_type)
        if project_description:
            project.set_value("description", project_description)
        # set the update of the database to current (this is obsolete)
        #project.set_value("last_db_update", "now()")
        project.set_value("last_version_update", "2.5.0.v01")

        if is_template in ['true', True, 'True']:
            project.set_value("is_template", True)
        else:
            project.set_value("is_template", False)


        if project_type != "default":
            category = Common.get_display_title(project_type)
            project.set_value("category", category)


        project.commit()
       
 

        # if there is an image, check it in
        upload_path = self.kwargs.get("project_image_path")
        if upload_path:
            if not os.path.exists(upload_path):
                raise TacticException("Cannot find upload image for project [%s]" % upload_path)
            file_type = 'main'

            file_paths = [upload_path]
            file_types = [file_type]

            source_paths = [upload_path]
            from pyasm.biz import IconCreator
            if os.path.isfile(upload_path):
                icon_creator = IconCreator(upload_path)
                icon_creator.execute()

                web_path = icon_creator.get_web_path()
                icon_path = icon_creator.get_icon_path()
                if web_path:
                    file_paths = [upload_path, web_path, icon_path]
                    file_types = [file_type, 'web', 'icon']

            from pyasm.checkin import FileCheckin
            checkin = FileCheckin(project, context='icon', file_paths=file_paths, file_types=file_types)
            checkin.execute()

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


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