<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
Under some circumstances, wpkg.js tries to parse non-existing .xml
files, and writes an "ERROR" into the log file. This is misleading
in situations where it is normal that the file does not exist.<br>
<br>
For example, when using a "packages" directory of .xml files instead
of a single packages.xml file, wpkg.js still tries to parse the
non-existing packages.xml.<br>
<br>
I have a cron job parsing the log files for "ERROR"s, and now it
prints these for every reboot of every machine, because the log
contains:<br>
<br>
<tt>2012-02-23 15:13:33, DEBUG : Reading XML file:
//192.168.44.1/install/wpkg/packages/twixtel.xml
<br>
2012-02-23 15:13:33, DEBUG : Reading XML file:
//192.168.44.1/install/wpkg/packages/user-settings.xml
<br>
2012-02-23 15:13:33, DEBUG : Reading XML file:
//192.168.44.1/install/wpkg/packages.xml
<br>
2012-02-23 15:13:33, <b>ERROR : Error parsing xml
'//192.168.44.1/install/wpkg/packages.xml</b>': Das Stylesheet
enth▒lt kein Dokumentelement. [... etc.]<br>
2012-02-23 15:13:33, <b>ERROR : No root element found in
'//192.168.44.1/install/wpkg/packages.xml'</b>.
<br>
</tt><br>
For now, I patched loadXml() to only try to load the xml if the file
actually exists. Otherwise, print debug info and skip it. Now I have
this in the log, which seems better:<br>
<br>
<tt>2012-02-23 21:00:29, DEBUG : Reading XML file:
//192.168.44.1/install/wpkg/packages/twixtel.xml<br>
2012-02-23 21:00:29, DEBUG : Reading XML file:
//192.168.44.1/install/wpkg/packages/user-settings.xml<br>
2012-02-23 21:00:29, <b>DEBUG : Skipping non-existing XML file:
//192.168.44.1/install/wpkg/packages.xml</b><br>
</tt><br>
<br>
This is the change I did to wpkg.js version 1.3.0:<br>
<br>
====================================<br>
<br>
<big><tt>$ diff -u wpkg.js.orig wpkg.js<br>
--- wpkg.js.orig 2011-12-08 15:03:24.000000000 +0100<br>
+++ wpkg.js 2012-02-23 20:40:14.000000000 +0100<br>
@@ -7740,7 +7740,14 @@<br>
<br>
for( var i=0; i < filePaths.length; i++) {<br>
var filePath = filePaths[i];<br>
- dinfo("Reading XML file: " + filePath);<br>
+ var fso = new
ActiveXObject("Scripting.FileSystemObject")<br>
+ if (fso.FileExists(filePath)) {<br>
+ dinfo("Reading XML file: " + filePath);<br>
+ } else {<br>
+ dinfo("Skipping non-existing XML file: " +
filePath);<br>
+ continue;<br>
+ }<br>
+<br>
<br>
// Read XML file from file system.<br>
var xsl = new ActiveXObject("Msxml2.DOMDocument.3.0");<br>
</tt></big><br>
====================================<br>
<br>
Maybe the line<br>
<br>
<tt> <big>var fso = new
ActiveXObject("Scripting.FileSystemObject")</big></tt><br>
<br>
should be moved before the for loop for efficiency?<br>
<br>
<br>
</body>
</html>