當前位置: 首頁>>代碼示例>>Python>>正文


Python StoragePool.get_default_dir方法代碼示例

本文整理匯總了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)
開發者ID:CyberShadow,項目名稱:virt-manager,代碼行數:9,代碼來源:createpool.py

示例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)
開發者ID:iainlane,項目名稱:virt-manager,代碼行數:37,代碼來源:formats.py


注:本文中的virtinst.StoragePool.get_default_dir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。