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


Python VirtualDisk.path_exists方法代码示例

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


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

示例1: disk_prompt

# 需要导入模块: from virtinst import VirtualDisk [as 别名]
# 或者: from virtinst.VirtualDisk import path_exists [as 别名]
def disk_prompt(prompt_txt, arg_dict, warn_overwrite=False, prompt_size=True,
                path_to_clone=None):

    retry_path = True
    conn = arg_dict.get("conn")
    passed_path = arg_dict.get("path")
    size = arg_dict.get("size")

    no_path_needed = (bool(arg_dict.get("volInstall")) or
                      bool(arg_dict.get("volName")))

    while 1:
        if not retry_path:
            passed_path = None
            size = None
        retry_path = False

        msg = None
        patherr = _("A disk path must be specified.")
        if path_to_clone:
            patherr = (_("A disk path must be specified to clone '%s'.") %
                       path_to_clone)

        if not prompt_txt:
            msg = _("What would you like to use as the disk (file path)?")
            if not size is None:
                msg = _("Please enter the path to the file you would like to "
                        "use for storage. It will have size %sGB.") %(size,)

        if not no_path_needed:
            path = prompt_for_input(patherr, prompt_txt or msg, passed_path)
        else:
            path = None
        arg_dict["path"] = path

        sizeerr = _("A size must be specified for non-existent disks.")
        if path and not size and prompt_size:
            size_prompt = _("How large would you like the disk (%s) to "
                            "be (in gigabytes)?") % path

            try:
                if not VirtualDisk.path_exists(conn, path):
                    size = prompt_loop(size_prompt, sizeerr, size, None, None,
                                       func=float)
            except Exception, e:
                # Path is probably bogus, raise the error
                logging.error(str(e))
                continue
        arg_dict["size"] = size

        # Build disk object for validation
        try:
            dev = VirtualDisk(**arg_dict)
        except ValueError, e:
            if is_prompt():
                logging.error(e)
                continue
            else:
                fail(_("Error with storage parameters: %s" % str(e)))
开发者ID:paradox12,项目名称:python-virtinst,代码行数:61,代码来源:cli.py


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