diff options
author | Christoph Helma <helma@in-silico.de> | 2010-02-04 19:41:23 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2010-02-04 19:41:23 +0100 |
commit | 96acb35b4357ee4094c2f54384f200b5533d8ad9 (patch) | |
tree | d2c6a5ef20d92a727907d69dc52516b9ddfc1459 | |
parent | 3d65a42cf68bd5128666d810ec3c29673624ee5d (diff) |
tasks as trees, prediction of database structures, improved error checking
-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 |