From: Phil Hodgson Date: Tue, 25 Nov 2014 07:41:37 +0000 (+0100) Subject: 4233: convert accidental tabs to spaces X-Git-Tag: 1.1.0~1966^2~6 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/5aecf0f1c591bc1f473b6bb56715ce8db5013268?hp=f8991d36180bf9c2c261dee519b0c878306a35d5 4233: convert accidental tabs to spaces --- diff --git a/apps/workbench/app/assets/stylesheets/jobs.css.scss b/apps/workbench/app/assets/stylesheets/jobs.css.scss index 565c354f6d..cf93f20350 100644 --- a/apps/workbench/app/assets/stylesheets/jobs.css.scss +++ b/apps/workbench/app/assets/stylesheets/jobs.css.scss @@ -10,6 +10,6 @@ } .morris-hover-point { - text-align: left; - width: 100%; + text-align: left; + width: 100%; } \ No newline at end of file diff --git a/services/api/lib/simulate_job_log.rb b/services/api/lib/simulate_job_log.rb index 71c9825e44..fc124c8f77 100644 --- a/services/api/lib/simulate_job_log.rb +++ b/services/api/lib/simulate_job_log.rb @@ -1,51 +1,49 @@ module SimulateJobLog - def replay(filename, multiplier = 1, simulated_job_uuid = nil) - raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV'] + def replay(filename, multiplier = 1, simulated_job_uuid = nil) + raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV'] - multiplier = multiplier.to_f - multiplier = 1.0 if multiplier <= 0 + multiplier = multiplier.to_f + multiplier = 1.0 if multiplier <= 0 - actual_start_time = Time.now - log_start_time = nil + actual_start_time = Time.now + log_start_time = nil - act_as_system_user do - File.open(filename).each.with_index do |line, index| - cols = {} - cols[:timestamp], rest_of_line = line.split(' ', 2) - begin - cols[:timestamp] = Time.strptime( cols[:timestamp], "%Y-%m-%d_%H:%M:%S" ) - rescue ArgumentError - if line =~ /^((?:Sun|Mon|Tue|Wed|Thu|Fri|Sat) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2} \d\d:\d\d:\d\d \d{4}) (.*)/ - # Wed Nov 19 07:12:39 2014 - cols[:timestamp] = Time.strptime( $1, "%a %b %d %H:%M:%S %Y" ) - rest_of_line = $2 - else - STDERR.puts "Ignoring log line because of unknown time format: #{line}" - end - end - cols[:job_uuid], cols[:pid], cols[:task], cols[:event_type], cols[:message] = rest_of_line.split(' ', 5) - # Override job uuid with a simulated one if specified - cols[:job_uuid] = simulated_job_uuid || cols[:job_uuid] - # determine when we want to simulate this log being created, based on the time multiplier - log_start_time = cols[:timestamp] if log_start_time.nil? - log_time = cols[:timestamp] - actual_elapsed_time = Time.now - actual_start_time - log_elapsed_time = log_time - log_start_time - modified_elapsed_time = log_elapsed_time / multiplier - pause_time = modified_elapsed_time - actual_elapsed_time - if pause_time > 0 - sleep pause_time - end - # output log entry for debugging and create it in the current environment's database - puts "#{index} #{cols.to_yaml}\n" - Log.new({ - event_at: Time.zone.local_to_utc(cols[:timestamp]), - object_uuid: cols[:job_uuid], - event_type: cols[:event_type], - properties: { 'text' => line } - }).save! - end - end + act_as_system_user do + File.open(filename).each.with_index do |line, index| + cols = {} + cols[:timestamp], rest_of_line = line.split(' ', 2) + begin + cols[:timestamp] = Time.strptime( cols[:timestamp], "%Y-%m-%d_%H:%M:%S" ) + rescue ArgumentError + if line =~ /^((?:Sun|Mon|Tue|Wed|Thu|Fri|Sat) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2} \d\d:\d\d:\d\d \d{4}) (.*)/ + # Wed Nov 19 07:12:39 2014 + cols[:timestamp] = Time.strptime( $1, "%a %b %d %H:%M:%S %Y" ) + rest_of_line = $2 + else + STDERR.puts "Ignoring log line because of unknown time format: #{line}" + end + end + cols[:job_uuid], cols[:pid], cols[:task], cols[:event_type], cols[:message] = rest_of_line.split(' ', 5) + # Override job uuid with a simulated one if specified + cols[:job_uuid] = simulated_job_uuid || cols[:job_uuid] + # determine when we want to simulate this log being created, based on the time multiplier + log_start_time = cols[:timestamp] if log_start_time.nil? + log_time = cols[:timestamp] + actual_elapsed_time = Time.now - actual_start_time + log_elapsed_time = log_time - log_start_time + modified_elapsed_time = log_elapsed_time / multiplier + pause_time = modified_elapsed_time - actual_elapsed_time + sleep pause_time if pause_time > 0 + # output log entry for debugging and create it in the current environment's database + puts "#{index} #{cols.to_yaml}\n" + Log.new({ + event_at: Time.zone.local_to_utc(cols[:timestamp]), + object_uuid: cols[:job_uuid], + event_type: cols[:event_type], + properties: { 'text' => line } + }).save! + end + end - end + end end diff --git a/services/api/lib/tasks/replay_job_log.rake b/services/api/lib/tasks/replay_job_log.rake index fad205b23d..14aa3be788 100644 --- a/services/api/lib/tasks/replay_job_log.rake +++ b/services/api/lib/tasks/replay_job_log.rake @@ -1,7 +1,7 @@ require 'simulate_job_log' desc 'Simulate job logging from a file. Three arguments: log filename, time multipler (optional), simulated job uuid (optional). E.g. (use quotation marks if using spaces between args): rake "replay_job_log[log.txt, 2.0, qr1hi-8i9sb-nf3qk0xzwwz3lre]"' task :replay_job_log, [:filename, :multiplier, :uuid] => :environment do |t, args| - include SimulateJobLog - abort("No filename specified.") if args[:filename].blank? - replay( args[:filename], args[:multiplier].to_f, args[:uuid] ) + include SimulateJobLog + abort("No filename specified.") if args[:filename].blank? + replay( args[:filename], args[:multiplier].to_f, args[:uuid] ) end