From d1d88cf35e71d3494ae55145ce9d865a9dab937a Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Tue, 5 Nov 2024 11:34:38 -0500 Subject: [PATCH] GUI: fix for Python3.13 --- gui/wxpython/core/gconsole.py | 34 ++++++++++++++++++++-------------- gui/wxpython/core/gthread.py | 18 +++++++++++------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index 5b58c08cc55..cde41710cd9 100644 --- a/gui/wxpython/core/gconsole.py +++ b/gui/wxpython/core/gconsole.py @@ -120,6 +120,14 @@ def SetId(self, id): def run(self): os.environ["GRASS_MESSAGE_FORMAT"] = "gui" while True: + variables = { + "callable": None, + "onDone": None, + "onPrepare": None, + "userData": None, + "addLayer": None, + "notification": None, + } requestId, args, kwds = self.requestQ.get() for key in ( "callable", @@ -130,13 +138,11 @@ def run(self): "notification", ): if key in kwds: - vars()[key] = kwds[key] + variables[key] = kwds[key] del kwds[key] - else: - vars()[key] = None - if not vars()["callable"]: - vars()["callable"] = GrassCmd + if not variables["callable"]: + variables["callable"] = GrassCmd requestTime = time.time() @@ -146,21 +152,21 @@ def run(self): cmd=args[0], time=requestTime, pid=requestId, - onPrepare=vars()["onPrepare"], - userData=vars()["userData"], + onPrepare=variables["onPrepare"], + userData=variables["userData"], ) wx.PostEvent(self.receiver, event) # run command event = wxCmdRun( - cmd=args[0], pid=requestId, notification=vars()["notification"] + cmd=args[0], pid=requestId, notification=variables["notification"] ) wx.PostEvent(self.receiver, event) time.sleep(0.1) - self.requestCmd = vars()["callable"](*args, **kwds) + self.requestCmd = variables["callable"](*args, **kwds) if self._want_abort_all and self.requestCmd is not None: self.requestCmd.abort() if self.requestQ.empty(): @@ -211,7 +217,7 @@ def run(self): "map=%s" % mapName, "color=%s" % colorTable, ] - self.requestCmdColor = vars()["callable"](*argsColor, **kwds) + self.requestCmdColor = variables["callable"](*argsColor, **kwds) self.resultQ.put((requestId, self.requestCmdColor.run())) if self.receiver: @@ -221,10 +227,10 @@ def run(self): returncode=returncode, time=requestTime, pid=requestId, - onDone=vars()["onDone"], - userData=vars()["userData"], - addLayer=vars()["addLayer"], - notification=vars()["notification"], + onDone=variables["onDone"], + userData=variables["userData"], + addLayer=variables["addLayer"], + notification=variables["notification"], ) # send event diff --git a/gui/wxpython/core/gthread.py b/gui/wxpython/core/gthread.py index 3437d04bf56..3e1eae86623 100644 --- a/gui/wxpython/core/gthread.py +++ b/gui/wxpython/core/gthread.py @@ -86,21 +86,25 @@ def SetId(self, id): gThread.requestId = id def run(self): + variables = { + "callable": None, + "ondone": None, + "userdata": None, + "onterminate": None, + } while True: requestId, args, kwds = self.requestQ.get() for key in ("callable", "ondone", "userdata", "onterminate"): if key in kwds: - vars()[key] = kwds[key] + variables[key] = kwds[key] del kwds[key] - else: - vars()[key] = None ret = None exception = None time.sleep(0.01) self._terminate_evt = wxThdTerminate( - onterminate=vars()["onterminate"], + onterminate=variables["onterminate"], kwds=kwds, args=args, pid=requestId, @@ -109,7 +113,7 @@ def run(self): if self.terminate: return - ret = vars()["callable"](*args, **kwds) + ret = variables["callable"](*args, **kwds) if self.terminate: return @@ -119,12 +123,12 @@ def run(self): self.resultQ.put((requestId, ret)) event = wxCmdDone( - ondone=vars()["ondone"], + ondone=variables["ondone"], kwds=kwds, args=args, # TODO expand args to kwds ret=ret, exception=exception, - userdata=vars()["userdata"], + userdata=variables["userdata"], pid=requestId, )