From 85b5c817b0c86d5e916212c894d4d5843199f909 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Thu, 8 Oct 2020 09:24:43 +0100 Subject: [PATCH] =?UTF-8?q?Nasal:=20use=20=E2=80=98quiet=E2=80=99=20flag?= =?UTF-8?q?=20when=20loading=20jetways.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid console spam from probing for jetways files every ten seconds --- Nasal/io.nas | 21 ++++++++++++++++++--- Nasal/jetways/jetways.nas | 11 ++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Nasal/io.nas b/Nasal/io.nas index 60f541ff2..a39162578 100644 --- a/Nasal/io.nas +++ b/Nasal/io.nas @@ -34,6 +34,11 @@ var is_regular_file = func(path) { else return 0; }; +var exists = func(path) { + var tmp = stat(path); + return tmp != nil; +}; + # the path that should be searched for subdirectories # returns a vector of subdirectory names var subdirectories = func(path) { @@ -132,7 +137,7 @@ var load_nasal = func(file, module = nil) { # are returned as a separate props.Node tree. Returns the data as a # props.Node on success or nil on error. # -# Usage: io.read_properties( [, ]); +# Usage: io.read_properties( [, , ]); # # Examples: # @@ -142,7 +147,7 @@ var load_nasal = func(file, module = nil) { # var data = io.read_properties("/tmp/foo.xml", "/sim/model"); # var data = io.read_properties("/tmp/foo.xml"); # -var read_properties = func(path, target = nil) { +var read_properties = func(path, target = nil, quiet = 0) { var args = props.Node.new({ filename: path }); if (target == nil) { var ret = args.getNode("data", 1); @@ -153,6 +158,11 @@ var read_properties = func(path, target = nil) { args.getNode("targetnode", 1).setValue(target); var ret = props.globals.getNode(target, 1); } + + # set the quiet flag if requested + if (quiet) + args.getNode("quiet", 1).setValue(1); + return fgcommand("loadxml", args) ? ret : nil; } @@ -170,7 +180,7 @@ var read_properties = func(path, target = nil) { # # var data = io.read_properties("KSFO", "rwyuse"); # -var read_airport_properties = func(icao, fname, target = nil) { +var read_airport_properties = func(icao, fname, target = nil, quiet = 0) { var args = props.Node.new({ filename: fname, icao:icao }); if (target == nil) { var ret = args.getNode("data", 1); @@ -181,6 +191,11 @@ var read_airport_properties = func(icao, fname, target = nil) { args.getNode("targetnode", 1).setValue(target); var ret = props.globals.getNode(target, 1); } + + # set the quiet flag if requested + if (quiet) + args.getNode("quiet", 1).setValue(1); + return fgcommand("loadxml", args) ? ret : nil; } diff --git a/Nasal/jetways/jetways.nas b/Nasal/jetways/jetways.nas index 0a195861c..5b5a6b968 100644 --- a/Nasal/jetways/jetways.nas +++ b/Nasal/jetways/jetways.nas @@ -712,12 +712,17 @@ var toggle_jetway_from_model = func(model) var load_airport_jetways = func(airport) { if (isin(loaded_airports, airport)) return; - var tree = io.read_airport_properties(airport, "jetways"); + var tree = io.read_airport_properties(airport, "jetways", nil, 1); if (tree == nil) { - tree = io.read_properties(root ~ "/AI/Airports/" ~ airport ~ "/jetways.xml"); - if (tree == nil) return; + var aiPath = root ~ "/AI/Airports/" ~ airport ~ "/jetways.xml"; + if (io.exists(aiPath)) { + tree = io.read_properties(aiPath, nil, 1); + } + + if (tree == nil) return; } + append(loaded_airports, airport); print_debug("Loading jetways for airport " ~ airport); var nodes = tree.getChildren("jetway");