diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index 4705d639297..4e7919ddf16 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 7bd8929c553..4a0918a149f 100644 --- a/gui/wxpython/core/gthread.py +++ b/gui/wxpython/core/gthread.py @@ -86,14 +86,18 @@ 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 requestTime = time.time() @@ -102,7 +106,7 @@ def run(self): time.sleep(0.01) self._terminate_evt = wxThdTerminate( - onterminate=vars()["onterminate"], + onterminate=variables["onterminate"], kwds=kwds, args=args, pid=requestId, @@ -111,7 +115,7 @@ def run(self): if self.terminate: return - ret = vars()["callable"](*args, **kwds) + ret = variables["callable"](*args, **kwds) if self.terminate: return @@ -121,12 +125,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, )