diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 49f4c1aae4a..63bfd709bcf 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -36,7 +36,7 @@ jobs: # renovate: datasource=pypi depName=bandit BANDIT_VERSION: "1.7.10" # renovate: datasource=pypi depName=ruff - RUFF_VERSION: "0.7.3" + RUFF_VERSION: "0.7.4" runs-on: ${{ matrix.os }} permissions: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 712342dc83a..449a9a61f04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: ) - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.7.3 + rev: v0.7.4 hooks: # Run the linter. - id: ruff diff --git a/python/grass/pygrass/rpc/base.py b/python/grass/pygrass/rpc/base.py index c436300c170..e12bea9f985 100644 --- a/python/grass/pygrass/rpc/base.py +++ b/python/grass/pygrass/rpc/base.py @@ -25,6 +25,10 @@ from multiprocessing.connection import Connection from multiprocessing.synchronize import _LockLike + +logger: logging.Logger = logging.getLogger(__name__) + + ############################################################################### @@ -134,7 +138,7 @@ def thread_checker(self): def start_server(self): """This function must be re-implemented in the subclasses""" - logging.debug("Start the libgis server") + logger.debug("Start the libgis server") self.client_conn, self.server_conn = Pipe(True) self.lock = Lock() @@ -147,7 +151,7 @@ def check_server(self): def _check_restart_server(self, caller="main thread") -> None: """Restart the server if it was terminated""" - logging.debug("Check libgis server restart") + logger.debug("Check libgis server restart") with self.threadLock: if self.server is not None and self.server.is_alive() is True: @@ -159,9 +163,9 @@ def _check_restart_server(self, caller="main thread") -> None: self.start_server() if self.stopped is not True: - logging.warning( - "Needed to restart the libgis server, caller: {caller}", - caller=caller, + logger.warning( + "Needed to restart the libgis server, caller: %(caller)s", + {"caller": caller}, ) self.stopped = False @@ -169,7 +173,8 @@ def _check_restart_server(self, caller="main thread") -> None: def safe_receive(self, message): """Receive the data and throw a FatalError exception in case the server process was killed and the pipe was closed by the checker thread""" - logging.debug("Receive message: {message}") + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Receive message: %s", message) try: ret = self.client_conn.recv() @@ -186,7 +191,7 @@ def stop(self): This method should be called at exit using the package atexit """ - logging.debug("Stop libgis server") + logger.debug("Stop libgis server") self.stop_checker_thread() if self.server is not None and self.server.is_alive(): diff --git a/python/grass/temporal/c_libraries_interface.py b/python/grass/temporal/c_libraries_interface.py index 9283baaba93..5ac75f6b139 100644 --- a/python/grass/temporal/c_libraries_interface.py +++ b/python/grass/temporal/c_libraries_interface.py @@ -36,6 +36,9 @@ from multiprocessing.connection import Connection from multiprocessing.synchronize import _LockLike + +logger = logging.getLogger(__name__) + ############################################################################### @@ -472,8 +475,9 @@ def _write_timestamp(lock: _LockLike, conn: Connection, data): check = libgis.G_scan_timestamp(byref(ts), timestring) if check != 1: - logging.error( - "Unable to convert the timestamp: {timestring}", timestring=timestring + logger.error( + "Unable to convert the timestamp: %(timestring)s", + {"timestring": timestring}, ) return -2 @@ -554,9 +558,9 @@ def _read_semantic_label(lock: _LockLike, conn: Connection, data): if ret: semantic_label = decode(ret) else: - logging.error( - "Unable to read semantic label. Unsupported map type {maptype}", - maptype=maptype, + logger.error( + "Unable to read semantic label. Unsupported map type %(maptype)s", + {"maptype": maptype}, ) return -1 finally: @@ -591,9 +595,9 @@ def _write_semantic_label(lock: _LockLike, conn: Connection, data): raise ValueError(_("Invalid semantic label")) libraster.Rast_write_semantic_label(name, semantic_label) else: - logging.error( - "Unable to write semantic label. Unsupported map type {maptype}", - maptype=maptype, + logger.error( + "Unable to write semantic label. Unsupported map type %(maptype)s", + {"maptype": maptype}, ) return -2 finally: @@ -625,9 +629,9 @@ def _remove_semantic_label(lock: _LockLike, conn: Connection, data): if maptype == RPCDefs.TYPE_RASTER: check = libgis.G_remove_misc("cell_misc", "semantic_label", name) else: - logging.error( - "Unable to remove semantic label. Unsupported map type {maptype}", - maptype=maptype, + logger.error( + "Unable to remove semantic label. Unsupported map type %(maptype)s", + {"maptype": maptype}, ) return -2 finally: @@ -743,11 +747,11 @@ def _read_raster_info(name, mapset): libraster.Rast_init_fp_range(byref(range)) ret = libraster.Rast_read_fp_range(name, mapset, byref(range)) if ret < 0: - logging.warning(_("Unable to read range file")) + logger.warning(_("Unable to read range file")) kvp["min"] = None kvp["max"] = None elif ret == 2: - logging.info(_("Raster range file is empty")) + logger.info(_("Raster range file is empty")) kvp["min"] = None kvp["max"] = None else: @@ -761,11 +765,11 @@ def _read_raster_info(name, mapset): libraster.Rast_init_range(byref(range)) ret = libraster.Rast_read_range(name, mapset, byref(range)) if ret < 0: - logging.warning(_("Unable to read range file")) + logger.warning(_("Unable to read range file")) kvp["min"] = None kvp["max"] = None elif ret == 2: - logging.info(_("Raster range file is empty")) + logger.info(_("Raster range file is empty")) kvp["min"] = None kvp["max"] = None else: @@ -831,7 +835,7 @@ def _read_raster3d_info(name, mapset): ) if not g3map: - logging.error(_("Unable to open 3D raster map <%s>"), (name)) + logger.error(_("Unable to open 3D raster map <%s>"), name) return None maptype = libraster3d.Rast3d_file_type_map(g3map) @@ -846,7 +850,7 @@ def _read_raster3d_info(name, mapset): max = libgis.DCELL() ret = libraster3d.Rast3d_range_load(g3map) if not ret: - logging.error(_("Unable to load range of 3D raster map <%s>"), (name)) + logger.error(_("Unable to load range of 3D raster map <%s>"), name) return None libraster3d.Rast3d_range_min_max(g3map, byref(min), byref(max)) @@ -860,7 +864,7 @@ def _read_raster3d_info(name, mapset): kvp["max"] = float(max.value) if not libraster3d.Rast3d_close(g3map): - logging.error(_("Unable to close 3D raster map <%s>"), (name)) + logger.error(_("Unable to close 3D raster map <%s>"), name) return None return kvp @@ -902,9 +906,9 @@ def _read_vector_info(name, mapset): libvector.Vect_set_open_level(1) # no topology with_topo = False if libvector.Vect_open_old2(byref(Map), name, mapset, "1") < 1: - logging.error( + logger.error( _("Unable to open vector map <%s>"), - (libvector.Vect_get_full_name(byref(Map))), + libvector.Vect_get_full_name(byref(Map)), ) return None @@ -1026,7 +1030,7 @@ def _read_raster_history(name, mapset): hist = libraster.History() ret = libraster.Rast_read_history(name, mapset, byref(hist)) if ret < 0: - logging.warning(_("Unable to read history file")) + logger.warning(_("Unable to read history file")) return None kvp["creation_time"] = decode( libraster.Rast_get_history(byref(hist), libraster.HIST_MAPID) @@ -1063,7 +1067,7 @@ def _read_raster3d_history(name, mapset): hist = libraster.History() ret = libraster3d.Rast3d_read_history(name, mapset, byref(hist)) if ret < 0: - logging.warning(_("Unable to read history file")) + logger.warning(_("Unable to read history file")) return None kvp["creation_time"] = decode( libraster.Rast_get_history(byref(hist), libraster3d.HIST_MAPID) diff --git a/vector/v.rectify/v.rectify.html b/vector/v.rectify/v.rectify.html index a90eefef229..5f6ac718fd7 100644 --- a/vector/v.rectify/v.rectify.html +++ b/vector/v.rectify/v.rectify.html @@ -46,11 +46,11 @@

Coordinate transformation and RMSE

The desired order of transformation (1, 2, or 3) is selected with the order option. -If the -r flag is given, v.rectify will calculate the +If the -r flag is given, v.rectify will calculate the Root Mean Square Error (RMSE) and print out statistics in tabular format. -The last row gives a summary with the first column holding the number of -active points, followed by average deviations for each dimension and both -forward and backward transformation and finally forward and backward +The last row gives a summary with the first column holding the number of +active points, followed by average deviations for each dimension and both +forward and backward transformation and finally forward and backward overall RMSE.

2D linear affine transformation (1st order transformation)