40
40
mRepositories = dict of dicts: {repoName : {"url" unicode,
41
41
"enabled" bool,
42
42
"valid" bool,
43
- "QPNAME" QPNetworkAccessManager,
44
43
"Relay" Relay, # Relay object for transmitting signals from QPHttp with adding the repoName information
45
44
"Request" QNetworkRequest,
46
45
"xmlData" QNetworkReply,
@@ -170,43 +169,6 @@ def removeDir(path):
170
169
171
170
172
171
173
- # --- class QPNetworkAccessManager ----------------------------------------------------------------------- #
174
- # --- It's a temporary workaround for broken proxy handling in Qt ------------------------- #
175
- class QPNetworkAccessManager (QNetworkAccessManager ):
176
- def __init__ (self , repoUrl ):
177
- QNetworkAccessManager .__init__ (self ,)
178
- settings = QSettings ()
179
- settings .beginGroup ("proxy" )
180
- if settings .value ("/proxyEnabled" , False , type = bool ):
181
- self .proxy = QNetworkProxy ()
182
- proxyType = settings .value ( "/proxyType" , "0" , type = unicode )
183
- if repoUrl :
184
- for excludedUrl in settings .value ("/proxyExcludedUrls" ,"" , type = unicode ).split ("|" ):
185
- if repoUrl .find ( excludedUrl ) > - 1 :
186
- proxyType = "NoProxy"
187
- if proxyType in ["1" ,"Socks5Proxy" ]: self .proxy .setType (QNetworkProxy .Socks5Proxy )
188
- elif proxyType in ["2" ,"NoProxy" ]: self .proxy .setType (QNetworkProxy .NoProxy )
189
- elif proxyType in ["3" ,"HttpProxy" ]: self .proxy .setType (QNetworkProxy .HttpProxy )
190
- elif proxyType in ["4" ,"HttpCachingProxy" ] and QT_VERSION >= 0X040400 : self .proxy .setType (QNetworkProxy .HttpCachingProxy )
191
- elif proxyType in ["5" ,"FtpCachingProxy" ] and QT_VERSION >= 0X040400 : self .proxy .setType (QNetworkProxy .FtpCachingProxy )
192
- else : self .proxy .setType (QNetworkProxy .DefaultProxy )
193
- self .proxy .setHostName (settings .value ("/proxyHost" ,"" , type = unicode ))
194
- try :
195
- # QSettings may contain non-int value...
196
- self .proxy .setPort (settings .value ("/proxyPort" , 0 , type = int ))
197
- except :
198
- pass
199
- self .proxy .setUser (settings .value ("/proxyUser" , "" , type = unicode ))
200
- self .proxy .setPassword (settings .value ("/proxyPassword" , "" , type = unicode ))
201
- self .setProxy (self .proxy )
202
- settings .endGroup ()
203
- return None
204
- # --- /class QPNetworkAccessManager ---------------------------------------------------------------------- #
205
-
206
-
207
-
208
-
209
-
210
172
# --- class Relay ----------------------------------------------------------------------- #
211
173
class Relay (QObject ):
212
174
""" Relay object for transmitting signals from QPHttp with adding the repoName information """
@@ -395,7 +357,6 @@ def load(self):
395
357
self .mRepositories [key ]["url" ] = settings .value (key + "/url" , "" , type = unicode )
396
358
self .mRepositories [key ]["enabled" ] = settings .value (key + "/enabled" , True , type = bool )
397
359
self .mRepositories [key ]["valid" ] = settings .value (key + "/valid" , True , type = bool )
398
- self .mRepositories [key ]["QPNAM" ] = QPNetworkAccessManager ( self .mRepositories [key ]["url" ] )
399
360
self .mRepositories [key ]["Relay" ] = Relay (key )
400
361
self .mRepositories [key ]["xmlData" ] = None
401
362
self .mRepositories [key ]["state" ] = 0
@@ -413,10 +374,10 @@ def requestFetching(self,key):
413
374
414
375
self .mRepositories [key ]["QRequest" ] = QNetworkRequest (url )
415
376
self .mRepositories [key ]["QRequest" ].setAttribute ( QNetworkRequest .User , key )
416
- self .mRepositories [key ]["xmlData" ] = self . mRepositories [ key ][ "QPNAM" ] .get ( self .mRepositories [key ]["QRequest" ] )
377
+ self .mRepositories [key ]["xmlData" ] = QgsNetworkAccessManager . instance () .get ( self .mRepositories [key ]["QRequest" ] )
417
378
self .mRepositories [key ]["xmlData" ].setProperty ( 'reposName' , key )
418
379
self .mRepositories [key ]["xmlData" ].downloadProgress .connect ( self .mRepositories [key ]["Relay" ].dataReadProgress )
419
- self .mRepositories [key ]["QPNAM " ].finished .connect ( self .xmlDownloaded )
380
+ self .mRepositories [key ]["xmlData " ].finished .connect ( self .xmlDownloaded )
420
381
421
382
422
383
# ----------------------------------------- #
@@ -432,21 +393,21 @@ def fetchingInProgress(self):
432
393
def killConnection (self , key ):
433
394
""" kill the fetching on demand """
434
395
if self .mRepositories [key ]["xmlData" ] and self .mRepositories [key ]["xmlData" ].isRunning ():
435
- self .mRepositories [key ]["QPNAM " ].finished .disconnect ()
396
+ self .mRepositories [key ]["xmlData " ].finished .disconnect ()
436
397
self .mRepositories [key ]["xmlData" ].abort ()
437
398
438
399
439
400
# ----------------------------------------- #
440
- def xmlDownloaded (self , reply ):
401
+ def xmlDownloaded (self ):
441
402
""" populate the plugins object with the fetched data """
403
+ reply = self .sender ()
442
404
reposName = reply .property ( 'reposName' )
443
405
if reply .error () != QNetworkReply .NoError : # fetching failed
444
406
self .mRepositories [reposName ]["state" ] = 3
445
407
self .mRepositories [reposName ]["error" ] = str (reply .error ())
446
408
else :
447
- repoData = self .mRepositories [reposName ]["xmlData" ]
448
409
reposXML = QDomDocument ()
449
- reposXML .setContent (repoData .readAll ())
410
+ reposXML .setContent (reply .readAll ())
450
411
pluginNodes = reposXML .elementsByTagName ("pyqgis_plugin" )
451
412
if pluginNodes .size ():
452
413
for i in range (pluginNodes .size ()):
@@ -509,6 +470,8 @@ def xmlDownloaded(self, reply):
509
470
if not self .fetchingInProgress ():
510
471
self .checkingDone .emit ()
511
472
473
+ del reply
474
+
512
475
513
476
# ----------------------------------------- #
514
477
def inspectionFilter (self ):
0 commit comments