Skip to content

Commit

Permalink
further on
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Sep 16, 2009
1 parent 87b19a8 commit fd3d508
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions lib/cloud_crowd/action.rb
Expand Up @@ -38,13 +38,16 @@ def process

# Download a file to the specified path.
def download(url, path)
if url.match(FILE_URL)
FileUtils.cp(url.sub(FILE_URL, ''), path)
else
# An alternative would be shelling out: `curl -s "#{url}" > "#{path}"`
resp = RestClient::Request.execute(:url => url, :method => :get, :raw_response => true)
FileUtils.mv resp.file.path, path
end
URI.parse(url) # Sanity check.
`curl -s "#{url}" > "#{path}"`
# if url.match(FILE_URL)
# FileUtils.cp(url.sub(FILE_URL, ''), path)
# else
# # An alternative would be shelling out: `curl -s "#{url}" > "#{path}"`
# puts url
# resp = RestClient::Request.execute(:url => url, :method => :get, :raw_response => true)
# FileUtils.mv resp.file.path, path
# end
path
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_crowd/models/job.rb
Expand Up @@ -95,8 +95,8 @@ def action_class
# How complete is this Job?
def percent_complete
return 0 if splitting?
return 100 if complete?
return 99 if merging?
return 100 if complete?
(work_units.complete.count / work_units.count.to_f * 100).round
end

Expand Down
2 changes: 2 additions & 0 deletions lib/cloud_crowd/server.rb
Expand Up @@ -104,6 +104,8 @@ class Server < Sinatra::Default
when 'failed' then current_work_unit.fail(params[:output], params[:time])
else error(500, "Completing a work unit must specify status.")
end
# TODO: Optimize this case -- we know there's probably going to be only
# a single slot available. Just try to distribute a single WorkUnit.
WorkUnit.distribute_to_nodes
json nil
end
Expand Down

0 comments on commit fd3d508

Please sign in to comment.