Browse Source

#75 #59 change error message about OGR and the OSM driver

tags/1.4.4
Etienne Trimaille 3 years ago
parent
commit
7762413572
4 changed files with 33 additions and 11 deletions
  1. 8
    3
      controller/process.py
  2. 11
    2
      core/exceptions.py
  3. 6
    3
      core/utilities/utilities_qgis.py
  4. 8
    3
      ui/osm_file_dialog.py

+ 8
- 3
controller/process.py View File

@@ -29,11 +29,13 @@ from qgis.core import \

from QuickOSM.core.query_factory import QueryFactory
from QuickOSM.core.utilities.tools import tr
from QuickOSM.core.exceptions import FileOutPutException, OsmDriver
from QuickOSM.core.exceptions import \
FileOutPutException, OsmDriverNotFound, GDALVersion
from QuickOSM.core.api.connexion_oapi import ConnexionOAPI
from QuickOSM.core.parser.osm_parser import OsmParser
from QuickOSM.core.utilities.operating_system import get_default_encoding
from QuickOSM.core.utilities.utilities_qgis import is_osm_driver_enabled
from QuickOSM.core.utilities.utilities_qgis import \
is_osm_driver_enabled, is_ogr_version_ok
from QuickOSM.core.utilities.tools import get_setting
from QuickOSM.core.query_parser import prepare_query

@@ -223,8 +225,11 @@ def process_query(
"""execute a query and send the result file to open_file."""

# Check OGR
if not is_ogr_version_ok():
raise GDALVersion

if not is_osm_driver_enabled():
raise OsmDriver
raise OsmDriverNotFound

# Get output's format
output_format = get_setting('outputFormat')

+ 11
- 2
core/exceptions.py View File

@@ -90,12 +90,21 @@ Ogr2Ogr
'''


class OsmDriver(QuickOsmException):
class OsmDriverNotFound(QuickOsmException):
def __init__(self, msg=None):
if not msg:
msg = tr(
'Exception', u"The OSM's driver is not installed. "
u"You must have GDAL/OGR >= 1.10.")
u"Please install the OSM driver for GDAL "
u": http://www.gdal.org/drv_osm.html")
QuickOsmException.__init__(self, msg)


class GDALVersion(QuickOsmException):
def __init__(self, msg=None):
if not msg:
msg = tr(
'Exception', u"You must upgrade GDAL/OGR >= 1.10.0.")
QuickOsmException.__init__(self, msg)



+ 6
- 3
core/utilities/utilities_qgis.py View File

@@ -24,6 +24,7 @@
from osgeo import gdal, ogr
from qgis.gui import QgsMessageBar
from qgis.utils import iface
from QuickOSM.core.exceptions import GDALVersion, OsmDriverNotFound


def display_message_bar(
@@ -42,11 +43,13 @@ def get_ogr_version():
return int(gdal.VersionInfo('VERSION_NUM'))


def is_osm_driver_enabled():
if get_ogr_version < 1100000:
def is_ogr_version_ok():
if get_ogr_version() < 1100000:
return False
return True


def is_osm_driver_enabled():
if not ogr.GetDriverByName('OSM'):
return False

return True

+ 8
- 3
ui/osm_file_dialog.py View File

@@ -33,8 +33,10 @@ from QuickOSM.core.exceptions import (
OutPutGeomTypesException,
FileDoesntExistException,
DirectoryOutPutException,
OsmDriver)
from QuickOSM.core.utilities.utilities_qgis import is_osm_driver_enabled
GDALVersion,
OsmDriverNotFound)
from QuickOSM.core.utilities.utilities_qgis import \
is_osm_driver_enabled, is_ogr_version_ok
from QuickOSM.core.parser.osm_parser import OsmParser
from QuickOSM.controller.process import open_file
from QuickOSMWidget import QuickOSMWidget
@@ -151,8 +153,11 @@ class OsmFileWidget(QuickOSMWidget, Ui_ui_osm_file):
raise DirectoryOutPutException

# Check OGR
if not is_ogr_version_ok():
raise GDALVersion

if not is_osm_driver_enabled():
raise OsmDriver
raise OsmDriverNotFound

if load_only:
osm_parser = OsmParser(

Loading…
Cancel
Save