Skip to content

Commit

Permalink
[qgepqwat2ili] retrieve pg_service from layer
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed Sep 15, 2021
1 parent 885f73c commit 50dae1e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions qgepplugin/qgepplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
)
from .tools.qgepnetwork import QgepGraphManager
from .utils.plugin_utils import plugin_root_path
from .utils.qgeplayermanager import QgepLayerNotifier
from .utils.qgeplayermanager import QgepLayerManager, QgepLayerNotifier
from .utils.qgeplogging import QgepQgsLogHandler
from .utils.translation import setup_i18n

Expand Down Expand Up @@ -485,7 +485,18 @@ def actionExportClicked(self):
)
self.logger.error(str(e))
return
action_export(self, "pg_qgep")

# Retrieve the pg_service
pg_layer = QgepLayerManager.layer("vw_qgep_wastewater_structure")
if not pg_layer or not pg_layer.dataProvider().uri().service():
self.iface.messageBar().pushMessage(
"Error",
"Could not determine the current pg_service from the loaded QGEP layers.",
level=Qgis.Critical,
)
return

action_export(self, pg_layer.dataProvider().uri().service())

def actionImportClicked(self):
# We only import now to avoid useless exception if dependencies aren't met
Expand All @@ -499,4 +510,15 @@ def actionImportClicked(self):
)
self.logger.error(str(e))
return
action_import(self, "pg_qgep")

# Retrieve the pg_service
pg_layer = QgepLayerManager.layer("vw_qgep_wastewater_structure")
if not pg_layer or not pg_layer.dataProvider().uri().service():
self.iface.messageBar().pushMessage(
"Error",
"Could not determine the current pg_service from the loaded QGEP layers.",
level=Qgis.Critical,
)
return

action_import(self, pg_layer.dataProvider().uri().service())

0 comments on commit 50dae1e

Please sign in to comment.