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: Console: Export history of executed commands #2682

Merged
merged 10 commits into from
Jan 5, 2023

Conversation

lindakarlovska
Copy link
Contributor

@lindakarlovska lindakarlovska commented Dec 4, 2022

This PR changes the way how the Log file button works. In this PR it is renamed to Export history because it better reflects what it newly does.

Original behavior (the button Log file is togglable):

  1. Press the button Log file in the Console
  2. Choose where you want to store executed commands
  3. Starting this moment, all executed commands are stored to this file
  4. Press the button Log file again and stop storing executed commands to the defined file

New behavior (the button Export History is not togglable):

  1. Press the button Export History in the Console
  2. Choose where you want to store executed commands
  3. Store the whole history of executed commands (content of .wxgui_history file which is a part of a mapset)

All executed command history related to particular mapset environment can be automatically saved by clicking on the Export history button:
Screenshot from 2022-12-04 16-46-45

@lindakarlovska lindakarlovska added GUI wxGUI related enhancement New feature or request labels Dec 4, 2022
@lindakarlovska lindakarlovska added this to the 8.3.0 milestone Dec 4, 2022
gui/wxpython/gui_core/goutput.py Outdated Show resolved Hide resolved
gui/wxpython/gui_core/goutput.py Outdated Show resolved Hide resolved
Comment on lines 483 to 485
try:
self.cmdPrompt.CopyHistory(path)
except IOError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move the exception handling in the CopyHistory. Check if the error type is appropriate, it seems OSError should be used instead.

Copy link
Contributor Author

@lindakarlovska lindakarlovska Dec 7, 2022

Choose a reason for hiding this comment

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

Good, I moved it to the CopyHistory. I think that the error type is okay according to https://docs.python.org/3/library/shutil.html : Changed in version 3.3: IOError used to be raised instead of OSError. Added follow_symlinks argument. Now returns dst.
But when I looked at the examples of how to use shutil.copyfile I found out that they use handling of different error types: https://www.geeksforgeeks.org/python-shutil-copyfile-method/
So difficult to decide... I would probably keep the IOError or just put the general except Exception as e: . What do you think?

path = dlg.GetPath()
try:
self.cmdPrompt.CopyHistory(path)
except IOError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
except IOError as e:
except (IOError, OSError) as e:

Maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. A good compromise.

gui/wxpython/gui_core/prompt.py Outdated Show resolved Hide resolved
gui/wxpython/gui_core/goutput.py Outdated Show resolved Hide resolved
@petrasovaa petrasovaa merged commit 87e1f78 into OSGeo:main Jan 5, 2023
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Replaces log file toggle functionality by exporting the whole history of executed commands
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
Replaces log file toggle functionality by exporting the whole history of executed commands
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.

3 participants