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


Python Config.get_config_path方法代码示例

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


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

示例1: execute

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

        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        # read the current config file.


        # copy config to the path
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            print "Installing default config file"

            dirname = os.path.dirname(config_path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            if os.name == 'nt':
                osname = 'win32'
            else:
                osname = 'linux'

            install_dir = Environment.get_install_dir()
            install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)

            shutil.copy(install_config_path, dirname)

        try:
            self.configure_db()
            self.configure_install()
            self.configure_mail_services()
            self.configure_gen_services()
            self.configure_asset_dir()
            self.configure_palette()
            self.configure_security()
        except Exception as e:
            raise TacticException('Error in [%s]: %s'%(self.section, e.__str__()))
        # FIXME: if this all fails, then revert back
        
        self.save_config()

        # after saving the config, test the database
        self.load_bootstrap()

        # remove the first run file
        data_dir = Environment.get_data_dir()
        path = "%s/first_run" % data_dir
        if os.path.exists(path):
            os.unlink(path)


        self.restart_program()
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:db_config_wdg.py

示例2: execute

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


        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        # read the current config file.


        # copy config to the path
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            print "Installing default config file"

            dirname = os.path.dirname(config_path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            if os.name == 'nt':
                osname = 'win32'
            else:
                osname = 'linux'

            install_dir = Environment.get_install_dir()
            install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)

            shutil.copy(install_config_path, dirname)

        my.configure_db()
        my.configure_install()
        my.configure_services()
        my.configure_asset_dir()
        my.configure_palette()
        # FIXME: if this all fails, then revert back
        my.save_config()

        # after saving the config, test the database
        my.load_bootstrap()

        # remove the first run file
        data_dir = Environment.get_data_dir()
        path = "%s/first_run" % data_dir
        if os.path.exists(path):
            os.unlink(path)


        my.restart_program()
开发者ID:blezek,项目名称:TACTIC,代码行数:52,代码来源:db_config_wdg.py

示例3: execute

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_config_path [as 别名]
    def execute(my):
        my.section = None

        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        # read the current config file.


        # copy config to the path
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            print "Installing default config file"

            dirname = os.path.dirname(config_path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            if os.name == 'nt':
                osname = 'win32'
            else:
                osname = 'linux'

            install_dir = Environment.get_install_dir()
            install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)

            shutil.copy(install_config_path, dirname)

        try:
            my.configure_db()
            my.configure_install()
            my.configure_mail_services()
            my.configure_gen_services()
            my.configure_asset_dir()
            my.configure_palette()
            my.configure_security()
        except Exception, e:
            raise TacticException('Error in [%s]: %s'%(my.section, e.__str__()))
开发者ID:0-T-0,项目名称:TACTIC,代码行数:43,代码来源:db_config_wdg.py

示例4: copy_start

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_config_path [as 别名]
    def copy_start(my):
        #import pdb; pdb.set_trace()
        data_dir = Environment.get_data_dir(manual=True)

        # check to see if the data folder already exists
        print
        print "Data Directory [%s]" % data_dir
        install_dir = Environment.get_install_dir()

        # find criteria for initializing
        initialize = False
        if data_dir and not os.path.exists(data_dir):
            initialize = True

        if data_dir and not os.path.exists("%s/config" % data_dir):
            initialize = True


        if initialize:
            # copy the template over.  This should exist even if it is not used
            print "... not found: initializing\n"
            install_data_path = "%s/src/install/start" % (install_dir)
            if os.path.exists(install_data_path):
                dirnames = os.listdir(install_data_path)
                for dirname in dirnames:
                    to_dir = "%s/%s" % (data_dir, dirname)
                    if os.path.exists(to_dir):
                        print "WARNING: path [%s] exists ... skipping copying" % to_dir
                        continue
                    print "Copying to [%s]" % to_dir
                    from_dir = "%s/%s" % (install_data_path, dirname)
                    shutil.copytree(from_dir, to_dir)
            else:
                shutil.copytree(install_data_path, data_dir)


            #import pdb; pdb.set_trace()

            # copy the appropriate config file
            if os.name == 'nt':
                filename = 'standalone_win32-conf.xml'
            else:
                filename = 'standalone_linux-conf.xml'
            install_config_path = "%s/src/install/config/%s" % (install_dir,filename)
            to_config_path = "%s/config/tactic-conf.xml" % data_dir

            if not os.path.exists(to_config_path):
                dirname = os.path.dirname(to_config_path)
                if not os.path.exists(dirname):
                    os.makedirs(dirname)
                shutil.copy(install_config_path, to_config_path)

        # some backwards compatibility issues
        old_config_path = "%s/config/tactic_linux-conf.xml" % data_dir
        if os.path.exists(old_config_path):
            new_config_path = "%s/config/tactic-conf.xml" % data_dir
            shutil.move(old_config_path, new_config_path)



        config_path = Config.get_config_path()
        config_exists = False
        if os.path.exists(config_path):
            config_exists = True


        #import pdb; pdb.set_trace()
        asset_dir = Environment.get_asset_dir()
        print "Asset Directory [%s]" % asset_dir

        tmp_dir = Environment.get_tmp_dir()
        print "Temp Directory [%s]" % tmp_dir

        # check if there is a config path already exists. If it does,
        # then don't do anything further.  This is likely a previous
        # installation
        if config_exists:
            print "Config_path [%s]" % config_path
            return
        else:
            # if there is no config, retrieve data_dir in non-manual mode
            data_dir = Environment.get_data_dir()
            f = open("%s/first_run" % data_dir, 'w')
            f.write("")
            f.close()

        return
开发者ID:makeittotop,项目名称:python-scripts,代码行数:89,代码来源:first_run_init.py

示例5: get_display

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

        top = my.top
        top.add_class("spt_db_config_top")
        top.add_style("width: 430px")
        top.add_style("min-height: 500")
        top.add_style("padding: 15px")
        top.add_style("margin-left: auto")
        top.add_style("margin-right: auto")
        top.add_color("background", "background", -10)
        top.add_border()

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add("System Configuration Setup")
        title_wdg.add_style("font-size: 20px")


        top.add("<hr/>")

        top.add("<i style='opacity: 0.5'>%s</i><br/>" % Config.get_config_path())
        top.add("<br/>")


        checkin_keys=Config.get_section_values('checkin')
        checkin_keys=checkin_keys.keys()
        save_button = my.get_save_button(checkin_keys)
        top.add(save_button)
        vendor = Config.get_value("database", "vendor")

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add("<b>Database Setup</b>")
        title_wdg.add_style("margin-bottom: 10px")


        db_select = SelectWdg("database/vendor")
        db_select.set_option("labels", "SQLite|PostgreSQL|MySQL|Oracle|SQLServer")
        db_select.set_option("values", "Sqlite|PostgreSQL|MySQL|Oracle|SQLServer")

        db_select.set_value(vendor)



        db_select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''

        var key;
        if (bvr.src_el.value == 'Sqlite') {
            key = 'Sqlite';
        }
        else {
            key = 'Other';
        }

        var top = bvr.src_el.getParent(".spt_db_config_top");
        var options_els = top.getElements(".spt_db_options");
        for (var i = 0; i < options_els.length; i++) {
            var vendor = options_els[i].getAttribute("spt_vendor");
            if (vendor == key) {
                spt.show(options_els[i]);
            }
            else {
                spt.hide(options_els[i]);
            }

        }
        '''
        } )
 
        option_div = DivWdg()
        top.add(option_div)
        option_div.add("Vendor: ")
        option_div.add(db_select)
        option_div.add_style("margin: 20px")

        sqlite_wdg = my.get_sqlite_wdg()
        option_div.add(sqlite_wdg)
        otherdb_wdg = my.get_otherdb_wdg()
        option_div.add(otherdb_wdg)

        if vendor == 'Sqlite':
            otherdb_wdg.add_style("display: none")
            sqlite_wdg.add_style("display", "")
        else:
            otherdb_wdg.add_style("display", "")
            sqlite_wdg.add_style("display: none")


        test_button = ActionButtonWdg(title="<< Test >>", tip="Test connecting to database")
        option_div.add(test_button)
        test_button.add_style("margin-left: auto")
        test_button.add_style("margin-right: auto")
        test_button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_db_config_top");
        var values = spt.api.Utility.get_input_values(top, null, false);
        var class_name = 'tactic.ui.startup.DbConfigCbk';
#.........这里部分代码省略.........
开发者ID:blezek,项目名称:TACTIC,代码行数:103,代码来源:db_config_wdg.py

示例6: ask_questions

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_config_path [as 别名]

#.........这里部分代码省略.........
                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)

        if user == "__EMPTY__":
            user = ""
        Config.set_value("database", "user", user)
        Config.save_config()
        path = Config.get_config_path()

        print
        print "Saved new database information to [%s].  Please restart TACTIC for the changes to take effect" % path
        print

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

示例7: get_display

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


        web = WebContainer.get_web()
        palette = web.get_palette()

        widget = DivWdg()
        widget.add_style("width: 100%")
        widget.add_style("text-align: center")

        from tactic.ui.app import PageHeaderWdg
        header = PageHeaderWdg(show_project=False)
        widget.add( header )

        security = Environment.get_security()


        search = Search("sthpw/project")
        search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')")
        search.add_where("\"type\" not in ('resource')")
        # hide template projects
        if security.check_access("builtin", "view_site_admin", "allow") or security.check_access("builtin", "view_template_projects", "allow"):
            pass
        else:
            search.add_op("begin")
            search.add_filter("is_template", True, op='!=')
            search.add_filter("is_template", 'NULL', quoted=False, op='is')
            search.add_op("or")

        search.add_order_by("category")

        projects = search.get_sobjects()
        
        num = len(projects)
        # sort by project
        if num < 5:
            columns = 1
            icon_size = 90
            width = 500
        elif num < 15:
            columns = 2
            icon_size = 60
            width = 700
        else:
            columns = 3
            icon_size = 45
            width = 800

        div = DivWdg()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        #div.add_style("width: 520px")
        div.center()
        widget.add(div)

        #logo = TacticLogoWdg()
        #div.add(logo)
        div.add("<br/>"*3)

        bg_color = palette.color("background")
        #div.add_color("color", "color")

        from tactic.ui.container import RoundedCornerDivWdg
        div = RoundedCornerDivWdg(hex_color_code=bg_color,corner_size="10")
        div.set_dimensions( width_str='%spx' % width, content_height_str='50px' )
        div.add_border()
        div.add_style("overflow: hidden")
        div.set_box_shadow()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        div.add_style("width: %spx" % width)
        table = Table()
        table.set_max_width()
        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("background-color: %s" % bg_color)
        table.add_color("color", "color")

        tr, td = table.add_row_cell()
        logo_div = DivWdg()
        logo_div.add_gradient("background", "background3", -5, -10)
        td.add(logo_div)
        logo = TacticLogoWdg()
        logo_div.add(logo)
        logo_div.add_style("margin: -6 -6 6 -6")


        app_name = WebContainer.get_web().get_app_name()
        security = Environment.get_security() 

        last_category = None
        has_category = False
        index = 0 

        # if TACTIC has not been set up, show the configuration page
        # FIXME: what is the requirement for is_installed?
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:index_wdg.py


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