-
-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store list of databases in settings #858
Store list of databases in settings #858
Conversation
…nteractively which removes selected grass db. The current grassdb cannot be removed. It is considered as well.
|
Maybe the message could be a bit more explicit: "Do you want to remove the following GRASS GIS database from the data catalogue ?" "The directory itself will not be deleted from the disk." Or something similar ? |
|
Moritz, We have eventually agreed with Anicka that the message will not be needed at all in this case since the user can add removed database to the tree whenever again.
The message is important when one deletes data. So I will create within this PR the function for real database deleting as well and this function will include the message box.
What do you think, does that make sense?
31. 7. 2020 v 6:45, mlennert <notifications@github.com>:
… Maybe the message could be a bit more explicit:
"Do you want to remove the following GRASS GIS database from the data catalogue ?"
"The directory itself will not be deleted from the disk."
Or something similar ?
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
Yes, perfectly ! |
…ssdb path are now stored into UserSettings. Function InsertGrassDb edited to add only grassdb which does not currently exist in the data catalogue.
…GrassDb function.
|
I made code more readable and clear but the error when starting grass for the second time is the same: _Failed to enforce user specified language 'system' with error: 'unsupported locale setting' I will let this error be for now. |
|
Have you tried recompiling all of GRASS GIS ? With a 'make distclean' before the configure+make ? |
Or, to start with a ligher solution: find the line language;locale;lc_all;None in your wx config file. From your error message, I imagine that the last element is 'system' and not 'None' ? Try changing it to 'None'. |
|
Or you could try this in the Python console and see the result: |
Great! I have tried that and it works. |
Observed in the wild by Linda Kladivova OSGeo#858 (comment)
That's strange. 'system' should not creep into wx file. I created a pull request to handle such strange wx files: #877 grass/gui/wxpython/gui_core/preferences.py Line 186 in bc417cd
|
gui/wxpython/core/settings.py
Outdated
| @@ -112,6 +112,10 @@ def _defaultSettings(self): | |||
| 'enabled' : False | |||
| }, | |||
| }, | |||
| # datacatalog | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be on the same level as eg. 'manager'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved. UserSettings needs to have three values so that now it is:
group="datacatalog",
key="grassdb"
subkey="getString"
gui/wxpython/core/settings.py
Outdated
| @@ -112,6 +112,10 @@ def _defaultSettings(self): | |||
| 'enabled' : False | |||
| }, | |||
| }, | |||
| # datacatalog | |||
| 'datacatalog': { | |||
| 'grassdb': None | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe empty string than None for consistent types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
gui/wxpython/datacatalog/catalog.py
Outdated
| dlg = wx.DirDialog(self, _("Choose GRASS data directory:"), | ||
| os.getcwd(), wx.DD_DEFAULT_STYLE) | ||
| if dlg.ShowModal() == wx.ID_OK: | ||
| grassdatabase = dlg.GetPath() | ||
| self.tree.InsertGrassDb(name=grassdatabase) | ||
|
|
||
| grassdb_node = self.tree._model.SearchNodes(name=grassdatabase, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could go into InsertGrassDb directly to avoid code duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved.
gui/wxpython/datacatalog/catalog.py
Outdated
| grassdb_node = self.tree._model.SearchNodes(name=grassdatabase, | ||
| type='grassdb') | ||
| if grassdb_node: | ||
| dlg = wx.MessageDialog( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking maybe we don't have to inform user about this, just check and see if to add it or no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
gui/wxpython/datacatalog/tree.py
Outdated
| @@ -254,8 +256,27 @@ def __init__( | |||
| self._initVariablesCatalog() | |||
| self.UpdateCurrentDbLocationMapsetNode() | |||
|
|
|||
| self.grassdatabases = [] | |||
| self.grassdatabases.append(gisenv()['GISDBASE']) | |||
| self.string_of_grassdatabases = UserSettings.Get( | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually It is enough to use just one variable "self.grassdatabases".
|
I think I know what's the problem with 'system'. Saving settings properly is not well documented, the procedure is more complicated (and the entire settings should be rewritten for better API and format). Basically you need to first load the settings from file, change the parts you want and then save it. This way, you won't get the 'system' there, because that's prevented in core/preferences.py. So taking an example from vdigit: This is the way to update the wx file without writing there any other current /temporary settings. So @lindakladivova please adapt this and make it into a function in tree.py. I would say #877 is not needed, it would hide the real problem. |
|
Also I posted some comments just now, although I made them couple days ago and apparently forgot to hit the submit button, so hopefully they still make sense. |
Anna, I am quite a desperate :/ do not know how to do this. There is a problem that first of all I need to load current grassdb string from wx file: |
|
I committed the new version with some improvements which Anna mentioned but I did not manage solving the "system" problem. |
…ger', kept empty string for consistent types, InsertGrassDb updated, user is not informed about adding an existing database.
|
@lindakladivova could you test it now and I think if it works we can merge this. |
Works perfectly. Let's merge it. |
IMHO it doesn't do any harm to have that workaround there. |
Hiding the problem is in my opinion doing harm... Next time a programmer uses the settings in a wrong way, they won't spot they did something wrong. |
There should be a better way how to spot improper use of settings API than relaying on settings file corruption in a particular way. |
That's not what I am saying. The change you suggest is not needed if the API is used as intended. (The API is weird and should be changed but that's a different discussion). We don't normally check for every misuse of APIs because that's programmer's error. If you want to have the change there, it must be clearly documented why was it added there, otherwise next time somebody looks at the code, they will be confused and the code will bloat. |
|
I agree with Anna on this one. My first reaction was based on my lack of knowledge of the functioning of the settings system. |


The GUI should remember the databases added. Every time a new database is added, a list of databases in the user settings should be updated. This way, a new GUI instance should read the user settings and put the databases to the list (if the directories still exist). The GUI should allow to remove the database from the tree. This should again be reflected in the user settings.