def info(self, msg): idx = min(len(stack()), 1) caller = getframeinfo(stack()[idx][0]) zmlog.Info(msg, caller) if (self.dump_console): print('CONSOLE:' + msg)
else: return path+'/snapshot.jpg' # Simple function to read variables from secret file def read_secrets(config='/etc/zm/secrets.ini'): from configparser import ConfigParser secrets_object = ConfigParser(interpolation=None,inline_comment_prefixes='#') secrets_object.optionxform=str zmlog.Debug(1,'eid:{} Reading secrets from {}'.format(eid,config)) with open(config) as f: secrets_object.read_file(f) return secrets_object._sections['secrets'] # -------- MAIN --------------- zmlog.init(name='ftp_selective_upload') zmlog.Info('--------| Selective FTP Plugin v{} |--------'.format(version)) #zmlog.Info ("I got {} arguments".format(len(sys.argv))) #zmlog.Info ("Arguments: {}".format(sys.argv[1:])) if len(sys.argv) != 8: zmlog.Error ('Missing arguments, got {} arguments, was expecting 8: {}'.format(len(sys.argv)-1, sys.argv)) zmlog.close() exit(1) eid = sys.argv[2] mid = sys.argv[3] mname = sys.argv[4] cause = sys.argv[5] image_path = sys.argv[7] fname=get_image(image_path, cause)
''' Author: John Appleseed Contact: <put your github ID here, or a link to your issue tracker> Intended trigger: <put the appropriate ES trigger that should be used for your script, like "event_start_hook", "event_end_hook", "event_start_hook_notify_userscript", "event_end_hook_notify_userscript" or others Description: <add a meaningful description of what your script does> ''' # Arguments: # All scripts invoked with the xxx_userscript tags # get the following args passed # ARG1: Hook result - 0 if object was detected, 1 if not. # Always check this FIRST as the json/text string # will be empty if this is 1 # # ARG2: Event ID # ARG3: Monitor ID # ARG4: Monitor Name # ARG5: object detection string # ARG6: object detection JSON string # ARG7: event path (if hook_pass_image_path is yes) import sys import pyzm.ZMLog as zmlog zmlog.init(name='zmeventnotification_userscript_example') zmlog.Info ("This is a dummy script. Only for your testing. I got {} as arguments".format(sys.argv[1:]))
# Simple function to read variables from secret file def read_secrets(config='/etc/zm/secrets.ini'): from configparser import ConfigParser secrets_object = ConfigParser(interpolation=None, inline_comment_prefixes='#') secrets_object.optionxform = str zmlog.Debug(1, 'eid:{} Reading secrets from {}'.format(eid, config)) with open(config) as f: secrets_object.read_file(f) return secrets_object._sections['secrets'] # -------- MAIN --------------- zmlog.init(name='zmeventnotification_pushapi') zmlog.Info('--------| Pushover Plugin v{} |--------'.format(version)) if len(sys.argv) < 6: zmlog.Error( 'Missing arguments, got {} arguments, was expecting at least 6: {}'. format(len(sys.argv) - 1, sys.argv)) zmlog.close() exit(1) eid = sys.argv[1] mid = sys.argv[2] mname = sys.argv[3] cause = sys.argv[4] event_type = sys.argv[5] image_path = None files = None
def info(self, msg): idx = min(len(stack()), 1) caller = getframeinfo(stack()[idx][0]) zmlog.Info(msg, caller)