diff options
-rw-r--r-- | lib/task.rb | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/task.rb b/lib/task.rb index 9e60c2e..70d22bf 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -26,19 +26,6 @@ module OpenTox task_uris = RestClient.get(@@config[:services]["opentox-task"]).split(/\n/) task_uris.collect{|uri| Task.new(uri)} end - - def started - #LOGGER.info File.join(@uri,'started') - RestClient.put File.join(@uri,'started'), {} - end - - def cancel - RestClient.put File.join(@uri,'cancelled'), {} - end - - def completed(uri) - RestClient.put File.join(@uri,'completed'), :resource => uri - end def created_at RestClient.get File.join(@uri, 'created_at') @@ -55,6 +42,26 @@ module OpenTox def resource RestClient.get File.join(@uri, 'resource') end + + def started + RestClient.put File.join(@uri,'started'), {} + end + + def cancel + RestClient.put File.join(@uri,'cancelled'), {} + end + + def failed + RestClient.put File.join(@uri,'failed'), {} + end + + def parent=(task) + RestClient.put File.join(@uri,'parent'), {:uri => task.uri} + end + + def completed(uri) + RestClient.put File.join(@uri,'completed'), :resource => uri + end def pid=(pid) RestClient.put File.join(@uri, 'pid'), :pid => pid @@ -64,8 +71,12 @@ module OpenTox self.status.to_s == 'completed' end + def failed? + self.status.to_s == 'failed' + end + def wait_for_completion - until self.completed? + until self.completed? or self.failed? sleep 1 end end |