From 24cbf265c062df41c507e4f7d080d59ff094f396 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Thu, 5 Dec 2024 11:21:37 -0500 Subject: [PATCH] update --- .flake8 | 3 --- python/grass/temporal/abstract_space_time_dataset.py | 5 ++++- python/grass/temporal/core.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.flake8 b/.flake8 index c9da26c037e..975cc914a8b 100644 --- a/.flake8 +++ b/.flake8 @@ -50,9 +50,6 @@ per-file-ignores = python/grass/pygrass/raster/__init__.py: E402 python/grass/pygrass/vector/__init__.py: E402 python/grass/pygrass/utils.py: E402 - python/grass/temporal/abstract_space_time_dataset.py: E722 - python/grass/temporal/c_libraries_interface.py: E722 - python/grass/temporal/core.py: E722 python/grass/temporal/datetime_math.py: E722 python/grass/temporal/spatial_topology_dataset_connector.py: E722 python/grass/temporal/temporal_algebra.py: E722 diff --git a/python/grass/temporal/abstract_space_time_dataset.py b/python/grass/temporal/abstract_space_time_dataset.py index 74e38c12e6e..541fc8dd564 100644 --- a/python/grass/temporal/abstract_space_time_dataset.py +++ b/python/grass/temporal/abstract_space_time_dataset.py @@ -19,6 +19,7 @@ class that is the base class for all space time datasets. from abc import ABCMeta, abstractmethod from datetime import datetime from pathlib import Path +from grass.exceptions import FatalError from .abstract_dataset import AbstractDataset, AbstractDatasetComparisonKeyStartTime from .core import ( @@ -2463,7 +2464,9 @@ def is_map_registered(self, map_id, dbif=None): try: dbif.execute(sql, (map_id,), mapset=self.base.mapset) row = dbif.fetchone(mapset=self.base.mapset) - except: + except FatalError: + raise + except Exception: self.msgr.warning(_("Error in register table request")) raise diff --git a/python/grass/temporal/core.py b/python/grass/temporal/core.py index 73cba84b6d3..c350c4fa458 100644 --- a/python/grass/temporal/core.py +++ b/python/grass/temporal/core.py @@ -52,7 +52,7 @@ try: import psycopg2 import psycopg2.extras -except: +except ImportError: pass import atexit @@ -414,7 +414,7 @@ def get_tgis_metadata(dbif=None): statement = "SELECT * FROM tgis_metadata;\n" dbif.execute(statement) rows = dbif.fetchall() - except: + except Exception: rows = None if connection_state_changed: @@ -1501,7 +1501,7 @@ def execute(self, statement, args=None): self.cursor.execute(statement, args) else: self.cursor.execute(statement) - except: + except (sqlite3.Error, psycopg2.Error): if connected: self.close() self.msgr.error(_("Unable to execute :\n %(sql)s") % {"sql": statement}) @@ -1544,7 +1544,7 @@ def execute_transaction(self, statement, mapset=None): else: self.cursor.execute(statement) self.connection.commit() - except: + except (sqlite3.Error, psycopg2.Error): if connected: self.close() self.msgr.error(