本文整理匯總了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)))