forked from linkedgeodesy/myfirstqgisplugin
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
import requests | ||
|
||
from ....util.ui.uiutils import UIUtils | ||
from ....util.conf.configutils import ConfigUtils | ||
from ....dialogs.info.errormessagebox import ErrorMessageBox | ||
from qgis.PyQt.QtGui import QIcon, QStandardItem, QStandardItemModel | ||
from qgis.core import Qgis,QgsTask, QgsMessageLog | ||
|
||
MESSAGE_CATEGORY = 'TripleStoreRepositorySyncTask' | ||
|
||
class TripleStoreRepositorySyncTask(QgsTask): | ||
|
||
|
||
def __init__(self, description,combobox,triplestoreconf,removeOldConfig=False,triplestorerepourl=None): | ||
super().__init__(description, QgsTask.CanCancel) | ||
self.exception = None | ||
self.triplestoreconf=triplestoreconf | ||
self.combobox=combobox | ||
self.triplestorerepourl = triplestorerepourl | ||
self.removeOldConfig=removeOldConfig | ||
if triplestorerepourl is None: | ||
self.triplestorerepourl="https://raw.githubusercontent.com/sparqlunicorn/sparqlunicornGoesGIS/ldregistry/ldregistry.json" | ||
self.results = None | ||
|
||
def run(self): | ||
QgsMessageLog.logMessage('Started task "{}"'.format(str(self.triplestorerepourl)), MESSAGE_CATEGORY, Qgis.Info) | ||
try: | ||
self.results = json.loads(requests.get(self.triplestorerepourl).text) | ||
#QgsMessageLog.logMessage('Started task "{}"'.format(str(self.results)), MESSAGE_CATEGORY, | ||
# Qgis.Info) | ||
return True | ||
except Exception as e: | ||
self.exception=e | ||
return False | ||
|
||
def finished(self, result): | ||
if self.exception is not None: | ||
QgsMessageLog.logMessage("An error occured while accessing the triple store repository:\n" + str(self.exception), MESSAGE_CATEGORY,Qgis.Info) | ||
if self.results is not None: | ||
triplestoreconf=ConfigUtils.updateTripleStoreConf(self.triplestoreconf,self.results,self.removeOldConfig) | ||
self.combobox.clear() | ||
UIUtils.createTripleStoreCBox(self.combobox, triplestoreconf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters