1 | # This program is under CECILL_B licence. See footer for details. |
---|
2 | |
---|
3 | proc action_create { args } { |
---|
4 | global codesPath defaultSolver solverPath |
---|
5 | set mandatory_arguments { path_father address } |
---|
6 | initWidget |
---|
7 | set widgetInfo($address-title) [dTree_getAttribute $XMLtree $full_address_XML "title"] |
---|
8 | set widgetInfo($address-args) [split [dTree_tryGetAttribute $XMLtree $full_address_XML "script_args" ""] ";"] |
---|
9 | set widgetInfo($address-blocking) [split [dTree_tryGetAttribute $XMLtree $full_address_XML "status_blocking" "yes"] ";"] |
---|
10 | |
---|
11 | set widgetInfo($address-starttime) "0" |
---|
12 | set widgetInfo($address-endtime) "0" |
---|
13 | |
---|
14 | |
---|
15 | #smartpacker_setup_modelframe $win $address |
---|
16 | ttk::frame $win |
---|
17 | eval $widgetInfo(packme-$win) |
---|
18 | |
---|
19 | ttk::frame $win.action |
---|
20 | ttk::frame $win.infos |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | set script [dTree_getAttribute $XMLtree $full_address_XML "script"] |
---|
25 | set widgetInfo($address-scriptAddress) [file join $solverPath scripts $script] |
---|
26 | if {![file exists $widgetInfo($address-scriptAddress)]} { |
---|
27 | error "File not found : \n$widgetInfo($address-scriptAddress)" |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | #ttk::label $win.title -width -10 -text $title |
---|
33 | ttk::label $win.action.status -width -20 -textvariable widgetInfo($address-status_txt) -justify left -compound left |
---|
34 | ttk::progressbar $win.action.progress -mode indeterminate |
---|
35 | $win.action.progress stop |
---|
36 | ttk::button $win.action.launch -text $widgetInfo($address-title) -command [subst { |
---|
37 | log "\n@@@@@@@@ Process Action '$widgetInfo($address-title)' @@@@@@@" |
---|
38 | openPipe $win $address |
---|
39 | }] |
---|
40 | # |
---|
41 | set widgetInfo($address-progressValue) 0 |
---|
42 | |
---|
43 | |
---|
44 | ############################ |
---|
45 | # Adding script node |
---|
46 | emptyNode_create -path_father $win -address $address.scriptNode |
---|
47 | append widgetInfo($address.scriptNode-refresh) [subst { set widgetInfo($address.scriptNode-status) \[ expr (\$widgetInfo($address.scriptNode-variable)+1)/2]}] |
---|
48 | |
---|
49 | #pack $win -pady 5 |
---|
50 | |
---|
51 | #grid $win.action -sticky news -column 0 -row 0 |
---|
52 | pack $win.action -side top -fill x -expand 1 |
---|
53 | pack $win.action.launch -side top -expand 1 |
---|
54 | pack $win.action.progress -side top -expand 1 |
---|
55 | pack $win.action.status -side top -expand 1 |
---|
56 | |
---|
57 | pack $win.infos -side top -fill x -expand 1 |
---|
58 | #grid $win.infos -sticky news -column 0 -row 1 |
---|
59 | |
---|
60 | #grid columnconfigure $win $win.infos -weight 1 |
---|
61 | |
---|
62 | append widgetInfo($address-refresh) [subst { action_refresh $win $address }] |
---|
63 | append widgetInfo($address-refreshStatus) [subst { action_refreshStatus $win $address }] |
---|
64 | |
---|
65 | set widgetInfo($address-onScriptStarts) [subst { |
---|
66 | $win.action.status configure -image icon_void -foreground black |
---|
67 | set widgetInfo($address-cancellation) 0 |
---|
68 | if {\$widgetInfo($address-status) == -1} { |
---|
69 | set widgetInfo($address-cancellation) 0 |
---|
70 | set widgetInfo($address-status_txt) "Warning, status was initially wrong.." |
---|
71 | } else { |
---|
72 | $win.action.progress start |
---|
73 | set widgetInfo(action-callingAddress) $address |
---|
74 | $win.action.launch configure -text "Escape to Abort" |
---|
75 | #$win.action.launch configure -command "stopScript $win $address" |
---|
76 | } |
---|
77 | }] |
---|
78 | |
---|
79 | set widgetInfo($address-onScriptStops) [subst { |
---|
80 | $win.action.progress configure -mode indeterminate |
---|
81 | $win.action.progress stop |
---|
82 | $win.action.launch configure -text "$widgetInfo($address-title)" |
---|
83 | $win.action.launch configure -command "openPipe $win $address" |
---|
84 | set widgetInfo($address.scriptNode-status) -1 |
---|
85 | set widgetInfo($address.scriptNode-variable) 0 |
---|
86 | eval \$widgetInfo($address.scriptNode-check) |
---|
87 | action_refreshStatus $win $address |
---|
88 | Stop_think normal |
---|
89 | }] |
---|
90 | |
---|
91 | set widgetInfo($address-updateProgress) [subst { |
---|
92 | $win.action.progress stop |
---|
93 | $win.action.progress configure -mode determinate -value \$widgetInfo($address-progressValue) |
---|
94 | |
---|
95 | }] |
---|
96 | |
---|
97 | set widgetInfo($address-onScriptEnds) [subst { |
---|
98 | $win.action.progress configure -mode indeterminate |
---|
99 | $win.action.progress stop |
---|
100 | $win.action.launch configure -text "$widgetInfo($address-title)" |
---|
101 | $win.action.launch configure -command "openPipe $win $address" |
---|
102 | set widgetInfo($address.scriptNode-status) 1 |
---|
103 | set widgetInfo($address.scriptNode-variable) 1 |
---|
104 | eval \$widgetInfo($address.scriptNode-check) |
---|
105 | action_refreshStatus $win $address |
---|
106 | Stop_think normal |
---|
107 | }] |
---|
108 | |
---|
109 | set widgetInfo($address-status) "-2" |
---|
110 | if {[dTree_attrExists $XMLtree $full_address_XML "initstatus"] == 1 } { |
---|
111 | set widgetInfo($address-status) "1" |
---|
112 | } |
---|
113 | |
---|
114 | action_refreshStatus $win $address |
---|
115 | finishWidget |
---|
116 | return $win.infos |
---|
117 | } |
---|
118 | |
---|
119 | proc action_refreshStatus {win address} { |
---|
120 | global widgetInfo |
---|
121 | |
---|
122 | set duration [printtime $widgetInfo($address-starttime) $widgetInfo($address-endtime) ] |
---|
123 | |
---|
124 | |
---|
125 | switch $widgetInfo($address.scriptNode-status) { |
---|
126 | "-1" {$win.action.status configure -image icon_error -foreground red |
---|
127 | set widgetInfo($address.scriptNode-status) -1 |
---|
128 | set widgetInfo($address-progress) 0 |
---|
129 | set widgetInfo($address-status_txt) "Execution error : check logs. Took $duration s." |
---|
130 | set widgetInfo($address-variable) 0 |
---|
131 | } |
---|
132 | "1" {$win.action.status configure -image icon_ok -foreground green4 |
---|
133 | set widgetInfo($address.scriptNode-status) 1 |
---|
134 | set widgetInfo($address-progress) 100 |
---|
135 | set widgetInfo($address-status_txt) "Done in $duration s." |
---|
136 | set widgetInfo($address-variable) 1 |
---|
137 | } |
---|
138 | "-2" {$win.action.status configure -image icon_void -foreground black |
---|
139 | set widgetInfo($address-progress) 100 |
---|
140 | |
---|
141 | set widgetInfo($address-status_txt) "Waiting for launch" |
---|
142 | set widgetInfo($address-variable) 1 |
---|
143 | set widgetInfo($address.scriptNode-status) -2 |
---|
144 | } |
---|
145 | default {$win.action.status configure -image icon_void -foreground black |
---|
146 | set widgetInfo($address-progress) 0 |
---|
147 | set widgetInfo($address-status_txt) "" |
---|
148 | set widgetInfo($address-variable) 0 |
---|
149 | set widgetInfo($address.scriptNode-status) 0 |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | smartpacker_update_visibility $win $address |
---|
154 | |
---|
155 | if {$widgetInfo($address-blocking) =="no"} { |
---|
156 | set widgetInfo($address-status) 1 |
---|
157 | set widgetInfo($address.scriptNode-status) 1 |
---|
158 | } |
---|
159 | |
---|
160 | } |
---|
161 | |
---|
162 | proc action_refresh {win address} { |
---|
163 | # take the variable value from DStree to see if the run has already be done |
---|
164 | |
---|
165 | } |
---|
166 | |
---|
167 | |
---|
168 | # Copyright CERFACS 2014 |
---|
169 | # |
---|
170 | # antoine.dauptain@cerfacs.fr |
---|
171 | # |
---|
172 | # This software is a computer program whose purpose is to ensure technology |
---|
173 | # transfer between academia and industry. |
---|
174 | # |
---|
175 | # This software is governed by the CeCILL-B license under French law and |
---|
176 | # abiding by the rules of distribution of free software. You can use, |
---|
177 | # modify and/ or redistribute the software under the terms of the CeCILL-B |
---|
178 | # license as circulated by CEA, CNRS and INRIA at the following URL |
---|
179 | # "http://www.cecill.info". |
---|
180 | # |
---|
181 | # As a counterpart to the access to the source code and rights to copy, |
---|
182 | # modify and redistribute granted by the license, users are provided only |
---|
183 | # with a limited warranty and the software's author, the holder of the |
---|
184 | # economic rights, and the successive licensors have only limited |
---|
185 | # liability. |
---|
186 | # |
---|
187 | # In this respect, the user's attention is drawn to the risks associated |
---|
188 | # with loading, using, modifying and/or developing or reproducing the |
---|
189 | # software by the user in light of its specific status of free software, |
---|
190 | # that may mean that it is complicated to manipulate, and that also |
---|
191 | # therefore means that it is reserved for developers and experienced |
---|
192 | # professionals having in-depth computer knowledge. Users are therefore |
---|
193 | # encouraged to load and test the software's suitability as regards their |
---|
194 | # requirements in conditions enabling the security of their systems and/or |
---|
195 | # data to be ensured and, more generally, to use and operate it in the |
---|
196 | # same conditions as regards security. |
---|
197 | # |
---|
198 | # The fact that you are presently reading this means that you have had |
---|
199 | # knowledge of the CeCILL-B license and that you accept its terms. |
---|