本文整理匯總了Python中virtinst.StoragePool.get_default_dir方法的典型用法代碼示例。如果您正苦於以下問題:Python StoragePool.get_default_dir方法的具體用法?Python StoragePool.get_default_dir怎麽用?Python StoragePool.get_default_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類virtinst.StoragePool
的用法示例。
在下文中一共展示了StoragePool.get_default_dir方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: browse_target_path
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import get_default_dir [as 別名]
def browse_target_path(self, ignore1=None):
startfolder = StoragePool.get_default_dir(self.conn.get_backend())
target = self._browse_file(_("Choose target directory"),
startfolder=startfolder,
foldermode=True)
if target:
self.widget("pool-target-path").get_child().set_text(target)
示例2: convert_disks
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import get_default_dir [as 別名]
def convert_disks(self, disk_format, destdir=None, dry=False):
"""
Convert a disk into the requested format if possible, in the
given output directory. Raises RuntimeError or other failures.
"""
if disk_format == "none":
disk_format = None
if destdir is None:
destdir = StoragePool.get_default_dir(self.conn, build=not dry)
guest = self.get_guest()
for disk in guest.get_devices("disk"):
if disk.device != "disk":
continue
if disk_format and disk.driver_type == disk_format:
logging.debug("path=%s is already in requested format=%s", disk.path, disk_format)
disk_format = None
basepath = os.path.splitext(os.path.basename(disk.path))[0]
newpath = re.sub(r"\s", "_", basepath)
if disk_format:
newpath += "." + disk_format
newpath = os.path.join(destdir, newpath)
if os.path.exists(newpath):
raise RuntimeError(_("New path name '%s' already exists") % newpath)
if not disk_format or disk_format == "none":
self._copy_file(disk.path, newpath, dry)
else:
self._qemu_convert(disk.path, newpath, disk_format, dry)
disk.driver_type = disk_format
disk.path = newpath
self._err_clean.append(newpath)