Skip to content

Commit

Permalink
[pluginmanager] apply auth also when downloading plugin package
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and dakcarto committed Mar 4, 2016
1 parent 2f5c193 commit e2879c3
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions python/pyplugin_installer/qgsplugininstallerinstallingdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply

import qgis
from qgis.core import QgsNetworkAccessManager
from qgis.core import QgsNetworkAccessManager, QgsAuthManager

from ui_qgsplugininstallerinstallingbase import Ui_QgsPluginInstallerInstallingDialogBase
from installer_data import removeDir
from installer_data import removeDir, repositories
from unzip import unzip


Expand All @@ -57,11 +57,27 @@ def __init__(self, parent, plugin):
self.file = QFile(tmpPath)

self.request = QNetworkRequest(url)
self.reply = QgsNetworkAccessManager.instance().get(self.request)
self.reply.downloadProgress.connect(self.readProgress)
self.reply.finished.connect(self.requestFinished)

self.stateChanged(4)
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)

def exec_(self):
if self.request is None:
return QDialog.Rejected

QDialog.exec_(self)

# ----------------------------------------- #
def result(self):
Expand Down

0 comments on commit e2879c3

Please sign in to comment.