Merge branch 'develop' of https://DennisOSRM@github.com/DennisOSRM/Project-OSRM.git into develop
This commit is contained in:
commit
10513784c7
@ -197,17 +197,28 @@ def write_timestamp
|
||||
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||
end
|
||||
|
||||
def log_tail path, n
|
||||
File.open(path) do |f|
|
||||
return f.tail(n).map { |line| " #{line}" }.join "\n"
|
||||
end
|
||||
end
|
||||
|
||||
def reprocess
|
||||
Dir.chdir TEST_FOLDER do
|
||||
write_osm
|
||||
write_timestamp
|
||||
convert_osm_to_pbf
|
||||
|
||||
log_path = 'preprocessing.log'
|
||||
log_lines = 3
|
||||
|
||||
unless extracted?
|
||||
log_preprocess_info
|
||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||
tail = log_tail log_path,log_lines
|
||||
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. Last #{log_lines} lines from #{log_path}:\n#{tail}\n"
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
@ -216,7 +227,8 @@ def reprocess
|
||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||
tail = log_tail log_path,log_lines
|
||||
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. Last #{log_lines} lines from #{log_path}:\n#{tail}\n"
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
|
22
features/support/file.rb
Normal file
22
features/support/file.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class File
|
||||
|
||||
#read last n lines of a file. useful for getting last part of a big log file.
|
||||
def tail(n)
|
||||
buffer = 1024
|
||||
idx = (size - buffer).abs
|
||||
chunks = []
|
||||
lines = 0
|
||||
|
||||
begin
|
||||
seek(idx)
|
||||
chunk = read(buffer)
|
||||
lines += chunk.count("\n")
|
||||
chunks.unshift chunk
|
||||
idx -= buffer
|
||||
end while lines < ( n + 1 ) && pos != 0
|
||||
|
||||
tail_of_file = chunks.join('')
|
||||
ary = tail_of_file.split(/\n/)
|
||||
lines_to_return = ary[ ary.size - n, ary.size - 1 ]
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user