Skip to content
Browse files

replaced all STDOUT PUT stmts with logger statements

  • Loading branch information...
1 parent 82dc4d5 commit 3bf93a7e99c636b174b2d1df0d21aeb56954d57b @rdulepet committed Jun 27, 2010
Showing with 8 additions and 12 deletions.
  1. +6 −6 job.rb
  2. +2 −6 s3_upload.rb
View
12 job.rb
@@ -106,8 +106,8 @@ def fetch_params
# track all input data files
@in_data_files[just_name] = 1
- puts "PARAM_NAME_DATASET::#{job_params[PARAM_NAME]} = #{job_params[PARAM_DATA_SET].to_s}"
- puts "MODIFIED_PARAM_NAME_DATASET::#{job_params[PARAM_NAME]} = #{job_params[PARAM_DATA_SET]}"
+ Global.logger.info("PARAM_NAME_DATASET::#{job_params[PARAM_NAME]} = #{job_params[PARAM_DATA_SET].to_s}")
+ Global.logger.info("MODIFIED_PARAM_NAME_DATASET::#{job_params[PARAM_NAME]} = #{job_params[PARAM_DATA_SET]}")
fetch_data_file job_params[PARAM_DATA_SET], "#{Global.results_dir}/#{@curr_uuid}/#{just_name}"
elsif job_params[PARAM_KIND] == VALUE_STRING
#@r_call_interface.assign(job_params[PARAM_NAME], job_params[PARAM_VALUE].to_s)
@@ -197,7 +197,7 @@ def normalized_get_id
def store_results_and_logs
# first store log
begin
- puts "LOG_FILE = logs/job_#{normalized_get_id}/job.log"
+ Global.logger.info("LOG_FILE = logs/job_#{normalized_get_id}/job.log")
upload_results_to_s3(@server_node, @job_id, "logs", "job.log", "#{Global.results_dir}/#{@curr_uuid}/job.log")
rescue => err_store_log
Global.logger.info('probably no error log generated, happens for successful jobs that have no output or error')
@@ -210,7 +210,7 @@ def store_results_and_logs
upload_files = Dir[File.join("#{Global.results_dir}/#{@curr_uuid}", "*")].select{|file| File.ftype(file) == "file" &&
/\.(jpg|png|gif|html|htm|js|css|pdf)$/.match(file.downcase)}.each{|name|
name = name.split("/").last
- puts "RESULTS_FILE = #{Global.results_dir}/#{@curr_uuid}/#{name}"
+ Global.logger.info("RESULTS_FILE = #{Global.results_dir}/#{@curr_uuid}/#{name}")
upload_results_to_s3(@server_node,
@job_id,
"results",
@@ -226,14 +226,14 @@ def store_data
# .html,.htm,.css,.png,.pdf,.jpg
# iterate through directory and store files one at a time in S3
upload_files = Dir[File.join("#{Global.results_dir}/#{@curr_uuid}", "*")].select{|file|
- puts "file in dir=#{file}"
+ Global.logger.info( "file in dir=#{file}")
File.ftype(file) == "file" &&
!/\.(jpg|png|gif|html|htm|js|css|pdf|log|r|rb|java|php|py|pyc|jar|gz|tar|zip|class|exe|so|o|dll|lib)$/.match(file.downcase)}.each{|name|
name = name.split("/").last
if ! @in_data_files.has_key?(name)
# seems like underscore is issue so replace with hyphen
uploaded_name = "job-#{normalized_get_id}-#{name}".gsub(/_/, '-')
- puts "DATA_OUTPUT_FILE = #{Global.results_dir}/#{@curr_uuid}/#{name}"
+ Global.logger.info("DATA_OUTPUT_FILE = #{Global.results_dir}/#{@curr_uuid}/#{name}")
upload_data_to_s3(@server_node,
@job_id,
"data",
View
8 s3_upload.rb
@@ -26,8 +26,6 @@ def upload_results_to_s3 (server_name, job_id, type, fname, fpath_name)
def upload_data_to_s3 (server_name, job_id, type, fname, fpath_name)
s3_data = ''
- puts "UPLOAD_DATA_TO_S3::http://#{server_name}/jobs/#{job_id}/uploadurls.xml?upload_type=#{type}&files=#{fname}"
-
response = Net::HTTP.get(URI.parse("http://#{server_name}/jobs/#{job_id}/uploadurls.xml?upload_type=#{type}&files=#{fname}"))
s3_data = XmlSimple.xml_in(response)
@@ -44,7 +42,6 @@ def upload_data_to_s3 (server_name, job_id, type, fname, fpath_name)
end
#create dataset object form path
- puts "UPLOAD_DATA_TO_S3::CREATE_DATASET::http://#{server_name}/data_sets/create_from_path.xml?name=#{fname}&job_id=#{job_id}&path=#{path}"
Net::HTTP.get(URI.parse("http://#{server_name}/data_sets/create_from_path.xml?name=#{fname}&job_id=#{job_id}&path=#{path}"))
end
@@ -55,7 +52,6 @@ def fetch_data_file(s3url, dest_file)
url_fetch = url.path
url_fetch = url.path + '?' + url.query if !url.query.nil?
- puts "URL_FETCH=#{url_fetch}"
# save output
data_file_handle = File.new(dest_file, 'wb')
@@ -90,8 +86,8 @@ def send_request(req_type, host, port, url, fields_hash, up_file, ssl)
# Handle auth errors and other errors!
if !response.is_a?(Net::HTTPOK)
- puts 'Failed to upload!'
- log_request(request, response)
+ #puts 'Failed to upload!'
+ #log_request(request, response)
else
res = true
end

0 comments on commit 3bf93a7

Please sign in to comment.
Something went wrong with that request. Please try again.