From aba7cbbf6afdef959a6903facde878aed70efcbc Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 29 Apr 2024 15:42:28 +0200 Subject: [PATCH 01/10] new images for history browser nodes --- gui/icons/grass/check.png | Bin 876 -> 989 bytes gui/icons/grass/check.svg | 41 +++++++++++++++++++ gui/icons/grass/circle.png | Bin 0 -> 650 bytes gui/icons/grass/circle.svg | 43 +++++++++++++++++++ gui/icons/grass/cross.png | Bin 0 -> 876 bytes gui/icons/grass/cross.svg | 52 +++++++++++++++++++++++ gui/icons/grass/exclamation-mark.png | Bin 0 -> 718 bytes gui/icons/grass/exclamation-mark.svg | 45 ++++++++++++++++++++ gui/icons/grass/question-mark.png | Bin 0 -> 658 bytes gui/icons/grass/question-mark.svg | 40 ++++++++++++++++++ gui/icons/grass/time-period.png | Bin 0 -> 1110 bytes gui/icons/grass/time-period.svg | 39 ++++++++++++++++++ gui/wxpython/history/tree.py | 59 +++++++++++++++++++++++---- python/grass/grassdb/history.py | 8 ++++ 14 files changed, 319 insertions(+), 8 deletions(-) create mode 100644 gui/icons/grass/check.svg create mode 100644 gui/icons/grass/circle.png create mode 100644 gui/icons/grass/circle.svg create mode 100644 gui/icons/grass/cross.png create mode 100644 gui/icons/grass/cross.svg create mode 100644 gui/icons/grass/exclamation-mark.png create mode 100644 gui/icons/grass/exclamation-mark.svg create mode 100644 gui/icons/grass/question-mark.png create mode 100644 gui/icons/grass/question-mark.svg create mode 100644 gui/icons/grass/time-period.png create mode 100644 gui/icons/grass/time-period.svg diff --git a/gui/icons/grass/check.png b/gui/icons/grass/check.png index a0f89157af01134a9934b1a622e0ef423484e9ea..246318fe4ed00608aa8bc044d77f6529b20efc18 100644 GIT binary patch delta 943 zcmV;g15o_z2Hgjc865@y007{3J@^0s010qNS#tmY4#NNd4#NS*Z>VIEMJIm)YDq*v zR7i=nlxs|zWfaH%@0DJl1j?-_6|%9nrDY3~=`@4Ieb}=20SVEKs4-r$7!zZh$xIky zzGWKY<%4mVNn_#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Nz z7$PCL_25e@rbLFehvr63TPA2s+_+ke=hUZ&$*LlA|L?rA#PjU)UB900TUu|jIr`ST zX_>EH2%Duu&Qbz8hR!^S0+bR9d%S?|OHI#S4yepxe~UYLG$Ma0y3rz2UHyu3N-;IYY54i+^m`X_L5=g-RC>x`?lRP6nd SkN5)p!r + + + + + diff --git a/gui/icons/grass/circle.png b/gui/icons/grass/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..64c2409dcdcd2c8e27dc49e2851276a1d494f1da GIT binary patch literal 650 zcmV;50(Jd~P)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10vAa{ zK~zYI?Ul`L(?Ar3&x~hqOkz{gDkNz^R8-2kMDPTCfXkzI*S?onb_TNs3R@9e~JM^xX11 z=jSe|Jk(~8S!-+3<-RkmCfajLy znV@=R<|#54yeUXp9}3`%U6B>v8OIy|xT(QpQuH5|%9#Kr>5^f`a$Eoaa6958jaoJU z>=ZMOHq~5^q=ctd|M!rIc9ZC6gPka@h$oFq07c@ZZskUr&VQv3OgJ*Poe2mHwHY@p z1wGa!La${K1K!};r!W&Rv)b$+!F~0`@kcc$%@BT=YUx0%4cgP!^g_OIFaB + + + + + diff --git a/gui/icons/grass/cross.png b/gui/icons/grass/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..6b9ab8c918b1b00dea7a1029262fd626477df45f GIT binary patch literal 876 zcmV-y1C#uTP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10{KZq zK~zYIwUo_oOkoshMAW7SO^=5P_gg__zy(161u>sSX--| z1r`#Ks91=PYJ9a8f`x>rk5ZlK++ps_vFP0Ex^t%)3ukxV`@YZbyyrc?BdW^(48#9% zK_oLQa<3q=`(Hr?k^b`{cg~3_94enw_dLX_LVyj@S0S|{nQUG!aQWiX31FP3T%su!W7z5jZ z{R67ETET%!y%1mQTYm{Z-@_XldW;C9f#pkmaDb&iZvG}$!^+jjyb0bo8&l{qA!(dY zeeJ;Zr%?O^5Q`z5ot{V@;=yvcWyy!Yr$8rQ7U&yP{UC0eo)PIb;qFF}#ENtpDiyR; z0$>Js1a=J$MWCYrw~`_7=P;|V?U?EWfcSlIS|k^R+ub6GWtj}vwkOhfld=FkA(?*! zeF3u$^bM#^y6X}&T9Zh*jLyvgP-MRC7PScv6$qAVWj0H_RDyE3XsQmhB|sjm2wZ6;()7p$k^Tsb^hTrc zWI9cKdK#)#06v2nAejKfZD9uv1jou>H)v!Y3jYZD6lTYv^f@5V7%OoTt_8=6C*YMO z1U}X1bA@d+*x`+pfJoRB7FGQN2P1L;dTw)iK;Rr z5?cf}Q_$ND)~7Zc>W05uSzsLOA8>au>^q`b_1bhuq{D(+3CI_r(kk + + + + + + + + + diff --git a/gui/icons/grass/exclamation-mark.png b/gui/icons/grass/exclamation-mark.png new file mode 100644 index 0000000000000000000000000000000000000000..789808c642e012c803738ac1417ea6935dd6e1e5 GIT binary patch literal 718 zcmV;<0x|uGP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10$WK$ zK~zYIt(Ct|6hRcnzi(!L9D&1NV}XT<9dHRmiLJ)U%HF@g#L7aHSYV>ThKTYnm{?q4 z0nrAQ;av;x&NY#?bd4RVp8|{FDW_(c62O9rdKEZNqObB-+&$fWTOdAoBQ6v%O^$ zT^;{WeY|hLwZ6WNHigyh$_=G8rf5-<9|VlJg=oU{ZR^UDyW=C^dLHAKFr@}>=vm*m^)@l_iDp;!*TR-c?FpOLkTRWY{oB2QZ zH?9v1oKnVI5+V)Y^@F9Q>X8Bt8hbv+n=v|gW`saDA;JLN8J?dX%j3({!M(x3^BT!i zXYoge0BAH$Y%rXQx98^G?d8oiWMc03{FY0~LMaQ^jTABW=kew`A|iSdM{UM)0$%_m zNkK?tHkUW=kVns*y#ls(6_FK7w}uxMp62oW1!s*U@aEka3IG5A07*qoM6N<$f{`Fc A$N&HU literal 0 HcmV?d00001 diff --git a/gui/icons/grass/exclamation-mark.svg b/gui/icons/grass/exclamation-mark.svg new file mode 100644 index 00000000000..20bd49e5cc8 --- /dev/null +++ b/gui/icons/grass/exclamation-mark.svg @@ -0,0 +1,45 @@ + + + + + + + diff --git a/gui/icons/grass/question-mark.png b/gui/icons/grass/question-mark.png new file mode 100644 index 0000000000000000000000000000000000000000..860c8d87bf3b12ac15abdf38427a6c13d596e87d GIT binary patch literal 658 zcmV;D0&V??P)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10v}04 zK~zYI)s?@C6G0rs-T z+&_@RB7&f;r3$B@XrXZ650EQFQAjY5%-2G5CgX0hcb%`=`F{7k&wOW>U5W_O6vuI~ z*XykUxBy@oKmcGKz&8LNNj@D8hn-fd^;lAZm}#wxWg&UQ81o@% zf|Gs-$xc!@02pI70etc;0FI9q%4;6j#H&U! zarXcaMbSKfqY16usU`sRdVL$f_KY0^0LtZZE(n4R01IC0N1;%7nFz?LD2f(KrBWNf zIlo8pdaYLL?i&z>;j&Wd0m;J&?Hk6J`UG&=x5$^)`izJ?0#KX?A-@6$jWPFpPi8 + + + + + diff --git a/gui/icons/grass/time-period.png b/gui/icons/grass/time-period.png new file mode 100644 index 0000000000000000000000000000000000000000..17963c827d53c2ba28d7d25517e5854dca61574d GIT binary patch literal 1110 zcmV-c1gZOpP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H11LH|V zK~zYIrIt@?wTKifZko21 zN@H6sxUp^;X+hg2Br_z>2zj`v8^Ly=E)-N~5DIE-tu+$S=H0w^T)eq>`FN39G-N3U*4o=eWS6S$ z2kuxlf;#?G)pteYP3PS2D>^X7JT4-WA=(sG;9`he!`ddGDPwaPc*Z$*epv^`m_8AC zA7}~G_rNira2&_d!Catxt0L=ioTy6;H08rJ#&bbeY#p0t;6dh94Gv51g0Pp>28eohW2F`o$ zPsMS(Nmcg%ogy*>?2ihC!dl>!U_aZ|*7gQK6h#Mt9uYZftt~bRXE58;)N}=4et!NS za47`3+gjTi<@5P1!0JFA9T^!(!p4)-PfrtY)>^xHDRuAt>GARLF9FKs@&ffk0kB$C zw?x3!KrD*Lbf&f+sp_sUZ2?MseSMGoOC~8wKrM{7iZSK_@EGv5bMB!=YisRmz~L~x z3iJbMLsfupoO9KNJr{xdfeR6ESKxmNi!U2v`ZAdu0p1DI^}spc^YDD7s_%t;+pM)O zWVL_|*&`PLsOmM~dNv~O{j0#4rRpIf?O}LbM1D=_^xaIo#qR;Sf|zdB#UmfQgXlOlHf5@cvPZF{8kOa_psM?NdU{#_ipAo?#+dCZ3C3}}!x(b_z*>77 zFcg;lN|K};jgF4~CL+fJxpB>!HHQGADC!WAO)EK2)o+0>!uSYqcNiZpl}dA>stgPa ztV@#QJL<EBr*Ip8l6JdHKNs4q8{99$L0@!J{kimIAYsWb--7ml@d8*mE91?rNByp<%$)YR0})vR!D zZ}0kCF4wE7`=}ptsCV|Db8alPTk6VuQbas(XNIm(zcSMf?E)SkG-tq7RV{k&Kh5eb zdFc-f46LhEDnlZ&8(4LV!Of_s>WRh0#n;oatmq(xwYDw%vTPNR`$FV|OlE-@V8%Ij ceL0Q40oks$=K{mrxc~qF07*qoM6N<$g0#*FzyJUM literal 0 HcmV?d00001 diff --git a/gui/icons/grass/time-period.svg b/gui/icons/grass/time-period.svg new file mode 100644 index 00000000000..48efd0d0879 --- /dev/null +++ b/gui/icons/grass/time-period.svg @@ -0,0 +1,39 @@ + + + + + + diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index caaeb8bda86..67c41f455cc 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -36,11 +36,17 @@ from gui_core.treeview import CTreeView from gui_core.wrap import Menu +from icons.icon import MetaIcon + from grass.pydispatch.signal import Signal from grass.grassdb import history +# global variables for node types +TIME_PERIOD = _("time_period") +COMMAND = _("command") + # global variable for purposes of sorting "No time info" node OLD_DATE = datetime.datetime(1950, 1, 1).date() @@ -108,6 +114,17 @@ def __init__( self._resetSelectVariables() + self._iconTypes = [ + TIME_PERIOD, + history.status_aborted, + history.status_failed, + history.status_running, + history.status_success, + history.status_unknown, + ] + + self._initImages() + self._initHistoryModel() self.showNotification = Signal("HistoryBrowserTree.showNotification") @@ -144,6 +161,21 @@ def _resetSelectVariables(self): self.selected_day = [] self.selected_command = [] + def _initImages(self): + bmpsize = (16, 16) + icons = { + TIME_PERIOD: MetaIcon(img="time-period").GetBitmap(bmpsize), + history.status_aborted: MetaIcon(img="exclamation-mark").GetBitmap(bmpsize), + history.status_failed: MetaIcon(img="cross").GetBitmap(bmpsize), + history.status_running: MetaIcon(img="circle").GetBitmap(bmpsize), + history.status_success: MetaIcon(img="check").GetBitmap(bmpsize), + history.status_unknown: MetaIcon(img="question-mark").GetBitmap(bmpsize), + } + il = wx.ImageList(bmpsize[0], bmpsize[1], mask=False) + for each in self._iconTypes: + il.Add(icons[each]) + self.AssignImageList(il) + def _confirmDialog(self, question, title): """Confirm dialog""" dlg = wx.MessageDialog(self, question, title, wx.YES_NO) @@ -200,14 +232,14 @@ def _initHistoryModel(self): day = self._model.SearchNodes( parent=self._model.root, day=self._timestampToDay(timestamp), - type="day", + type=TIME_PERIOD, ) else: # Find day node prepared for entries without any command info day = self._model.SearchNodes( parent=self._model.root, day=self._timestampToDay(), - type="day", + type=TIME_PERIOD, ) if day: @@ -218,13 +250,13 @@ def _initHistoryModel(self): # Prepare it for entries without command info day = self._model.AppendNode( parent=self._model.root, - data=dict(type="day", day=self._timestampToDay()), + data=dict(type=TIME_PERIOD, day=self._timestampToDay()), ) else: day = self._model.AppendNode( parent=self._model.root, data=dict( - type="day", + type=TIME_PERIOD, day=self._timestampToDay( entry["command_info"]["timestamp"] ), @@ -243,7 +275,7 @@ def _initHistoryModel(self): self._model.AppendNode( parent=day, data=dict( - type="command", + type=COMMAND, name=entry["command"].strip(), timestamp=timestamp if timestamp else None, status=status, @@ -306,10 +338,10 @@ def DefineItems(self, selected): self._resetSelectVariables() for item in selected: type = item.data["type"] - if type == "command": + if type == COMMAND: self.selected_command.append(item) self.selected_day.append(item.parent) - elif type == "day": + elif type == TIME_PERIOD: self.selected_command.append(None) self.selected_day.append(item) @@ -323,7 +355,7 @@ def Filter(self, text): except re.error: return self._model = self._orig_model.Filtered( - method="filtering", name=compiled, type="command" + method="filtering", name=compiled, type=COMMAND ) else: self._model = self._orig_model @@ -433,6 +465,17 @@ def Run(self, node=None): showTraceback=False, ) + def OnGetItemImage(self, index, which=wx.TreeItemIcon_Normal, column=0): + """Overridden method to return image for each item.""" + node = self._model.GetNodeByIndex(index) + try: + if node.data["type"] == TIME_PERIOD: + return self._iconTypes.index(node.data["type"]) + elif node.data["type"] == COMMAND: + return self._iconTypes.index(node.data["status"]) + except ValueError: + return 0 + def OnRemoveCmd(self, event): """Remove cmd from the history file""" self.DefineItems(self.GetSelected()) diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index b1ddb52c19a..60c6b32a6e6 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -18,6 +18,14 @@ from grass.script.utils import parse_key_val +# global status variables +status_aborted = _("aborted") +status_failed = _("failed") +status_running = _("running") +status_success = _("success") +status_unknown = _("unknown") + + def get_current_mapset_gui_history_path(): """Return path to the current mapset history file. This function does not ensure that the file exists. From df0587966f86bc0480fb560daa51cffa67e05e0f Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 30 Apr 2024 10:51:42 +0200 Subject: [PATCH 02/10] variable fix --- gui/wxpython/history/tree.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index 67c41f455cc..e646039fb67 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -376,13 +376,13 @@ def InsertCommand(self, entry): # Check if today time period node exists or create it today = self._timestampToDay(entry["command_info"]["timestamp"]) today_nodes = self._model.SearchNodes( - parent=self._model.root, day=today, type="day" + parent=self._model.root, day=today, type=TIME_PERIOD ) if not today_nodes: today_node = self._model.AppendNode( parent=self._model.root, data=dict( - type="day", + type=TIME_PERIOD, day=today, ), ) @@ -393,7 +393,7 @@ def InsertCommand(self, entry): command_node = self._model.AppendNode( parent=today_node, data=dict( - type="command", + type=COMMAND, name=entry["command"].strip(), timestamp=entry["command_info"]["timestamp"], status=entry["command_info"].get("status", "in process"), @@ -418,9 +418,9 @@ def UpdateCommand(self, entry): # Get node of last command today = self._timestampToDay(entry["command_info"]["timestamp"]) today_node = self._model.SearchNodes( - parent=self._model.root, day=today, type="day" + parent=self._model.root, day=today, type=TIME_PERIOD )[0] - command_nodes = self._model.SearchNodes(parent=today_node, type="command") + command_nodes = self._model.SearchNodes(parent=today_node, type=COMMAND) last_node = command_nodes[-1] # Remove last node From 755931ff8c4478d9dc425b337efd0f8a0852e9d9 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 2 May 2024 11:11:16 +0200 Subject: [PATCH 03/10] check.png preserved, new icon success.png added, color of circle edited and circle centered --- gui/icons/grass/check.png | Bin 989 -> 876 bytes gui/icons/grass/circle.png | Bin 650 -> 518 bytes gui/icons/grass/circle.svg | 16 ++++++++-------- gui/icons/grass/success.png | Bin 0 -> 989 bytes gui/icons/grass/{check.svg => success.svg} | 0 gui/wxpython/history/tree.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 gui/icons/grass/success.png rename gui/icons/grass/{check.svg => success.svg} (100%) diff --git a/gui/icons/grass/check.png b/gui/icons/grass/check.png index 246318fe4ed00608aa8bc044d77f6529b20efc18..a0f89157af01134a9934b1a622e0ef423484e9ea 100644 GIT binary patch literal 876 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAF&8^|hH!9j+9gP2NC6c|fD}2F zmSp4?F$Co&r52Sa1Xm?jr4}USrDn&6ZR7x|Q3t7UNi9w;$}A|!%+F)UC@Cqh($_Bn ztJf=rtJf>YnGorb05jIPC^ZqJULhniH zM&yLZ(5}#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lE+h?`sLKMErjN08n}6^DJJO`ij$pFT>5P11l9@60jC_7l7UpA-@l} Rpa1{>07(Z$PDHLkV1fZ9&*1<7 diff --git a/gui/icons/grass/circle.png b/gui/icons/grass/circle.png index 64c2409dcdcd2c8e27dc49e2851276a1d494f1da..c6ad944f3b1ca323d1745cd431f06e515290f25b 100644 GIT binary patch delta 435 zcmV;k0Zjgi1%?EWU4H?SNkl(FlU9@(;4CwAm6d>Vj_D$ao1NjWW2)dSPgB>bH=dC?sz{7fGOp<&O zn!O(P6@LS9k4LWLE;JKgy1f3F_B5HJvaF`;^rzwg03<+JJA)Bj@l1OiB0&z5j`4=k zkVB#*Zww$M1AniEnnFk-#(?jH-(`Axpt0xM;Rn#zGX@Cb5qH9DD$X}y7Qq8!06pQV zt|ywn21YOfpATB7Rn-^}D>ho>Qd!qh?LY`4xTmQ$JYp%naMAWE34SWJGjr0<>y))K zH1vLL`6kSKmaxE~Qf$%M_tOXj007)?OpahgS42skNGu`(0K(W4#sk!<>NmMD;HUBT dKb*f0cm}76tub-;q4xj)002ovPDHLkV1jxQ#;E`R delta 568 zcmV-80>}M^1d0WaU4H@>NklXK+knQ_?CVX+cy}%DP1G1bu=+ z_s|7w%MytlNPPkRgbc61s;Xee64v8OIy|xT(QpQuH5| z%9#Kr>5^f`a$Eoaa6958jaoJU>=ZMOHq~5^q=ctd|M!rIc9ZC6gPka@h$oFq07c@Z zZskUr&VQv3OgJ*Poe2mHwHY@p1wGa!La${K1K!};r++XLFtgh1Ai;h0#qmcqC(RIk zm}==jtPR@J*YrZZaWDREZN+*;pCH1xNDtKRPC(1|- z>a|Sr-)#$_C6fA@0zlWTE<@5flSz@=5$A$rqPWtY$r!_H9f-B8%!dMg z>+s3>iZSNV0*IX^&Ku4FwsC7G7-l>&;D0soFY_2MRKEaxi{56Cc%laY0000 + style="fill:#f7d200;fill-opacity:1;stroke:#f28f1a;stroke-width:0.724246;stroke-miterlimit:0.4;stroke-dasharray:none;stroke-opacity:1" + r="6.637877" /> diff --git a/gui/icons/grass/success.png b/gui/icons/grass/success.png new file mode 100644 index 0000000000000000000000000000000000000000..246318fe4ed00608aa8bc044d77f6529b20efc18 GIT binary patch literal 989 zcmV<310wv1P)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H118PY` zK~zYIwUld2n`IQo|L>JvpajaTC>64?x20tZlj$^r#eLYa_yGygji@nRvKSL%oXJcW zW4>h?R#@rV(f87`4@=23AeX^O zo-a?%`Tx#&&Up?)L|9K_*HwKz09!gfv924SD(GuWnG++`f%nVS9N_BwU^6j#$4tc~ zhbE>jxB_x105EIOWT{gwUF$UsIaPuKp;jJsN(D!38}a3!;H_W#j84fby9DuBF^R$2!u34Wxu|VlzI;Lfr!cY z@vC_jcR(&D!8je+anhn@#{d8&Lr*Xw(M~nz)~h6>FS)eC0tH9k(|-rPR%==UZ7Fi$z* z7;I9Yns!}%{%CZe7#08|uYO$3o!oPM_X*S3<2`xAYUe$H_PYBWJ>Bik8NB*>r0%4Z zSOa1rAI{%iOftIAG}7Gi=VDdE)pe}d)g|kKl6!9&2xOhuKvM4!r79pd5D`29-!`fD zh>|r^Odt?{$4Zr_4ke_Z{PI%M#!Y$ahwUZlVq3)Po_*+wm=@=tWluvXz9!^Ey$xT4 z&g%xRpBUR7v?UAwW>`ajbKo_FOJ#pH+VtM1i)Nm&49VRkzb$>!qL^Z(^OcBkJ5}}_ zO4={)RPW6?OJ%>jq-^SG{d&3o_@iOY z7OB3NJyo{r;(-I&lG$T{ZR+i6-=_0=|K#TWoaxF7T;|?>rCu)>-g!eyTen_&_TAgd z5nm7h0IuM%3b5+Ww=0H9CTe~VZBY+71{-67mQ@qle>k#S@kIdu;0?<8I;Z!~<&Aqx zu~LoIO-~N*YYDGJ{C@!eP Date: Fri, 3 May 2024 17:01:25 +0200 Subject: [PATCH 04/10] browser updates in gconsole to avoid Running state in special cases --- gui/wxpython/core/gconsole.py | 35 +++++++++++++++++++++++++++++---- gui/wxpython/history/tree.py | 24 +++++++++++----------- python/grass/grassdb/history.py | 11 ++++++----- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index cb26b57f0f5..41fa38a50f5 100644 --- a/gui/wxpython/core/gconsole.py +++ b/gui/wxpython/core/gconsole.py @@ -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, @@ -529,14 +544,16 @@ def RunCmd( ): event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) - return + self.UpdateHistory(status=history.STATUS_FAILED) + 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 @@ -560,6 +577,7 @@ def RunCmd( ) % {"cmd": " ".join(command), "opt": p.get("name", "")}, ) + self.UpdateHistory(status=history.STATUS_FAILED) return if len(command) == 1: @@ -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: @@ -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 @@ -636,6 +659,8 @@ def RunCmd( ): event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) + + self.UpdateHistory(status=history.STATUS_FAILED) return skipInterface = True @@ -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: @@ -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, @@ -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} diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index db0424ca19b..617caa46889 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -116,11 +116,11 @@ def __init__( self._iconTypes = [ TIME_PERIOD, - history.status_aborted, - history.status_failed, - history.status_running, - history.status_success, - history.status_unknown, + history.STATUS_ABORTED, + history.STATUS_FAILED, + history.STATUS_RUNNING, + history.STATUS_SUCCESS, + history.STATUS_UNKNOWN, ] self._initImages() @@ -165,11 +165,11 @@ def _initImages(self): bmpsize = (16, 16) icons = { TIME_PERIOD: MetaIcon(img="time-period").GetBitmap(bmpsize), - history.status_aborted: MetaIcon(img="exclamation-mark").GetBitmap(bmpsize), - history.status_failed: MetaIcon(img="cross").GetBitmap(bmpsize), - history.status_running: MetaIcon(img="circle").GetBitmap(bmpsize), - history.status_success: MetaIcon(img="success").GetBitmap(bmpsize), - history.status_unknown: MetaIcon(img="question-mark").GetBitmap(bmpsize), + history.STATUS_ABORTED: MetaIcon(img="exclamation-mark").GetBitmap(bmpsize), + history.STATUS_FAILED: MetaIcon(img="cross").GetBitmap(bmpsize), + history.STATUS_RUNNING: MetaIcon(img="circle").GetBitmap(bmpsize), + history.STATUS_SUCCESS: MetaIcon(img="success").GetBitmap(bmpsize), + history.STATUS_UNKNOWN: MetaIcon(img="question-mark").GetBitmap(bmpsize), } il = wx.ImageList(bmpsize[0], bmpsize[1], mask=False) for each in self._iconTypes: @@ -268,7 +268,7 @@ def _initHistoryModel(self): entry["command_info"].get("status") if entry.get("command_info") and entry["command_info"].get("status") is not None - else "unknown" + else history.STATUS_UNKNOWN ) # Add command to time period node @@ -396,7 +396,7 @@ def InsertCommand(self, entry): type=COMMAND, name=entry["command"].strip(), timestamp=entry["command_info"]["timestamp"], - status=entry["command_info"].get("status", "in process"), + status=entry["command_info"].get("status", history.STATUS_UNKNOWN), ), ) diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index 60c6b32a6e6..0c8076ce167 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -19,11 +19,11 @@ # global status variables -status_aborted = _("aborted") -status_failed = _("failed") -status_running = _("running") -status_success = _("success") -status_unknown = _("unknown") +STATUS_ABORTED = _("aborted") +STATUS_FAILED = _("failed") +STATUS_RUNNING = _("running") +STATUS_SUCCESS = _("success") +STATUS_UNKNOWN = _("unknown") def get_current_mapset_gui_history_path(): @@ -286,6 +286,7 @@ def get_initial_command_info(env_run): "mask2d": mask2d_present, "mask3d": mask3d_present, "region": region_settings, + "status": STATUS_RUNNING, } return cmd_info From 3c7979d823abce6d2c37d085bb9cab4b644546f6 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 6 May 2024 07:57:26 +0200 Subject: [PATCH 05/10] translatable names ale not needed here --- gui/wxpython/history/tree.py | 4 ++-- python/grass/grassdb/history.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index 617caa46889..2971c666555 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -44,8 +44,8 @@ # global variables for node types -TIME_PERIOD = _("time_period") -COMMAND = _("command") +TIME_PERIOD = "time_period" +COMMAND = "command" # global variable for purposes of sorting "No time info" node OLD_DATE = datetime.datetime(1950, 1, 1).date() diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index 0c8076ce167..0e87d6e647b 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -19,11 +19,11 @@ # global status variables -STATUS_ABORTED = _("aborted") -STATUS_FAILED = _("failed") -STATUS_RUNNING = _("running") -STATUS_SUCCESS = _("success") -STATUS_UNKNOWN = _("unknown") +STATUS_ABORTED = "aborted" +STATUS_FAILED = "failed" +STATUS_RUNNING = "running" +STATUS_SUCCESS = "success" +STATUS_UNKNOWN = "unknown" def get_current_mapset_gui_history_path(): From 124e398c09a344743a02e987d1bf118eace9006a Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 6 May 2024 14:54:56 +0200 Subject: [PATCH 06/10] setting the status in RunSpecialCmd --- gui/wxpython/core/gconsole.py | 7 ------- gui/wxpython/main_window/frame.py | 30 +++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index 41fa38a50f5..13f8e752ca7 100644 --- a/gui/wxpython/core/gconsole.py +++ b/gui/wxpython/core/gconsole.py @@ -545,7 +545,6 @@ def RunCmd( event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) - self.UpdateHistory(status=history.STATUS_FAILED) return else: # other GRASS commands (r|v|g|...) @@ -553,7 +552,6 @@ def RunCmd( 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 @@ -577,7 +575,6 @@ def RunCmd( ) % {"cmd": " ".join(command), "opt": p.get("name", "")}, ) - self.UpdateHistory(status=history.STATUS_FAILED) return if len(command) == 1: @@ -598,7 +595,6 @@ 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) @@ -617,7 +613,6 @@ def RunCmd( except GException as e: print(e, file=sys.stderr) - self.UpdateHistory(status=history.STATUS_FAILED) return @@ -660,7 +655,6 @@ def RunCmd( event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) - self.UpdateHistory(status=history.STATUS_FAILED) return skipInterface = True @@ -674,7 +668,6 @@ def RunCmd( skipInterface = False break except OSError: - self.UpdateHistory(status=history.STATUS_FAILED) pass if len(command) == 1 and not skipInterface: diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index 2494077e7e9..907f9ef23f4 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -89,6 +89,7 @@ create_location_interactively, ) from grass.grassdb.checks import is_first_time_user +from grass.grassdb import history class SingleWindowAuiManager(aui.AuiManager): @@ -1082,10 +1083,26 @@ def FocusPage(self, page_text): if notebook.GetPageText(i) == page_text: notebook.SetSelection(i) + 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 RunSpecialCmd(self, command): """Run command from command line, check for GUI wrappers""" + result = 0 if re.compile(r"^d\..*").search(command[0]): - self.RunDisplayCmd(command) + result = self.RunDisplayCmd(command) elif re.compile(r"r[3]?\.mapcalc").search(command[0]): self.OnMapCalculator(event=None, cmd=command) elif command[0] == "i.group": @@ -1105,15 +1122,21 @@ def RunSpecialCmd(self, command): elif command[0] == "cd": self.OnChangeCWD(event=None, cmd=command) else: + result = 1 raise ValueError( "Layer Manager special command (%s)" " not supported." % " ".join(command) ) + if result == 0: + self.UpdateHistory(status=history.STATUS_SUCCESS) + else: + self.UpdateHistory(status=history.STATUS_FAILED) def RunDisplayCmd(self, command): """Handles display commands. :param command: command in a list + :return int: 1 if failed, 0 if succcess """ if not self.currentPage: self.NewDisplay(show=True) @@ -1121,7 +1144,7 @@ def RunDisplayCmd(self, command): if command[0] == "d.erase": # rest of d.erase is ignored self.GetLayerTree().DeleteAllLayers() - return + return 1 try: # display GRASS commands layertype = command2ltype[command[0]] @@ -1134,7 +1157,7 @@ def RunDisplayCmd(self, command): ) % command[0], ) - return + return 1 if layertype == "barscale": if len(command) > 1: @@ -1188,6 +1211,7 @@ def RunDisplayCmd(self, command): lname=lname, lcmd=command, ) + return 0 def GetAuiManager(self): """Get aui manager From 348149ed67897f5eb33a4a5bc4f8e23b35159726 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 7 May 2024 15:06:18 +0200 Subject: [PATCH 07/10] refactoring of UpdateHistory --- gui/wxpython/core/gconsole.py | 25 ++++++++++--------------- gui/wxpython/lmgr/frame.py | 14 +++++++++++--- gui/wxpython/main_window/frame.py | 19 ++----------------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index 13f8e752ca7..c0bb5bfcdda 100644 --- a/gui/wxpython/core/gconsole.py +++ b/gui/wxpython/core/gconsole.py @@ -446,9 +446,15 @@ 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} + def UpdateHistory(self, status, runtime=None): + """Update command history. + :param enum status enum: status of command + :param int runtime: duration of command run + """ + if runtime: + cmd_info = {"runtime": runtime, "status": status} + else: + cmd_info = {"status": status} try: history_path = history.get_current_mapset_gui_history_path() @@ -766,19 +772,8 @@ def OnCmdDone(self, event): msg = _("Command finished") status = history.STATUS_SUCCESS - cmd_info = {"runtime": int(ctime), "status": status} - # update command history log by status and runtime duration - 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)) + self.UpdateHistory(status=status, runtime=int(ctime)) self.WriteCmdLog( "(%s) %s (%s)" % (str(time.ctime()), msg, stime), diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index 2f863103424..dd3e196b5ab 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -83,6 +83,7 @@ create_location_interactively, ) from grass.grassdb.checks import is_first_time_user +from grass.grassdb import history class GMFrame(wx.Frame): @@ -947,8 +948,9 @@ def _switchPage(self, notification): def RunSpecialCmd(self, command): """Run command from command line, check for GUI wrappers""" + result = 0 if re.compile(r"^d\..*").search(command[0]): - self.RunDisplayCmd(command) + result = self.RunDisplayCmd(command) elif re.compile(r"r[3]?\.mapcalc").search(command[0]): self.OnMapCalculator(event=None, cmd=command) elif command[0] == "i.group": @@ -968,10 +970,15 @@ def RunSpecialCmd(self, command): elif command[0] == "cd": self.OnChangeCWD(event=None, cmd=command) else: + result = 1 raise ValueError( "Layer Manager special command (%s)" " not supported." % " ".join(command) ) + if result == 0: + self._gconsole.UpdateHistory(status=history.STATUS_SUCCESS) + else: + self._gconsole.UpdateHistory(status=history.STATUS_FAILED) def RunDisplayCmd(self, command): """Handles display commands. @@ -984,7 +991,7 @@ def RunDisplayCmd(self, command): if command[0] == "d.erase": # rest of d.erase is ignored self.GetLayerTree().DeleteAllLayers() - return + return 1 try: # display GRASS commands layertype = command2ltype[command[0]] @@ -997,7 +1004,7 @@ def RunDisplayCmd(self, command): ) % command[0], ) - return + return 1 if layertype == "barscale": if len(command) > 1: @@ -1051,6 +1058,7 @@ def RunDisplayCmd(self, command): lname=lname, lcmd=command, ) + return 0 def GetLayerNotebook(self): """Get Layers Notebook""" diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index 907f9ef23f4..a69f40bebed 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -1083,21 +1083,6 @@ def FocusPage(self, page_text): if notebook.GetPageText(i) == page_text: notebook.SetSelection(i) - 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 RunSpecialCmd(self, command): """Run command from command line, check for GUI wrappers""" result = 0 @@ -1128,9 +1113,9 @@ def RunSpecialCmd(self, command): " not supported." % " ".join(command) ) if result == 0: - self.UpdateHistory(status=history.STATUS_SUCCESS) + self._gconsole.UpdateHistory(status=history.STATUS_SUCCESS) else: - self.UpdateHistory(status=history.STATUS_FAILED) + self._gconsole.UpdateHistory(status=history.STATUS_FAILED) def RunDisplayCmd(self, command): """Handles display commands. From 07376554092267c6e3115c1e4c4c7bb0fe143df9 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 7 May 2024 16:02:34 +0200 Subject: [PATCH 08/10] png size is 16x16 --- gui/icons/grass/circle.png | Bin 518 -> 399 bytes gui/icons/grass/cross.png | Bin 876 -> 646 bytes gui/icons/grass/exclamation-mark.png | Bin 718 -> 492 bytes gui/icons/grass/question-mark.png | Bin 658 -> 497 bytes gui/icons/grass/success.png | Bin 989 -> 595 bytes gui/icons/grass/time-period.png | Bin 1110 -> 733 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/gui/icons/grass/circle.png b/gui/icons/grass/circle.png index c6ad944f3b1ca323d1745cd431f06e515290f25b..cec9e99476841d78fe1f9736565f2133cf67b4cb 100644 GIT binary patch delta 370 zcmV-&0ge8K1djtYiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVE_OC32;bR za{vGd*8l(s*8#C^7q^i%D1RJDL_t(Ijm49{PQx$|#y{I>8WP1)2ZpL*q7z{$AReb| znM+@UcFo4?0A*>q(Fs*WVn9hDe;UQdRH=z#2~;G$%_raQzB`{85#bQ=gR=huU^E5S zLC!4>#H+>N2A6}EQGVFxTn{$oZ*K`-F%)k}JnD^r|UBA2^dmEXLDzVDJQiGlCCNZmI z!c>=9z)z%rN`WdM07*qoM6N<$g5U?8@c;k- delta 490 zcmVqw8GESl5L~Rrij7uKKL%}4cYkN1z#(@{P1$Ko zIt2KV5CHCkS=SRya;O|#w06G?=G?}BatfuVrr{VwrBtTg^gArZvOnV(7K@O9S z@rKcmL!u;a3?L-~uYZP`LP#RUfbWFgWqNy{vFF?22hi9v1_jaZCz`+pMlb@O4_c^I)ff;fHd^FTS=UnSKnNqar>QnPVky3G(e^3{ek!&zbJEZ2 zl(jQ7^nPvmCd_=6u)v{GY|+~H(+C6r0Nig(j$lMrL`j}VA}ay_!q^kW1JtVOH@Pw3 gr}6hcoWBov2B(UxF>&{y_W%F@07*qoM6N<$g36iE`v3p{ diff --git a/gui/icons/grass/cross.png b/gui/icons/grass/cross.png index 6b9ab8c918b1b00dea7a1029262fd626477df45f..d5190202eedb5208d7e871f79a3b4861409b706f 100644 GIT binary patch delta 619 zcmV-x0+jvi28IPTiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVE_OC32;bR za{vGd*8l(s*8#C^7q^i%D1Q@4L_t(IjeV27Pg7wO#($^1y@hglt3(+{sO952nD~*H z6x@tDsmvHB@edGpO~k0tq^7isqr?Gafy8Kxg0ZXV=4!M}!G)>F75V7J!_eMxYs5Es zhx73~=XuY052}i)G6fw^;YeT~bhFSq1$JOZ0H#Gc4?!^orAH#iIDg<|McfW3C1L5l zhz%e)=mb8UfwNr@D?w!qF5XqGgu#zRjyte40;vtCe}U3ZxD@f>W*?mFfmj^Kz<_~| zVI^4+*T9ESNX3C3h#iGf4vdR}UnId5-71C+SRC>jyDOH!K=W+E!7*M zsvshHm~*4i%l*bUx_`D7kdy@?8A#hra232V%->d>0B8_EK=R79tSc#FoIkZ1^=2#< zs$7Qo$tJj+V4q~xwXCuJ?rukGwN@xBJKWqz+niK&6Q(M@|C`<2won;1J-GMxXxj){ zqcWzKdc7_29P}ok_)ugZ>~B3GE8-?#am1Lky|aUEZLtFDQGbZ^fdjA&e1@_I7w)K5 zTMC|t3@70IXfoLXFN60T7QVvU75D`Z2S#Bq3B}-_$O9NU42u~Uj9V7!`|aHpkpjFN zf~)-@B_*hA!1+igoKAqT0rh>VjmrC@Qq@Vg{te#!2q{TGmklRSRdO)#0#;wcdLCx} zxrrdtF!u($=Pa;VfNQEsDD*!N%(3X)>$-EN z84G83-}}DL@4V+dzay&3{|v+baX} z47h$qWKX;BVUdFdj4Xq#5xD0UFk>3tlYdCLjLyvgP-MRC7PScv z6$qAVWj0H_RDyE3XsQmhB|sjm2!C8@CDQcB1(E&;jPypM@nkwpeR>+IRRBJN8X%bf#BE^*4g|-_UpHuE z9t!^m`V?lzq4YT*&=@Om6RriviYMTeB?Laz=yQc_HQ3>em4Hat6c$ze0|zT{WG9(gP1UFOA+YQ#IHXQ1Pzg$^h9PA%(cQNcc zqFVLZbV#Jbf?Em57opNB^RPHAk~3j60ns@aEyKQ(styEv&=9%cz{PgqZWKf|8*tc$ dqb?laHx%u=aPQ|!>=^(6002ovPDHLkV1m7be^vkh diff --git a/gui/icons/grass/exclamation-mark.png b/gui/icons/grass/exclamation-mark.png index 789808c642e012c803738ac1417ea6935dd6e1e5..fa17285bd6aa53da211e8c89fc039b50c239cfc8 100644 GIT binary patch delta 465 zcmV;?0WSW|1?&ShiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVE_OC32;bR za{vGd*8l(s*8#C^7q^i%Cw~EXNkl)n5D2_VRU4w*9s1Y`f3A2-+w)3;I*E9Z#0eB z;=|)vCojTAA!#O)vfG;hfC$K>?5rWF5aGiGt?9-Mj8?eb@)Mrc^7>DK5{Yx$OIE^l z$1`8F>z4i$?A+ab`o8!GkJbxhwfOWD5k~|70H#YnFxpFBNigI7H}qG5hs1uPWq!7g z@0v}Y|*UcSA(ieqB0ur-mJH_h6K+2fp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pnC&YG#&NvE7;^x?T6-HX6qf!JX7lD}Omq)o+0>!uSYqcNiZpl}dA>stgPatV@#QJL<EBr z*Ip8l6JdHKNs4q8{99$L0@!J{kimIAY zsWb--7ml@d8*mE91?rNByp<%$)YR0})vR!DZ-4LlTrStEs{5!PbEtRrpmT04wOi`S zd{RU_aA$_DQNJ?N4($RSAT(#dRaGr|??27zEqUn=3=FKRR4PLvvKv@+i^0vPsOpKu z#l_dtvaIMJg|)UV{IYBnk^4gAgiL0E8DPdacYQgHzX92 Date: Tue, 7 May 2024 16:31:33 +0200 Subject: [PATCH 09/10] Status enum used instead of status global variables --- gui/wxpython/core/gconsole.py | 23 ++++++++++------------- gui/wxpython/history/tree.py | 25 +++++++++++++------------ gui/wxpython/lmgr/frame.py | 6 +++--- gui/wxpython/main_window/frame.py | 6 +++--- python/grass/grassdb/history.py | 18 +++++++++++------- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/gui/wxpython/core/gconsole.py b/gui/wxpython/core/gconsole.py index c0bb5bfcdda..4705d639297 100644 --- a/gui/wxpython/core/gconsole.py +++ b/gui/wxpython/core/gconsole.py @@ -41,6 +41,7 @@ from grass.pydispatch.signal import Signal from grass.grassdb import history +from grass.grassdb.history import Status from core import globalvar from core.gcmd import CommandThread, GError, GException @@ -448,14 +449,13 @@ def WriteError(self, text): def UpdateHistory(self, status, runtime=None): """Update command history. - :param enum status enum: status of command + :param enum status: status of command run :param int runtime: duration of command run """ if runtime: - cmd_info = {"runtime": runtime, "status": status} + cmd_info = {"runtime": runtime, "status": status.value} else: - cmd_info = {"status": status} - + cmd_info = {"status": status.value} try: history_path = history.get_current_mapset_gui_history_path() history.update_entry(history_path, cmd_info) @@ -550,8 +550,8 @@ def RunCmd( ): event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) - return + else: # other GRASS commands (r|v|g|...) try: @@ -601,7 +601,6 @@ def RunCmd( parent=self._guiparent, message=_("Module <%s> not found.") % command[0], ) - pymodule = imp.load_source(command[0].replace(".", "_"), pyPath) pymain = inspect.getfullargspec(pymodule.main) if pymain and "giface" in pymain.args: @@ -615,8 +614,7 @@ def RunCmd( GUI( parent=self._guiparent, giface=self._giface ).ParseCommand(command) - self.UpdateHistory(status=history.STATUS_SUCCESS) - + self.UpdateHistory(status=Status.SUCCESS) except GException as e: print(e, file=sys.stderr) @@ -660,7 +658,6 @@ def RunCmd( ): event = gIgnoredCmdRun(cmd=command) wx.PostEvent(self, event) - return skipInterface = True @@ -687,7 +684,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) + self.UpdateHistory(status=Status.SUCCESS) else: self.cmdThread.RunCmd( command, @@ -762,15 +759,15 @@ def OnCmdDone(self, event): ) ) msg = _("Command aborted") - status = history.STATUS_ABORTED + status = Status.ABORTED elif event.returncode != 0: msg = _("Command ended with non-zero return code {returncode}").format( returncode=event.returncode ) - status = history.STATUS_FAILED + status = Status.FAILED else: msg = _("Command finished") - status = history.STATUS_SUCCESS + status = Status.SUCCESS # update command history log by status and runtime duration self.UpdateHistory(status=status, runtime=int(ctime)) diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index 2971c666555..ead959fbaae 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -41,6 +41,7 @@ from grass.pydispatch.signal import Signal from grass.grassdb import history +from grass.grassdb.history import Status # global variables for node types @@ -116,11 +117,11 @@ def __init__( self._iconTypes = [ TIME_PERIOD, - history.STATUS_ABORTED, - history.STATUS_FAILED, - history.STATUS_RUNNING, - history.STATUS_SUCCESS, - history.STATUS_UNKNOWN, + Status.ABORTED.value, + Status.FAILED.value, + Status.RUNNING.value, + Status.SUCCESS.value, + Status.UNKNOWN.value, ] self._initImages() @@ -165,11 +166,11 @@ def _initImages(self): bmpsize = (16, 16) icons = { TIME_PERIOD: MetaIcon(img="time-period").GetBitmap(bmpsize), - history.STATUS_ABORTED: MetaIcon(img="exclamation-mark").GetBitmap(bmpsize), - history.STATUS_FAILED: MetaIcon(img="cross").GetBitmap(bmpsize), - history.STATUS_RUNNING: MetaIcon(img="circle").GetBitmap(bmpsize), - history.STATUS_SUCCESS: MetaIcon(img="success").GetBitmap(bmpsize), - history.STATUS_UNKNOWN: MetaIcon(img="question-mark").GetBitmap(bmpsize), + Status.ABORTED.value: MetaIcon(img="exclamation-mark").GetBitmap(bmpsize), + Status.FAILED.value: MetaIcon(img="cross").GetBitmap(bmpsize), + Status.RUNNING.value: MetaIcon(img="circle").GetBitmap(bmpsize), + Status.SUCCESS.value: MetaIcon(img="success").GetBitmap(bmpsize), + Status.UNKNOWN.value: MetaIcon(img="question-mark").GetBitmap(bmpsize), } il = wx.ImageList(bmpsize[0], bmpsize[1], mask=False) for each in self._iconTypes: @@ -268,7 +269,7 @@ def _initHistoryModel(self): entry["command_info"].get("status") if entry.get("command_info") and entry["command_info"].get("status") is not None - else history.STATUS_UNKNOWN + else Status.UNKNOWN.value ) # Add command to time period node @@ -396,7 +397,7 @@ def InsertCommand(self, entry): type=COMMAND, name=entry["command"].strip(), timestamp=entry["command_info"]["timestamp"], - status=entry["command_info"].get("status", history.STATUS_UNKNOWN), + status=entry["command_info"].get("status", Status.UNKNOWN.value), ), ) diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index dd3e196b5ab..96b49780f2e 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -83,7 +83,7 @@ create_location_interactively, ) from grass.grassdb.checks import is_first_time_user -from grass.grassdb import history +from grass.grassdb.history import Status class GMFrame(wx.Frame): @@ -976,9 +976,9 @@ def RunSpecialCmd(self, command): " not supported." % " ".join(command) ) if result == 0: - self._gconsole.UpdateHistory(status=history.STATUS_SUCCESS) + self._gconsole.UpdateHistory(status=Status.SUCCESS) else: - self._gconsole.UpdateHistory(status=history.STATUS_FAILED) + self._gconsole.UpdateHistory(status=Status.FAILED) def RunDisplayCmd(self, command): """Handles display commands. diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index a69f40bebed..4dd8b5bf279 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -89,7 +89,7 @@ create_location_interactively, ) from grass.grassdb.checks import is_first_time_user -from grass.grassdb import history +from grass.grassdb.history import Status class SingleWindowAuiManager(aui.AuiManager): @@ -1113,9 +1113,9 @@ def RunSpecialCmd(self, command): " not supported." % " ".join(command) ) if result == 0: - self._gconsole.UpdateHistory(status=history.STATUS_SUCCESS) + self._gconsole.UpdateHistory(status=Status.SUCCESS) else: - self._gconsole.UpdateHistory(status=history.STATUS_FAILED) + self._gconsole.UpdateHistory(status=Status.FAILED) def RunDisplayCmd(self, command): """Handles display commands. diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index 0e87d6e647b..d20628dc820 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -11,6 +11,7 @@ import json import shutil +from enum import Enum from pathlib import Path from datetime import datetime @@ -18,12 +19,15 @@ from grass.script.utils import parse_key_val -# global status variables -STATUS_ABORTED = "aborted" -STATUS_FAILED = "failed" -STATUS_RUNNING = "running" -STATUS_SUCCESS = "success" -STATUS_UNKNOWN = "unknown" +class Status(Enum): + """Enum representing a set of status constants + that are used to represent various states or command outcomes.""" + + ABORTED = "aborted" + FAILED = "failed" + RUNNING = "running" + SUCCESS = "success" + UNKNOWN = "unknown" def get_current_mapset_gui_history_path(): @@ -286,7 +290,7 @@ def get_initial_command_info(env_run): "mask2d": mask2d_present, "mask3d": mask3d_present, "region": region_settings, - "status": STATUS_RUNNING, + "status": Status.RUNNING.value, } return cmd_info From b78d8e8bf6a9b9a4130c512ce7ef96ecb69f464e Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 9 May 2024 14:36:39 +0200 Subject: [PATCH 10/10] True/False instead of 0/1 --- gui/wxpython/lmgr/frame.py | 13 +++++++------ gui/wxpython/main_window/frame.py | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index 96b49780f2e..bfc25131a85 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -948,7 +948,7 @@ def _switchPage(self, notification): def RunSpecialCmd(self, command): """Run command from command line, check for GUI wrappers""" - result = 0 + result = True if re.compile(r"^d\..*").search(command[0]): result = self.RunDisplayCmd(command) elif re.compile(r"r[3]?\.mapcalc").search(command[0]): @@ -970,12 +970,12 @@ def RunSpecialCmd(self, command): elif command[0] == "cd": self.OnChangeCWD(event=None, cmd=command) else: - result = 1 + result = False raise ValueError( "Layer Manager special command (%s)" " not supported." % " ".join(command) ) - if result == 0: + if result: self._gconsole.UpdateHistory(status=Status.SUCCESS) else: self._gconsole.UpdateHistory(status=Status.FAILED) @@ -984,6 +984,7 @@ def RunDisplayCmd(self, command): """Handles display commands. :param command: command in a list + :return int: False if failed, True if succcess """ if not self.currentPage: self.NewDisplay(show=True) @@ -991,7 +992,7 @@ def RunDisplayCmd(self, command): if command[0] == "d.erase": # rest of d.erase is ignored self.GetLayerTree().DeleteAllLayers() - return 1 + return False try: # display GRASS commands layertype = command2ltype[command[0]] @@ -1004,7 +1005,7 @@ def RunDisplayCmd(self, command): ) % command[0], ) - return 1 + return False if layertype == "barscale": if len(command) > 1: @@ -1058,7 +1059,7 @@ def RunDisplayCmd(self, command): lname=lname, lcmd=command, ) - return 0 + return True def GetLayerNotebook(self): """Get Layers Notebook""" diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index 4dd8b5bf279..cba4c81b6de 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -1085,7 +1085,7 @@ def FocusPage(self, page_text): def RunSpecialCmd(self, command): """Run command from command line, check for GUI wrappers""" - result = 0 + result = True if re.compile(r"^d\..*").search(command[0]): result = self.RunDisplayCmd(command) elif re.compile(r"r[3]?\.mapcalc").search(command[0]): @@ -1107,12 +1107,12 @@ def RunSpecialCmd(self, command): elif command[0] == "cd": self.OnChangeCWD(event=None, cmd=command) else: - result = 1 + result = False raise ValueError( "Layer Manager special command (%s)" " not supported." % " ".join(command) ) - if result == 0: + if result: self._gconsole.UpdateHistory(status=Status.SUCCESS) else: self._gconsole.UpdateHistory(status=Status.FAILED) @@ -1121,7 +1121,7 @@ def RunDisplayCmd(self, command): """Handles display commands. :param command: command in a list - :return int: 1 if failed, 0 if succcess + :return int: False if failed, True if succcess """ if not self.currentPage: self.NewDisplay(show=True) @@ -1129,7 +1129,7 @@ def RunDisplayCmd(self, command): if command[0] == "d.erase": # rest of d.erase is ignored self.GetLayerTree().DeleteAllLayers() - return 1 + return False try: # display GRASS commands layertype = command2ltype[command[0]] @@ -1142,7 +1142,7 @@ def RunDisplayCmd(self, command): ) % command[0], ) - return 1 + return False if layertype == "barscale": if len(command) > 1: @@ -1196,7 +1196,7 @@ def RunDisplayCmd(self, command): lname=lname, lcmd=command, ) - return 0 + return True def GetAuiManager(self): """Get aui manager