Skip to content

Commit

Permalink
wxGUI: initialize db connection when creating new mapset (#3086)
Browse files Browse the repository at this point in the history
Partly addresses #3078
  • Loading branch information
petrasovaa committed Jul 17, 2023
1 parent c2fd5fe commit bd8ef29
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gui/wxpython/startup/guiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit bd8ef29

Please sign in to comment.