From af71e17c793d4f0a0a420e5fb672941d2d07263f Mon Sep 17 00:00:00 2001 From: mshukun Date: Wed, 28 Aug 2024 17:30:46 -0400 Subject: [PATCH 1/4] Delete unused variables and lines to fix F841 --- gui/wxpython/animation/mapwindow.py | 2 +- gui/wxpython/animation/provider.py | 2 +- gui/wxpython/core/gthread.py | 2 -- gui/wxpython/core/render.py | 2 -- gui/wxpython/core/utils.py | 4 ++-- gui/wxpython/core/ws.py | 2 -- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/gui/wxpython/animation/mapwindow.py b/gui/wxpython/animation/mapwindow.py index 749a2da147d..4a6822e0841 100644 --- a/gui/wxpython/animation/mapwindow.py +++ b/gui/wxpython/animation/mapwindow.py @@ -61,7 +61,7 @@ def Draw(self, dc): def OnPaint(self, event): Debug.msg(5, "BufferedWindow.OnPaint()") # All that is needed here is to draw the buffer to screen - dc = wx.BufferedPaintDC(self, self._Buffer) + wx.BufferedPaintDC(self, self._Buffer) def OnSize(self, event): Debug.msg(5, "BufferedWindow.OnSize()") diff --git a/gui/wxpython/animation/provider.py b/gui/wxpython/animation/provider.py index 46eddea7294..fd966219407 100644 --- a/gui/wxpython/animation/provider.py +++ b/gui/wxpython/animation/provider.py @@ -924,7 +924,7 @@ def test(): prov.mapsLoaded.connect(lambda: sys.stdout.write("Maps loading finished\n")) cmdMatrix = layerListToCmdsMatrix(layerList) prov.SetCmds(cmdMatrix, [layer.opacity for layer in layerList]) - app = wx.App() + wx.App() prov.Load(bgcolor=(13, 156, 230), nprocs=4) diff --git a/gui/wxpython/core/gthread.py b/gui/wxpython/core/gthread.py index 7bd8929c553..44a938f335a 100644 --- a/gui/wxpython/core/gthread.py +++ b/gui/wxpython/core/gthread.py @@ -95,8 +95,6 @@ def run(self): else: vars()[key] = None - requestTime = time.time() - ret = None exception = None time.sleep(0.01) diff --git a/gui/wxpython/core/render.py b/gui/wxpython/core/render.py index 021f3aa6500..b63f930fdce 100644 --- a/gui/wxpython/core/render.py +++ b/gui/wxpython/core/render.py @@ -666,8 +666,6 @@ def OnRenderDone(self, env): Make image composiotion, emits updateMap event. """ - stopTime = time.time() - maps = [] masks = [] opacities = [] diff --git a/gui/wxpython/core/utils.py b/gui/wxpython/core/utils.py index fe4f40c359a..d5554a1081c 100644 --- a/gui/wxpython/core/utils.py +++ b/gui/wxpython/core/utils.py @@ -827,7 +827,7 @@ def StoreEnvVariable(key, value=None, envFile=None): if os.path.exists(envFile): try: fd = open(envFile) - except OSError as e: + except OSError: sys.stderr.write(_("Unable to open file '%s'\n") % envFile) return for line in fd: @@ -857,7 +857,7 @@ def StoreEnvVariable(key, value=None, envFile=None): # write update env file try: fd = open(envFile, "w") - except OSError as e: + except OSError: sys.stderr.write(_("Unable to create file '%s'\n") % envFile) return if windows: diff --git a/gui/wxpython/core/ws.py b/gui/wxpython/core/ws.py index 156cd0166f9..010deac824f 100644 --- a/gui/wxpython/core/ws.py +++ b/gui/wxpython/core/ws.py @@ -99,7 +99,6 @@ def Render(self, cmd, env): self.updateMap = True fetchData = True # changed to True when calling Render() - zoomChanged = False if self.renderedRegion is None or cmd != self.fetched_data_cmd: fetchData = True @@ -111,7 +110,6 @@ def Render(self, cmd, env): for c in ["e-w resol", "n-s resol"]: if self.renderedRegion and region[c] != self.renderedRegion[c]: - zoomChanged = True break if fetchData: From c0b7d4f6e9a49cb63d2b192bc69f4089c2e5f5d9 Mon Sep 17 00:00:00 2001 From: mshukun Date: Wed, 28 Aug 2024 17:30:59 -0400 Subject: [PATCH 2/4] Update `.flake8` according to F841 fixes --- .flake8 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index 573debabe1c..82eba32ceee 100644 --- a/.flake8 +++ b/.flake8 @@ -42,13 +42,11 @@ per-file-ignores = locale/grass_po_stats.py: E122, E128, E231, E401, E722 gui/scripts/d.wms.py: E501 gui/wxpython/core/gcmd.py: E402 - gui/wxpython/core/gthread.py: F841 gui/wxpython/core/gconsole.py: E722 gui/wxpython/core/toolboxes.py: E722 - gui/wxpython/core/utils.py: E722, F841 + gui/wxpython/core/utils.py: E722 gui/wxpython/core/workspace.py: E722 - gui/wxpython/core/render.py: E722, F841 - gui/wxpython/core/ws.py: F841 + gui/wxpython/core/render.py: E722 gui/wxpython/core/settings.py: E722 gui/wxpython/core/watchdog.py: E402 gui/wxpython/datacatalog/tree.py: E731, E402 From 4d5fc17251b9642ea2e4a162be63644fa2aeb27f Mon Sep 17 00:00:00 2001 From: mshukun Date: Thu, 29 Aug 2024 10:53:45 -0400 Subject: [PATCH 3/4] Update .flake8 by removing the F841 fixes that were missed --- .flake8 | 2 -- 1 file changed, 2 deletions(-) diff --git a/.flake8 b/.flake8 index 82eba32ceee..c1b6804100c 100644 --- a/.flake8 +++ b/.flake8 @@ -83,8 +83,6 @@ per-file-ignores = gui/wxpython/vnet/*: F841 gui/wxpython/wxgui.py: F841 gui/wxpython/animation/g.gui.animation.py: E501 - gui/wxpython/animation/mapwindow.py: F841 - gui/wxpython/animation/provider.py: F841 gui/wxpython/tplot/frame.py: F841, E722 gui/wxpython/tplot/g.gui.tplot.py: E501 gui/wxpython/rdigit/g.gui.rdigit.py: F841 From 6d0d1985dffff81311f24d137c04760dc96b184e Mon Sep 17 00:00:00 2001 From: mshukun Date: Thu, 29 Aug 2024 11:36:24 -0400 Subject: [PATCH 4/4] Use OSError output in stderr --- gui/wxpython/core/utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gui/wxpython/core/utils.py b/gui/wxpython/core/utils.py index d5554a1081c..10d6dca2759 100644 --- a/gui/wxpython/core/utils.py +++ b/gui/wxpython/core/utils.py @@ -827,8 +827,12 @@ def StoreEnvVariable(key, value=None, envFile=None): if os.path.exists(envFile): try: fd = open(envFile) - except OSError: - sys.stderr.write(_("Unable to open file '%s'\n") % envFile) + except OSError as error: + sys.stderr.write( + _("Unable to open file '{name}': {error}\n").format( + name=envFile, error=error + ) + ) return for line in fd: line = line.rstrip(os.linesep) @@ -857,8 +861,12 @@ def StoreEnvVariable(key, value=None, envFile=None): # write update env file try: fd = open(envFile, "w") - except OSError: - sys.stderr.write(_("Unable to create file '%s'\n") % envFile) + except OSError as error: + sys.stderr.write( + _("Unable to create file '{name}': {error}\n").format( + name=envFile, error=error + ) + ) return if windows: expCmd = "set"