Example #1
0
def MotionNotify(config_file_path,notify):
    config = ConfigParser.ConfigParser()
    config.read(config_file_path)
    logfile = config.get('log', 'logfile')
    logger = logit(logfile)
    logger.info("Config file read - log initialized ")
    # mail account credentials
    username = config.get('mail', 'user')
    password = config.get('mail', 'password')
    from_name = config.get('mail', 'name')
    sender = config.get('mail', 'sender')
    mailServ = config.get('mail','server')
    smtp =     config.get('mail', 'port')
    print 'config read'
    # Recipient email address (could be same as from_addr)
    recipient = config.get('mail', 'recipient')

    # Subject line for email
    subject = config.get('mail', 'subject')

    # First line of email message
    message = config.get('mail', 'message')

    # Folder (or collection) in Docs where you want the media to go
    folder = config.get('docs', 'folder')

    # Options
    delete_files = config.getboolean('options', 'delete-files')
    send_email = config.getboolean('options', 'send-email')
    event_started_message = config.get('mail', 'event_started_message')
    
    presenceMacs = []
    network = None
    
    ip_addresses = None
    

    
    try:
        forceOnStart = config.getint( 'activate-system', 'force_on_start' )
        forceOnEnd = config.getint( 'activate-system', 'force_on_end' )
    except ConfigParser.NoSectionError, ConfigParser.NoOptionError:
        pass
Example #2
0
            logger.info( 'Based on network presence should the email be sent %s', active )
            return active
    
    
##   Thats all she wrote ...     
    if  notify or system_active() :
        msg = event_started_message
        send_email(msg)
        logger.info('msg sent')
    else:
        logger.info('somebody home')


if __name__ == '__main__':
    if sys.platform == 'win32':
        cwcfg = r'/Users/charles/data/cwtest/motion/notify/motion-notify.cfg'
        print cwcfg
        sys.argv = ['cw_notify.py', cwcfg, 1]
        logger = logit('notify.log')
       
    cfg_path = sys.argv[1]   # motion-notify on Git
    notify = True    

    if not os.path.exists(cfg_path):
        print('Config file does not exist [%s]' % cfg_path)
    MotionNotify(cfg_path,notify) 
  #  logger.info('main cw-notify done\n')