Class: DTK::Client::TaskStatus::RefreshMode
- Inherits:
-
DTK::Client::TaskStatus
- Object
- BaseCommandHelper
- DTK::Client::TaskStatus
- DTK::Client::TaskStatus::RefreshMode
- Defined in:
- lib/task_status/refresh_mode.rb
Constant Summary collapse
- DEBUG_SLEEP_TIME =
DTK::Configuration.get(:debug_task_frequency)
Instance Method Summary collapse
Methods inherited from DTK::Client::TaskStatus
Methods inherited from BaseCommandHelper
#initialize, #print_external_dependencies
Constructor Details
This class inherits a constructor from DTK::Client::TaskStatus
Instance Method Details
#task_status(opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/task_status/refresh_mode.rb', line 23 def task_status(opts={}) begin response = nil loop do response = post_call(opts) return response unless response.ok? # stop pulling when top level task succeds, fails or timeout if response and response.data and response.data.first return response if response.data.first["change_context"] #TODO: may fix in server, but now top can have non executing state but a concurrent branch can execute; so #chanding bloew for time being #break unless response.data.first["status"].eql? "executing" # TODO: There is bug where we do not see executing status on start so we have to wait until at # least one 'successed' has been found top_task_failed = response.data.first['status'].eql?('failed') is_pending = (response.data.select {|r|r["status"].nil? }).size > 0 is_executing = (response.data.select {|r|r["status"].eql? "executing"}).size > 0 is_failed = (response.data.select {|r|r["status"].eql? "failed"}).size > 0 is_cancelled = response.data.first["status"].eql?("cancelled") # commented out because of DTK-1804 # when some of the converge tasks fail, stop task-status --wait and set task status to '' for remaining tasks which are not executed # if is_failed # response.data.each {|r| (r["status"] = "") if r["status"].eql?("executing")} # is_cancelled = true # end is_cancelled = true if top_task_failed unless (is_executing || is_pending) && !is_cancelled system('clear') response.print_error_table = true response.render_table(:task_status) return response end end response.render_table(:task_status) system('clear') response.render_data(true) Console.wait_animation("Watching '#{@object_type}' task status [ #{DEBUG_SLEEP_TIME} seconds refresh ] ", DEBUG_SLEEP_TIME) end rescue Interrupt => e puts "" # this tells rest of the flow to skip rendering of this response response.skip_render = true unless response.nil? end end |