Skip to content
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

wxGUI: New History pane for launching commands from history log #3234

Merged
merged 19 commits into from
Dec 8, 2023

Conversation

lindakarlovska
Copy link
Contributor

@lindakarlovska lindakarlovska commented Nov 10, 2023

This PR creates a new History pane which allows us to launch commands contained in .wxgui_history file.
The history pane is visible on the right side:

Screenshot from 2023-11-10 16-22-06

It tries to parse the command. If the parsing is not successful, it writes the message: "History record cound not be parsed into command" into the Main window statusbar. In the case when parsing successes, it opens the dialog with filled command parameters.

History panel is also linked to mapset switching, so when mapset is switched the tree is regenerated based on the relevant wxgui_history file.

@lindakarlovska lindakarlovska self-assigned this Nov 10, 2023
@lindakarlovska lindakarlovska added enhancement New feature or request GUI wxGUI related labels Nov 10, 2023
@lindakarlovska lindakarlovska added this to the 8.4.0 milestone Nov 10, 2023
@lindakarlovska
Copy link
Contributor Author

@petrasovaa why did you unassign me?

@wenzeslaus
Copy link
Member

@petrasovaa why did you unassign me?

@lindakladivova Nothing changes for you, but during PSC meeting today, we agreed on an initial policy for handling PRs and this was a one of the PRs we tested the policy on. Each PR should have a assignee who is responsible for moving the PR towards being closed. We will work on making this official. While for issues, nothing changes, assignee for a PR will be someone with write access, i.e., someone who can do the actual merge when the code is ready. You can comment on that in #3235.

@wenzeslaus
Copy link
Member

it write the message: "History record cound not be parsed into command"

Maybe it can open a dialog just like in the successful case, but say "...but here it is and you can copy it and modify as needed: ...".

@lindakarlovska
Copy link
Contributor Author

it write the message: "History record cound not be parsed into command"

Maybe it can open a dialog just like in the successful case, but say "...but here it is and you can copy it and modify as needed: ...".

Yes, It could open the module dialog based on the module called, but the issue is that in a history file, there can be lots of mistakes (calling of nonexisting modules etc.) so probably when the module is decoded, we can launch the relevant empty module dialog but otherwise, just show the message "History record cound not be parsed into command" in the statusbar?

I was also thinking about history file itself. I would suggest changing it to JSON format and to also save dates within it or other information such as "task failed", "task succeeded". It could possibly be the tree of dates with subitems as commands. What do you think @petrasovaa ?

These improvements could be implemented in following PRs. 🙂

@petrasovaa
Copy link
Contributor

Just a quick testing, it looks like the content is not being updated when you run a tool?

@petrasovaa
Copy link
Contributor

I am getting:

Traceback (most recent call last):
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 870, in OnRun

ret = self._gconsole.RunCmd(cmd, onDone=self.OnDone)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/gconsole.py", line 501, in RunCmd

self.UpdateHistoryFile(cmd_save_to_history)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/gconsole.py", line 823, in
UpdateHistoryFile

fileHistory = codecs.open(filePath, encoding="utf-8",
mode="a")
  File "/usr/lib/python3.8/codecs.py", line 905, in open

file = builtins.open(filename, mode, buffering)
TypeError
:
expected str, bytes or os.PathLike object, not NoneType

It looks like this happens in a new mapset.

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think putting the code in menu.py and menudata.py is not a good choice, it's unrelated. Either put it all in one file history.py, which could go into lmgr/ or create a history folder (similar to datacatalog) and put the files there.

lindakladivova added 2 commits November 18, 2023 10:56
…from empty history mapset, creating a new updateHistory signal
…ng history file moved to new grassdb/history.py
@lindakarlovska
Copy link
Contributor Author

I think putting the code in menu.py and menudata.py is not a good choice, it's unrelated. Either put it all in one file history.py, which could go into lmgr/ or create a history folder (similar to datacatalog) and put the files there.

You are right, I created the folder history_catalog and inside there are new python files "catalog" and "tree".

@lindakarlovska
Copy link
Contributor Author

Just a quick testing, it looks like the content is not being updated when you run a tool?

Now fixed. I created a new signal giface.updateHistory and connected several methods to it.

@lindakarlovska
Copy link
Contributor Author

I am getting:

Traceback (most recent call last):
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 870, in OnRun

ret = self._gconsole.RunCmd(cmd, onDone=self.OnDone)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/gconsole.py", line 501, in RunCmd

self.UpdateHistoryFile(cmd_save_to_history)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/gconsole.py", line 823, in
UpdateHistoryFile

fileHistory = codecs.open(filePath, encoding="utf-8",
mode="a")
  File "/usr/lib/python3.8/codecs.py", line 905, in open

file = builtins.open(filename, mode, buffering)
TypeError
:
expected str, bytes or os.PathLike object, not NoneType

It looks like this happens in a new mapset.

Fixed.

landam
landam previously requested changes Nov 19, 2023
Copy link
Member

@landam landam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently wxGUI fails when wxgui_history file is missing (open GUI first time in a new mapset):

  File "/usr/lib/python3/dist-packages/wx/core.py", line 3427, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py", line 93, in show_main_gui
    mainframe = GMFrame(
                ^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 184, in __init__
    self.BuildPanes()
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 571, in BuildPanes
    self._createConsole(parent=self)
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 370, in _createConsole
    self.goutput = GConsoleWindow(
                   ^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/goutput.py", line 146, in __init__
    self._loadHistory()
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/goutput.py", line 263, in _loadHistory
    self.cmdPrompt.cmdbuffer = read_history(history_path)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/grassdb/history.py", line 38, in read_history
    fileHistory = codecs.open(
                  ^^^^^^^^^^^^
  File "<frozen codecs>", line 918, in open
TypeError: expected str, bytes or os.PathLike object, not NoneType

@lindakarlovska
Copy link
Contributor Author

Currently wxGUI fails when wxgui_history file is missing (open GUI first time in a new mapset):

  File "/usr/lib/python3/dist-packages/wx/core.py", line 3427, in <lambda>

    lambda event: event.callable(*event.args, **event.kw) )

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py", line 93, in show_main_gui

    mainframe = GMFrame(

                ^^^^^^^^

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 184, in __init__

    self.BuildPanes()

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 571, in BuildPanes

    self._createConsole(parent=self)

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/main_window/frame.py", line 370, in _createConsole

    self.goutput = GConsoleWindow(

                   ^^^^^^^^^^^^^^^

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/goutput.py", line 146, in __init__

    self._loadHistory()

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/goutput.py", line 263, in _loadHistory

    self.cmdPrompt.cmdbuffer = read_history(history_path)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/grassdb/history.py", line 38, in read_history

    fileHistory = codecs.open(

                  ^^^^^^^^^^^^

  File "<frozen codecs>", line 918, in open

TypeError: expected str, bytes or os.PathLike object, not NoneType

Ah ok, thanks for catching Martin. I had fixed it but probably through several iterations, it has occured again… I will look at it.

lindakarlovska and others added 5 commits December 1, 2023 16:50
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

gui/wxpython/history/browser.py Outdated Show resolved Hide resolved
gui/wxpython/history/browser.py Outdated Show resolved Hide resolved
gui/wxpython/gui_core/goutput.py Outdated Show resolved Hide resolved
@petrasovaa petrasovaa merged commit 8fd28c4 into OSGeo:main Dec 8, 2023
18 checks passed
HuidaeCho pushed a commit to HuidaeCho/grass that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GUI wxGUI related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants