1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3 4__author__ = 'Tobias Brunner <tobias()tobru.ch>' 5__copyright__ = 'Copyright 2016 Tobias Brunner' 6__license__ = """Eclipse Public License - v 1.0 (http://www.eclipse.org/legal/epl-v10.html)""" 7 8import subprocess 9 10def plugin(srv, item): 11 12 srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target) 13 14 config = item.config 15 if type(config) == dict and 'text_replace' in config: 16 replace = config['text_replace'] 17 else: 18 replace = '[TEXT]' 19 20 text = item.message 21 cmd = [i.replace(replace, text) for i in item.addrs] 22 23 try: 24 res = subprocess.check_output(cmd, stdin=None, stderr=subprocess.STDOUT, shell=False, universal_newlines=True, cwd='/tmp') 25 except Exception as e: 26 srv.logging.warning("Cannot execute %s because %s" % (cmd, e)) 27 return False 28 29 return True 30