Merge branch 'develop' of https://DennisOSRM@github.com/DennisOSRM/Project-OSRM.git into develop
This commit is contained in:
		
						commit
						9b4e31c5ea
					
				| @ -39,7 +39,7 @@ When /^I preprocess data$/ do | ||||
| end | ||||
| 
 | ||||
| Then /^"([^"]*)" should return code (\d+)$/ do |binary, code| | ||||
|   @process_error.class.should == OSRMError | ||||
|   @process_error.is_a?(OSRMError).should == true | ||||
|   @process_error.process.should == binary | ||||
|   @process_error.code.to_i.should == code.to_i | ||||
| end | ||||
|  | ||||
| @ -177,7 +177,7 @@ def convert_osm_to_pbf | ||||
|     log_preprocess_info | ||||
|     log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess | ||||
|     unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}" | ||||
|       raise "Failed to convert to proto buffer format. Please see #{hash}.log for more info."  | ||||
|       raise OsmosisError.new $?, "osmosis exited with code #{$?.exitstatus}" | ||||
|     end | ||||
|     log '', :preprocess | ||||
|   end | ||||
| @ -197,28 +197,17 @@ 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 | ||||
|         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"  | ||||
|         raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}." | ||||
|       end | ||||
|       log '', :preprocess | ||||
|     end | ||||
| @ -227,8 +216,7 @@ 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 | ||||
|         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"  | ||||
|         raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}." | ||||
|       end  | ||||
|       log '', :preprocess | ||||
|     end | ||||
|  | ||||
| @ -1,14 +1,49 @@ | ||||
| 
 | ||||
| class OSRMError < StandardError | ||||
|   attr_accessor :process, :code, :msg | ||||
|   attr_accessor :msg, :code, :process | ||||
| 
 | ||||
|   def initialize process, code, msg | ||||
|   def initialize process, code, msg, log, lines | ||||
|     @process = process | ||||
|     @code = code | ||||
|     @msg = msg | ||||
|     @lines = lines | ||||
|     @log = log | ||||
|     @extract = log_tail @log, @lines | ||||
|   end | ||||
|    | ||||
|   def to_s | ||||
|     @msg | ||||
|     "*** #{@msg}\nLast #{@lines} lines from #{@log}:\n#{@extract}\n" | ||||
|   end | ||||
|    | ||||
|   private | ||||
|    | ||||
|   def log_tail path, n | ||||
|     File.open(path) do |f| | ||||
|       return f.tail(n).map { |line| "  > #{line}" }.join "\n" | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class OsmosisError < OSRMError | ||||
|   def initialize code, msg | ||||
|     super 'osmosis', code, msg, PREPROCESS_LOG_FILE, 40 | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class ExtractError < OSRMError | ||||
|   def initialize code, msg | ||||
|     super 'osrm-extract', code, msg, PREPROCESS_LOG_FILE, 3 | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class PrepareError < OSRMError | ||||
|   def initialize code, msg | ||||
|     super 'osrm-prepare', code, msg, PREPROCESS_LOG_FILE, 3 | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class RoutedError < OSRMError | ||||
|   def initialize msg | ||||
|     super 'osrm-routed', nil, msg, OSRM_ROUTED_LOG_FILE, 3 | ||||
|   end | ||||
| end | ||||
| @ -3,6 +3,7 @@ require 'open3' | ||||
| 
 | ||||
| LAUNCH_TIMEOUT = 2 | ||||
| SHUTDOWN_TIMEOUT = 2 | ||||
| OSRM_ROUTED_LOG_FILE = 'osrm-routed.log' | ||||
| 
 | ||||
| class OSRMLauncher | ||||
|   def initialize &block | ||||
| @ -24,7 +25,7 @@ class OSRMLauncher | ||||
|       wait_for_connection | ||||
|     end | ||||
|   rescue Timeout::Error | ||||
|     raise "*** Launching osrm-routed timed out." | ||||
|     raise RoutedError.new "Launching osrm-routed timed out." | ||||
|   end | ||||
|    | ||||
|   def shutdown | ||||
| @ -33,7 +34,7 @@ class OSRMLauncher | ||||
|     end | ||||
|   rescue Timeout::Error | ||||
|     kill | ||||
|     raise "*** Shutting down osrm-routed timed out." | ||||
|     raise RoutedError.new "Shutting down osrm-routed timed out." | ||||
|   end | ||||
|    | ||||
|    | ||||
| @ -47,7 +48,7 @@ class OSRMLauncher | ||||
| 
 | ||||
|   def osrm_up | ||||
|     return if osrm_up? | ||||
|     @pid = Process.spawn(['../osrm-routed',''],:out=>'osrm-routed.log', :err=>'osrm-routed.log') | ||||
|     @pid = Process.spawn(['../osrm-routed',''],:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE) | ||||
|   end | ||||
| 
 | ||||
|   def osrm_down | ||||
|  | ||||
| @ -7,7 +7,6 @@ DESTINATION_REACHED = 15      #OSRM instruction code | ||||
| 
 | ||||
| def request_path path | ||||
|   @query = path | ||||
|   log path | ||||
|   uri = URI.parse "#{HOST}/#{path}" | ||||
|   Timeout.timeout(REQUEST_TIMEOUT) do | ||||
|     Net::HTTP.get_response uri | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user