Hello,
Reading wpkg.js I saw how logFilePattern is expanded and I think this
treatment can be applied to more variables.
For example:
- wpkg_base = http://www.mydomaine.tld/wpkg/
- web_packages_file_name = packages/[HOSTNAME].xml
- web_profiles_file_name = profiles/[HOSTNAME].xml
- web_hosts_file_name = hosts/[HOSTNAME].xml
So, instead of loading maybe "huge" XML files, the web service can
restrict them for the host only.
This may avoid the use of profiles and hosts files if the web service
handle the profiles management and packages dependencies and hide them
to the client.
So http://www.mydomaine.tld/wpkg/[HOSTNAME].xml can be just ready to
be used.
I provide a little diff which define an expandVariable function and
use it in web parts. This is not tested, just to clarify my point.
Regards.
--
Daniel Dehennin
RAIP de l'Orne
=== modified file 'wpkg.js'
--- wpkg.js 2008-10-21 07:56:40 +0000
+++ wpkg.js 2008-10-21 08:38:44 +0000
@@ -4718,9 +4718,9 @@
// load packages
setPackages(loadXml(packages_file, packages_folder, "packages"));
} else {
- var packages_file = base + "/" + web_packages_file_name;
- var profiles_file = base + "/" + web_profiles_file_name;
- var hosts_file = base + "/" + web_hosts_file_name;
+ var packages_file = base + "/" + expandVariable(web_packages_file_name);
+ var profiles_file = base + "/" + expandVariable(web_profiles_file_name);
+ var hosts_file = base + "/" + expandVariable(web_hosts_file_name);
var nodes = loadXml( profiles_file, null, null );
if (nodes == null) {
// connot continue without profiles (probably network error occurred)
@@ -6294,3 +6294,47 @@
}
return ret;
}
+
+/**
+ * expandVariable - expand shell variable and WPKG regexp
+ * @param variable to expand
+ * @return expanded variable string
+ */
+function expandVariable(var) {
+ // build log file name
+ var today = new Date();
+ var year = today.getFullYear();
+ var month = today.getMonth() + 1;
+ var day = today.getDate();
+ var hour = today.getHours();
+ var minute = today.getMinutes();
+ var second = today.getSeconds();
+ if (month < 10) {
+ month = "0" + month;
+ }
+ if (day < 10) {
+ day = "0" + day;
+ }
+ if (hour < 10) {
+ hour = "0" + hour;
+ }
+ if (minute < 10) {
+ minute = "0" + minute;
+ }
+ if (second < 10) {
+ second = "0" + second;
+ }
+
+ var expandedVar = var.replace(new RegExp("\\[HOSTNAME\\]", "g"), getHostname());
+ expandedVar = var.replace(new RegExp("\\[YYYY\\]", "g"), year);
+ expandedVar = var.replace(new RegExp("\\[MM\\]", "g"), month);
+ expandedVar = var.replace(new RegExp("\\[DD\\]", "g"), day);
+ expandedVar = var.replace(new RegExp("\\[hh\\]", "g"), hour);
+ expandedVar = var.replace(new RegExp("\\[mm\\]", "g"), minute);
+ expandedVar = var.replace(new RegExp("\\[ss\\]", "g"), second);
+
+ var shell = new ActiveXObject("WScript.Shell");
+ expandedVar = shell.ExpandEnvironmentStrings(expandedVar);
+
+ return expandedVar;
+}
\ No newline at end of file
-------------------------------------------------------------------------
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
_______________________________________________
wpkg-users mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/wpkg-users