Skip to content

Commit

Permalink
Silence python warnings from 3rd party libraries on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 21, 2018
1 parent 343872b commit c0d9528
Show file tree
Hide file tree
Showing 33 changed files with 186 additions and 66 deletions.
7 changes: 6 additions & 1 deletion python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -29,6 +29,7 @@

import json
import os.path
import warnings
from urllib.request import build_opener, install_opener, ProxyHandler

from qgis.PyQt.QtCore import Qt
Expand All @@ -43,7 +44,11 @@
from qgis.gui import QgsRubberBand
from qgis.utils import OverrideCursor

from owslib.csw import CatalogueServiceWeb # spellok
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ResourceWarning)
warnings.filterwarnings("ignore", category=ImportWarning)
from owslib.csw import CatalogueServiceWeb # spellok

from owslib.fes import BBox, PropertyIsLike
from owslib.ows import ExceptionReport

Expand Down
1 change: 1 addition & 0 deletions python/plugins/MetaSearch/dialogs/newconnectiondialog.py
Expand Up @@ -27,6 +27,7 @@
#
###############################################################################

import warnings
from qgis.core import QgsSettings
from qgis.PyQt.QtWidgets import QDialog, QMessageBox

Expand Down
1 change: 1 addition & 0 deletions python/plugins/MetaSearch/util.py
Expand Up @@ -27,6 +27,7 @@
# avoid PendingDeprecationWarning from PyQt4.uic
import warnings
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)

import configparser
from gettext import gettext, ngettext
Expand Down
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -29,15 +29,16 @@
import subprocess
import platform
import re
import warnings

import psycopg2

from osgeo import gdal
from osgeo import ogr
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import ogr

from qgis.core import (Qgis,
QgsApplication,
QgsCoordinateReferenceSystem,
QgsVectorFileWriter,
QgsProcessingFeedback,
QgsProcessingUtils,
Expand All @@ -49,7 +50,9 @@
from processing.tools.system import isWindows, isMac

try:
from osgeo import gdal # NOQA
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import gdal # NOQA

gdalAvailable = True
except:
Expand Down
Expand Up @@ -27,6 +27,7 @@

import os
import re
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
Expand All @@ -53,8 +54,10 @@
from processing.gui.ParameterGuiUtils import getFileFilter

pluginPath = os.path.dirname(__file__)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'DlgFieldsCalculator.ui'))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'DlgFieldsCalculator.ui'))


class FieldCalculatorFeedback(QgsProcessingFeedback):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/AutofillDialog.py
Expand Up @@ -26,13 +26,17 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgAutofill.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgAutofill.ui'))


class AutofillDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/BatchPanel.py
Expand Up @@ -27,6 +27,7 @@

import os
import json
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QTableWidgetItem, QComboBox, QHeaderView, QFileDialog, QMessageBox
Expand All @@ -43,8 +44,11 @@
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBatchPanel.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBatchPanel.ui'))


class BatchPanel(BASE, WIDGET):
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/gui/ConfigDialog.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt, QEvent
Expand Down Expand Up @@ -61,8 +62,10 @@


pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgConfig.ui'))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgConfig.ui'))


class ConfigOptionsPage(QgsOptionsPageWidget):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/DestinationSelectionPanel.py
Expand Up @@ -27,6 +27,7 @@

import re
import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication, QDir, pyqtSignal
Expand All @@ -49,8 +50,11 @@
from processing.gui.ParameterGuiUtils import getFileFilter

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))


class DestinationSelectionPanel(BASE, WIDGET):
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/gui/DirectorySelectorDialog.py
Expand Up @@ -26,15 +26,18 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.core import QgsSettings
from qgis.PyQt.QtWidgets import QDialog, QAbstractItemView, QPushButton, QDialogButtonBox, QFileDialog
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMultipleSelection.ui'))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMultipleSelection.ui'))


class DirectorySelectorDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/EditRenderingStylesDialog.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
Expand All @@ -38,8 +39,11 @@
from processing.gui.RenderingStyleFilePanel import RenderingStyleFilePanel

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgRenderingStyles.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgRenderingStyles.ui'))


class EditRenderingStylesDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/ExtentSelectionPanel.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QMenu, QAction, QInputDialog
Expand All @@ -45,8 +46,11 @@
from processing.tools.dataobjects import createContext

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))


class ExtentSelectionPanel(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/FileSelectionPanel.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QFileDialog
Expand All @@ -34,8 +35,11 @@
from processing.tools.system import isWindows

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))


class FileSelectionPanel(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/FixedTableDialog.py
Expand Up @@ -26,14 +26,18 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog, QPushButton, QAbstractItemView, QDialogButtonBox
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgFixedTable.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgFixedTable.ui'))


class FixedTableDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/FixedTablePanel.py
Expand Up @@ -26,14 +26,18 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic

from processing.gui.FixedTableDialog import FixedTableDialog

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))


class FixedTablePanel(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/HelpEditionDialog.py
Expand Up @@ -27,6 +27,7 @@

import os
import json
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog, QTreeWidgetItem
Expand All @@ -38,8 +39,11 @@
QgsProcessingModelAlgorithm)

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgHelpEdition.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgHelpEdition.ui'))


class HelpEditionDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/HistoryDialog.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt, QCoreApplication
Expand All @@ -35,8 +36,11 @@
from processing.core.ProcessingLog import ProcessingLog

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgHistory.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgHistory.ui'))


class HistoryDialog(BASE, WIDGET):
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/gui/MessageDialog.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.PyQt import uic
from qgis.PyQt.QtGui import QDesktopServices
Expand All @@ -34,8 +35,10 @@
from qgis.utils import iface

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMessage.ui'))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMessage.ui'))


class MessageDialog(BASE, WIDGET):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/MultipleFileInputDialog.py
Expand Up @@ -28,6 +28,7 @@
__revision__ = '$Format:%H$'

import os
import warnings

from qgis.core import QgsSettings
from qgis.PyQt import uic
Expand All @@ -36,8 +37,11 @@
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMultipleSelection.ui'))

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgMultipleSelection.ui'))


class MultipleFileInputDialog(BASE, WIDGET):
Expand Down

0 comments on commit c0d9528

Please sign in to comment.