• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.resolve_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mongoctl.utils.resolve_path函数的典型用法代码示例。如果您正苦于以下问题:Python resolve_path函数的具体用法?Python resolve_path怎么用?Python resolve_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: find_all_executables

def find_all_executables(executable_name):
    # create a list of all available executables found and then return the best
    # match if applicable
    executables_found = []

    ####### Look in $PATH
    path_executable = which(executable_name)
    if path_executable is not None:
        add_to_executables_found(executables_found, path_executable)

    #### Look in $MONGO_HOME if set
    mongo_home = os.getenv(MONGO_HOME_ENV_VAR)

    if mongo_home is not None:
        mongo_home = resolve_path(mongo_home)
        mongo_home_exe = get_mongo_home_exe(mongo_home, executable_name)
        add_to_executables_found(executables_found, mongo_home_exe)
        # Look in mongod_installs_dir if set
    mongo_installs_dir = config.get_mongodb_installs_dir()

    if mongo_installs_dir is not None:
        if os.path.exists(mongo_installs_dir):
            for mongo_installation in os.listdir(mongo_installs_dir):
                child_mongo_home = os.path.join(mongo_installs_dir,
                                                mongo_installation)

                child_mongo_exe = get_mongo_home_exe(child_mongo_home,
                                                     executable_name)

                add_to_executables_found(executables_found, child_mongo_exe)

    return get_exe_version_tuples(executables_found)
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:32,代码来源:command_utils.py


示例2: export_cmd_options

    def export_cmd_options(self, options_override=None):
        """
            Override!
        :return:
        """
        cmd_options = super(MongodServer, self).export_cmd_options(
            options_override=options_override)

        # reset some props to exporting vals
        cmd_options['dbpath'] = self.get_db_path()

        if 'repairpath' in cmd_options:
            cmd_options['repairpath'] = resolve_path(cmd_options['repairpath'])

        # Add ReplicaSet args if a cluster is configured

        repl_cluster = self.get_replicaset_cluster()
        if repl_cluster is not None:
            if "replSet" not in cmd_options:
                cmd_options["replSet"] = repl_cluster.id

        # add configsvr as needed
        if self.is_config_server():
            cmd_options["configsvr"] = True

        # add shardsvr as needed
        if self.is_shard_server():
            cmd_options["shardsvr"] = True

        return cmd_options
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:30,代码来源:mongod.py


示例3: restore_command

def restore_command(parsed_options):

    # get and validate source/destination
    source = parsed_options.source
    destination = parsed_options.destination

    is_addr = is_db_address(destination)
    is_path = is_dbpath(destination)

    if is_addr and is_path:
        msg = ("Ambiguous destination value '%s'. Your destination matches"
               " both a dbpath and a db address. Use prefix 'file://',"
               " 'cluster://' or 'server://' to make it more specific" %
               destination)

        raise MongoctlException(msg)

    elif not (is_addr or is_path):
        raise MongoctlException("Invalid destination value '%s'. Destination has to be"
                                " a valid db address or dbpath." % destination)
    restore_options = extract_mongo_restore_options(parsed_options)

    if is_addr:
        mongo_restore_db_address(destination,
                                 source,
                                 username=parsed_options.username,
                                 password=parsed_options.password,
                                 restore_options=restore_options)
    else:
        dbpath = resolve_path(destination)
        mongo_restore_db_path(dbpath, source, restore_options=restore_options)
开发者ID:zenglzh,项目名称:mongoctl,代码行数:31,代码来源:restore.py


示例4: dump_command

def dump_command(parsed_options):

    # get and validate dump target
    target = parsed_options.target
    use_best_secondary = parsed_options.useBestSecondary
    #max_repl_lag = parsed_options.maxReplLag
    is_addr = is_db_address(target)
    is_path = is_dbpath(target)

    if is_addr and is_path:
        msg = ("Ambiguous target value '%s'. Your target matches both a dbpath"
               " and a db address. Use prefix 'file://', 'cluster://' or"
               " 'server://' to make it more specific" % target)

        raise MongoctlException(msg)

    elif not (is_addr or is_path):
        raise MongoctlException("Invalid target value '%s'. Target has to be"
                                " a valid db address or dbpath." % target)
    dump_options = extract_mongo_dump_options(parsed_options)

    if is_addr:
        mongo_dump_db_address(target,
                              username=parsed_options.username,
                              password=parsed_options.password,
                              use_best_secondary=use_best_secondary,
                              max_repl_lag=None,
                              dump_options=dump_options)
    else:
        dbpath = resolve_path(target)
        mongo_dump_db_path(dbpath, dump_options=dump_options)
开发者ID:mongolab,项目名称:mongoctl,代码行数:31,代码来源:dump.py


示例5: is_dbpath

def is_dbpath(value):
    """
    Checks if the specified value is a dbpath. dbpath could be an absolute
    file path, relative path or a file uri
    """

    value = resolve_path(value)
    return os.path.exists(value)
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:8,代码来源:command_utils.py


示例6: get_db_path

    def get_db_path(self):
        dbpath = self.get_cmd_option("dbpath")
        if not dbpath:
            dbpath = super(MongodServer, self).get_server_home()
        if not dbpath:
            dbpath = DEFAULT_DBPATH

        return resolve_path(dbpath)
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:8,代码来源:mongod.py


示例7: export_cmd_options

    def export_cmd_options(self, options_override=None, standalone=False):
        """
            Override!
        :return:
        """
        cmd_options = super(MongodServer, self).export_cmd_options(
            options_override=options_override)

        # reset some props to exporting vals
        cmd_options['dbpath'] = self.get_db_path()

        if 'repairpath' in cmd_options:
            cmd_options['repairpath'] = resolve_path(cmd_options['repairpath'])

        # Add ReplicaSet args if a cluster is configured

        repl_cluster = self.get_replicaset_cluster()
        if repl_cluster is not None:
            if "replSet" not in cmd_options:
                cmd_options["replSet"] = repl_cluster.id

        # apply standalone if specified
        if standalone:
            if "replSet" in cmd_options:
                del cmd_options["replSet"]
            if "keyFile" in cmd_options:
                del cmd_options["keyFile"]

        # add configsvr as needed
        if self.is_config_server():
            cmd_options["configsvr"] = True

        # add shardsvr as needed
        if self.is_shard_server():
            cmd_options["shardsvr"] = True

        # remove wiredTigerCacheSizeGB if its not an int since we set it in runtime parameter
        #  wiredTigerEngineRuntimeConfig in this case
        if "wiredTigerCacheSizeGB" in cmd_options and not isinstance(self.get_cmd_option("wiredTigerCacheSizeGB"), int):
            del cmd_options["wiredTigerCacheSizeGB"]

        return cmd_options
开发者ID:mongolab,项目名称:mongoctl,代码行数:42,代码来源:mongod.py


示例8: get_server_home

 def get_server_home(self):
     home_dir = self.get_property("serverHome")
     if home_dir:
         return resolve_path(home_dir)
     else:
         return None
开发者ID:macroeyes,项目名称:mongoctl,代码行数:6,代码来源:server.py


示例9: get_server_file_path

 def get_server_file_path(self, cmd_prop, default_file_name):
     file_path = self.get_cmd_option(cmd_prop)
     if file_path is not None:
         return resolve_path(file_path)
     else:
         return self.get_default_file_path(default_file_name)
开发者ID:macroeyes,项目名称:mongoctl,代码行数:6,代码来源:server.py


示例10: get_key_file

 def get_key_file(self):
     kf = self.get_cmd_option("keyFile")
     if kf:
         return resolve_path(kf)
开发者ID:macroeyes,项目名称:mongoctl,代码行数:4,代码来源:server.py


示例11: get_db_path

    def get_db_path(self):
        dbpath = self.get_cmd_option("dbpath")
        if dbpath is None:
            dbpath = DEFAULT_DBPATH

        return resolve_path(dbpath)
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:6,代码来源:mongod.py


示例12: get_root_path

 def get_root_path(self):
     server_root = self.get_property("rootPath")
     return resolve_path(server_root)
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:3,代码来源:server.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mongoctl_logging.log_verbose函数代码示例发布时间:2022-05-27
下一篇:
Python mongoctl_logging.log_verbose函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap