Module: check_mk
Branch: master
Commit: 73b24b13fc5a813db268ef4c9dae7cdabe6416fc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=73b24b13fc5a81…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Apr 18 15:04:35 2012 +0200
Multisite: allow byte compiled *.pyc files
---
ChangeLog | 5 +++++
web/htdocs/lib.py | 10 ++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 522e9de..00fac6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1.2.0b3:
+ Multisite:
+ * FIX: allow web plugins to be byte compiled (*.pyc). Those
+ are preferred over *.py if existing
+
1.2.0b2:
Core:
* FIX: Cluster host checks were UNKNOWN all the time
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 0f07142..4ad5246 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-import grp, defaults, pprint, os, errno, gettext, __builtin__
+import grp, defaults, pprint, os, errno, gettext, marshal, __builtin__
nagios_state_names = { -1: "NODATA", 0: "OK", 1: "WARNING",
2: "CRITICAL", 3: "UNKNOWN", 4: "DEPENDENT" }
nagios_short_state_names = { -1: "PEND", 0: "OK", 1:
"WARN", 2: "CRIT", 3: "UNKN", 4: "DEP" }
@@ -124,8 +124,14 @@ def load_web_plugins(forwhat, globalvars):
fns = os.listdir(plugins_path)
fns.sort()
for fn in fns:
+ file_path = plugins_path + "/" + fn
if fn.endswith(".py"):
- execfile(plugins_path + "/" + fn, globalvars)
+ if not os.path.exists(file_path + "c"):
+ execfile(file_path, globalvars)
+ elif fn.endswith(".pyc"):
+ code_bytes = file(file_path).read()[8:]
+ code = marshal.loads(code_bytes)
+ exec code in globalvars
if defaults.omd_root:
local_plugins_path = defaults.omd_root +
"/local/share/check_mk/web/plugins/" + forwhat