summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolargo <nicolas@nicolargo.com>2015-01-03 17:46:14 +0100
committerNicolargo <nicolas@nicolargo.com>2015-01-03 17:46:14 +0100
commitf58e7ef95ef8de7748bf95b367fa1b5d6623c8d0 (patch)
treedbf80fdbd355854d4856593b0339be586cbe22aa
parent0a99364c9f4a04bcdd6fb086b3f617836e6c0643 (diff)
PyStache is not mandatory
-rw-r--r--glances/core/glances_actions.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/glances/core/glances_actions.py b/glances/core/glances_actions.py
index 6069e0e8..ee29fd61 100644
--- a/glances/core/glances_actions.py
+++ b/glances/core/glances_actions.py
@@ -19,13 +19,19 @@
"""Manage on alert actions."""
-# Import system lib
-from subprocess import Popen
-import pystache
-
# Import Glances lib
from glances.core.glances_logging import logger
+# Import system lib
+from subprocess import Popen
+try:
+ import pystache
+except ImportError:
+ logger.warning("PyStache lib not installed (action script with mustache will not work)")
+ pystache_tag = False
+else:
+ pystache_tag = True
+
class GlancesActions(object):
@@ -67,7 +73,10 @@ class GlancesActions(object):
# Ran all actions in background
for cmd in commands:
# Replace {{arg}} by the dict one (Thk to {Mustache})
- cmd_full = pystache.render(cmd, mustache_dict)
+ if pystache_tag:
+ cmd_full = pystache.render(cmd, mustache_dict)
+ else:
+ cmd_full = cmd
# Execute the action
logger.info("Action triggered for {0} ({1}): {2}".format(stat_name, criticity, cmd_full))
logger.debug("Stats value for the trigger: {0}".format(mustache_dict))