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)
| 168 | |
| 169 | |
| 170 | def 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 | |
| 198 | class ActionBranch(resource.ResourceBranch): |
no test coverage detected