From 88774ce75b52f4a38e92384e53e6069b7b6987ce Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Wed, 12 Jul 2023 22:31:55 +0200 Subject: [PATCH 1/3] wxGUI/dbmgr: fix show attribute table for vector map from another mapset --- gui/wxpython/dbmgr/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 857a644c786..d9cf5be2581 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -3069,6 +3069,7 @@ def __init__(self, parent, id, parentDialog, style=wx.BK_DEFAULT): self.parent = parent self.parentDialog = parentDialog self.mapDBInfo = self.parentDialog.dbMgrData["mapDBInfo"] + vectName = self.parentDialog.dbMgrData["vectName"] # # drivers @@ -3083,7 +3084,11 @@ def __init__(self, parent, id, parentDialog, style=wx.BK_DEFAULT): # get default values # self.defaultConnect = {} + vectMapset = vectName.split("@")[-1] + defaultMapset = RunCommand("g.mapset", flags="p", read=True, quiet=True).strip() + RunCommand("g.mapset", mapset=vectMapset, quiet=True) connect = RunCommand("db.connect", flags="p", read=True, quiet=True) + RunCommand("g.mapset", mapset=defaultMapset, quiet=True) for line in connect.splitlines(): item, value = line.split(":", 1) From 6d6c7418f1a8e3404883533697da70bbb79a9f28 Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Fri, 14 Jul 2023 22:24:53 +0200 Subject: [PATCH 2/3] Create and use env for vector map from another mapset --- gui/wxpython/dbmgr/base.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index d9cf5be2581..651c4696bcd 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -3084,11 +3084,21 @@ def __init__(self, parent, id, parentDialog, style=wx.BK_DEFAULT): # get default values # self.defaultConnect = {} + genv = grass.gisenv() vectMapset = vectName.split("@")[-1] - defaultMapset = RunCommand("g.mapset", flags="p", read=True, quiet=True).strip() - RunCommand("g.mapset", mapset=vectMapset, quiet=True) - connect = RunCommand("db.connect", flags="p", read=True, quiet=True) - RunCommand("g.mapset", mapset=defaultMapset, quiet=True) + vectEnv = grass.create_environment( + gisdbase=genv["GISDBASE"], + location=genv["LOCATION_NAME"], + mapset=vectMapset, + ) + connect = RunCommand( + "db.connect", + flags="p", + env=vectEnv[1], + read=True, + quiet=True, + ) + grass.utils.try_remove(vectEnv[0]) for line in connect.splitlines(): item, value = line.split(":", 1) From daa7e860d4a5a814b2aa325d4b42f9d46d9b9f31 Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Tue, 18 Jul 2023 13:37:23 +0200 Subject: [PATCH 3/3] Get vect map MAPSET by gs.find_file() func --- gui/wxpython/dbmgr/base.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 651c4696bcd..7c5861b40ff 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -3085,20 +3085,23 @@ def __init__(self, parent, id, parentDialog, style=wx.BK_DEFAULT): # self.defaultConnect = {} genv = grass.gisenv() - vectMapset = vectName.split("@")[-1] - vectEnv = grass.create_environment( + vectMap = grass.find_file( + name=vectName, + element="vector", + ) + vectGisrc, vectEnv = grass.create_environment( gisdbase=genv["GISDBASE"], location=genv["LOCATION_NAME"], - mapset=vectMapset, + mapset=vectMap["mapset"], ) connect = RunCommand( "db.connect", flags="p", - env=vectEnv[1], + env=vectEnv, read=True, quiet=True, ) - grass.utils.try_remove(vectEnv[0]) + grass.utils.try_remove(vectGisrc) for line in connect.splitlines(): item, value = line.split(":", 1)