From 36f4b22deaa4fe221edff3a73b2703fadeaf9642 Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Mon, 17 Jul 2023 10:04:11 -0400 Subject: [PATCH] wxGUI: initialize db connection when creating new mapset (#3086) Partly addresses #3078 --- gui/wxpython/startup/guiutils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gui/wxpython/startup/guiutils.py b/gui/wxpython/startup/guiutils.py index 8427f3b2870..42382f2e76d 100644 --- a/gui/wxpython/startup/guiutils.py +++ b/gui/wxpython/startup/guiutils.py @@ -117,6 +117,13 @@ def _isLocationNameValid(self, text): return is_location_name_valid(self.database, text) +def initialize_mapset(grassdb, location, mapset): + """Initialize mapset (database connection)""" + gisrc_file, env = create_environment(grassdb, location, mapset) + RunCommand("db.connect", flags="c", env=env) + try_remove(gisrc_file) + + def create_mapset_interactively(guiparent, grassdb, location): """ Create new mapset @@ -135,6 +142,7 @@ def create_mapset_interactively(guiparent, grassdb, location): mapset = dlg.GetValue() try: create_mapset(grassdb, location, mapset) + initialize_mapset(grassdb, location, mapset) except OSError as err: mapset = None GError(