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


Python QDir.cleanPath方法代碼示例

本文整理匯總了Python中PyQt.QtCore.QDir.cleanPath方法的典型用法代碼示例。如果您正苦於以下問題:Python QDir.cleanPath方法的具體用法?Python QDir.cleanPath怎麽用?Python QDir.cleanPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt.QtCore.QDir的用法示例。


在下文中一共展示了QDir.cleanPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt.QtCore import QDir [as 別名]
# 或者: from PyQt.QtCore.QDir import cleanPath [as 別名]
    def __init__(self, parent, plugin):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.plugin = plugin
        self.mResult = ""
        self.progressBar.setRange(0, 0)
        self.progressBar.setFormat("%p%")
        self.labelName.setText(plugin["name"])
        self.buttonBox.clicked.connect(self.abort)

        url = QUrl(plugin["download_url"])

        fileName = plugin["filename"]
        tmpDir = QDir.tempPath()
        tmpPath = QDir.cleanPath(tmpDir + "/" + fileName)
        self.file = QFile(tmpPath)

        self.request = QNetworkRequest(url)
        authcfg = repositories.all()[plugin["zip_repository"]]["authcfg"]
        if authcfg and isinstance(authcfg, basestring):
            if not QgsAuthManager.instance().updateNetworkRequest(
                    self.request, authcfg.strip()):
                self.mResult = self.tr(
                    "Update of network request with authentication "
                    "credentials FAILED for configuration '{0}'").format(authcfg)
                self.request = None

        if self.request is not None:
            self.reply = QgsNetworkAccessManager.instance().get(self.request)
            self.reply.downloadProgress.connect(self.readProgress)
            self.reply.finished.connect(self.requestFinished)

            self.stateChanged(4)
開發者ID:Antoviscomi,項目名稱:QGIS,代碼行數:35,代碼來源:qgsplugininstallerinstallingdialog.py

示例2: requestFinished

# 需要導入模塊: from PyQt.QtCore import QDir [as 別名]
# 或者: from PyQt.QtCore.QDir import cleanPath [as 別名]
 def requestFinished(self):
     reply = self.sender()
     self.buttonBox.setEnabled(False)
     if reply.error() != QNetworkReply.NoError:
         self.mResult = reply.errorString()
         if reply.error() == QNetworkReply.OperationCanceledError:
             self.mResult += "<br/><br/>" + QCoreApplication.translate("QgsPluginInstaller", "If you haven't cancelled the download manually, it might be caused by a timeout. In this case consider increasing the connection timeout value in QGIS options.")
         self.reject()
         reply.deleteLater()
         return
     self.file.open(QFile.WriteOnly)
     self.file.write(reply.readAll())
     self.file.close()
     self.stateChanged(0)
     reply.deleteLater()
     pluginDir = qgis.utils.home_plugin_path
     tmpPath = self.file.fileName()
     # make sure that the parent directory exists
     if not QDir(pluginDir).exists():
         QDir().mkpath(pluginDir)
     # if the target directory already exists as a link, remove the link without resolving:
     QFile(pluginDir + unicode(QDir.separator()) + self.plugin["id"]).remove()
     try:
         unzip(unicode(tmpPath), unicode(pluginDir))  # test extract. If fails, then exception will be raised and no removing occurs
         # removing old plugin files if exist
         removeDir(QDir.cleanPath(pluginDir + "/" + self.plugin["id"]))  # remove old plugin if exists
         unzip(unicode(tmpPath), unicode(pluginDir))  # final extract.
     except:
         self.mResult = self.tr("Failed to unzip the plugin package. Probably it's broken or missing from the repository. You may also want to make sure that you have write permission to the plugin directory:") + "\n" + pluginDir
         self.reject()
         return
     try:
         # cleaning: removing the temporary zip file
         QFile(tmpPath).remove()
     except:
         pass
     self.close()
開發者ID:Antoviscomi,項目名稱:QGIS,代碼行數:39,代碼來源:qgsplugininstallerinstallingdialog.py


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