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/history: Add time/status icons in front of browser nodes #3679

Merged
merged 11 commits into from
May 9, 2024
Binary file added gui/icons/grass/circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions gui/icons/grass/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/icons/grass/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions gui/icons/grass/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/icons/grass/exclamation-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions gui/icons/grass/exclamation-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/icons/grass/question-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions gui/icons/grass/question-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/icons/grass/success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions gui/icons/grass/success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/icons/grass/time-period.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions gui/icons/grass/time-period.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 31 additions & 4 deletions gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,21 @@ def WriteError(self, text):
"""Write message in error style"""
self.writeError.emit(text=text)

def UpdateHistory(self, status):
"""Update command history"""
cmd_info = {"status": status}

try:
history_path = history.get_current_mapset_gui_history_path()
history.update_entry(history_path, cmd_info)

# update history model
if self._giface:
entry = history.read(history_path)[-1]
self._giface.entryInHistoryUpdated.emit(entry=entry)
except (OSError, ValueError) as e:
GError(str(e))

def RunCmd(
self,
command,
Expand Down Expand Up @@ -529,14 +544,16 @@ def RunCmd(
):
event = gIgnoredCmdRun(cmd=command)
wx.PostEvent(self, event)
return

self.UpdateHistory(status=history.STATUS_FAILED)
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
return
else:
# other GRASS commands (r|v|g|...)
try:
task = GUI(show=None).ParseCommand(command)
except GException as e:
GError(parent=self._guiparent, message=str(e), showTraceback=False)
self.UpdateHistory(status=history.STATUS_FAILED)
return

hasParams = False
Expand All @@ -560,6 +577,7 @@ def RunCmd(
)
% {"cmd": " ".join(command), "opt": p.get("name", "")},
)
self.UpdateHistory(status=history.STATUS_FAILED)
return

if len(command) == 1:
Expand All @@ -580,6 +598,8 @@ def RunCmd(
parent=self._guiparent,
message=_("Module <%s> not found.") % command[0],
)
self.UpdateHistory(status=history.STATUS_FAILED)

pymodule = imp.load_source(command[0].replace(".", "_"), pyPath)
pymain = inspect.getfullargspec(pymodule.main)
if pymain and "giface" in pymain.args:
Expand All @@ -593,8 +613,11 @@ def RunCmd(
GUI(
parent=self._guiparent, giface=self._giface
).ParseCommand(command)
self.UpdateHistory(status=history.STATUS_SUCCESS)

except GException as e:
print(e, file=sys.stderr)
self.UpdateHistory(status=history.STATUS_FAILED)

return

Expand Down Expand Up @@ -636,6 +659,8 @@ def RunCmd(
):
event = gIgnoredCmdRun(cmd=command)
wx.PostEvent(self, event)

self.UpdateHistory(status=history.STATUS_FAILED)
return

skipInterface = True
Expand All @@ -649,6 +674,7 @@ def RunCmd(
skipInterface = False
break
except OSError:
self.UpdateHistory(status=history.STATUS_FAILED)
pass

if len(command) == 1 and not skipInterface:
Expand All @@ -662,6 +688,7 @@ def RunCmd(
if task:
# process GRASS command without argument
GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
self.UpdateHistory(status=history.STATUS_SUCCESS)
else:
self.cmdThread.RunCmd(
command,
Expand Down Expand Up @@ -736,15 +763,15 @@ def OnCmdDone(self, event):
)
)
msg = _("Command aborted")
status = "aborted"
status = history.STATUS_ABORTED
elif event.returncode != 0:
msg = _("Command ended with non-zero return code {returncode}").format(
returncode=event.returncode
)
status = "failed"
status = history.STATUS_FAILED
else:
msg = _("Command finished")
status = "success"
status = history.STATUS_SUCCESS

cmd_info = {"runtime": int(ctime), "status": status}

Expand Down
Loading
Loading