MCPcopy Create free account
hub / github.com/StackStorm/st2 / format_execution_status

Function format_execution_status

st2client/st2client/commands/action.py:170–195  ·  view source on GitHub ↗

Augment instance "status" attribute with number of seconds which have elapsed for all the executions which are in running state and execution total run time for all the executions which have finished.

(instance)

Source from the content-addressed store, hash-verified

168
169
170def format_execution_status(instance):
171 """
172 Augment instance "status" attribute with number of seconds which have elapsed for all the
173 executions which are in running state and execution total run time for all the executions
174 which have finished.
175 """
176 status = getattr(instance, "status", None)
177 start_timestamp = getattr(instance, "start_timestamp", None)
178 end_timestamp = getattr(instance, "end_timestamp", None)
179
180 if status == LIVEACTION_STATUS_RUNNING and start_timestamp:
181 start_timestamp = instance.start_timestamp
182 start_timestamp = parse_isotime(start_timestamp)
183 start_timestamp = calendar.timegm(start_timestamp.timetuple())
184 now = int(time.time())
185 elapsed_seconds = now - start_timestamp
186 instance.status = "%s (%ss elapsed)" % (instance.status, elapsed_seconds)
187 elif status in LIVEACTION_COMPLETED_STATES and start_timestamp and end_timestamp:
188 start_timestamp = parse_isotime(start_timestamp)
189 start_timestamp = calendar.timegm(start_timestamp.timetuple())
190 end_timestamp = parse_isotime(end_timestamp)
191 end_timestamp = calendar.timegm(end_timestamp.timetuple())
192 elapsed_seconds = end_timestamp - start_timestamp
193 instance.status = "%s (%ss elapsed)" % (instance.status, elapsed_seconds)
194
195 return instance
196
197
198class ActionBranch(resource.ResourceBranch):

Callers 4

run_and_printMethod · 0.85
_print_resultMethod · 0.85
_print_resultMethod · 0.85

Calls 1

timeMethod · 0.45

Tested by

no test coverage detected