예제 #1
0
        if o in ('-h', '--help'):
            print help()
            sys.exit(0)
        elif o in ('-d', '--debug'):
            #debug_level = logging.DEBUG
            pass
        elif o in ('-c', '--config-file'):
            config_file = a
        elif o in ('-t', '--test'):
            test_match = True
    
    if not os.path.exists(config_file):
        raise ConfigError("%s not found" % config_file)
    
    smsfile = args[0]
    if not os.path.exists(smsfile):
        raise Exception("Can't find smsfile %s" % smsfile)
    print config_file, smsfile
    x = SmsReader(config_file, smsfile)
    x.run()

if __name__ == '__main__':
    smsfile = '-'
    log = get_logger("smshandler")
    try:
        main()
    except Exception, e:
        log.error('Exception processing "%s": %s' % (smsfile, e))
        raise
else:
    log = get_logger("smshandler")
예제 #2
0
            config_file = a
        elif o in ('-t', '--test'):
            test_mode = True
    
    if not os.path.exists(config_file):
        raise ConfigError("%s not found" % config_file)
    
    pidfile = 'email.pid'
    if not cmp(action, 'stop') or not cmp(action, 'restart'):
        for elem in stopd(pidfile):
            log.error(elem)
        if not cmp(action, 'restart'):
            action = 'start'
    if not cmp(action, 'start'):
        x = EmailReader(config_file)
        log.info("Daemon PID %d" % startd(pidfile))
        if test_mode:
            x.test_mode()
        else:
            x.run()

if __name__ == '__main__':
    smsfile = '-'
    log = get_logger("emailhandler")
    try:
        main()
    except Exception, e:
        log.error('Exception processing "%s": %s' % (smsfile, e))
        raise
else:
    log = get_logger("emailhandler")
예제 #3
0
            pass#debug_level = logging.DEBUG
        elif o in ('-c', '--config-file'):
            config_file = a
        elif o in ('-t', '--test'):
            test_match = True
            return
    
    if not os.path.exists(config_file):
        raise ConfigError("%s not found" % config_file)
    
    pidfile = 'mh2triage.pid'
    if not cmp(action, 'stop') or not cmp(action, 'restart'):
        for elem in stopd(pidfile):
            log.error(elem)
        if not cmp(action, 'restart'):
            action = 'start'
    if not cmp(action, 'start'):
        x = MsgProcess(config_file)
        log.info("Daemon PID %d" % startd(pidfile))
        x.run()

if __name__ == '__main__':
    smsfile = '-'
    log = get_logger("mh2triage")
    try:
        main()
    except Exception, e:
        log.error('Exception processing "%s": %s' % (smsfile, e))
        raise
else:
    log = get_logger("mh2triage")
예제 #4
0
        
        return (contact, dict(headers), text_content, dict(attachments))
    
    def _dict_to_lists(self, elems):
        """Convert values of dictionary into binary and return a tuple."""
        keys = list()
        values = list()
        for (key, value) in elems.items():
            keys.append(key.lower())
            values.append(value)
        return (keys, values)

    def _parse_headers(self, val, sep=':'):
        """Parse header fields and values and return as tuple."""
        x = val.partition(sep)
        return (x[0].capitalize(), x[2])
    
    def _generate_attachments(self, num, elems):
        """Extract attachment names and contents from a list and return a list of name-content pairs."""
        res = list()
        for index in range(0, num*2, 2):
            name = elems[index]
            cont = binascii.a2b_base64(elems[index+1])
            res.append((name, cont))
        return res

if __name__ == '__main__':
    print 'This script is not meant to be run from command line'
    log = get_logger("mhlink")
else:
    log = get_logger("mhlink")
예제 #5
0
            pass#debug_level = logging.DEBUG
        elif o in ('-c', '--config-file'):
            config_file = a
        elif o in ('-t', '--test'):
            test_match = True
            return
    
    if not os.path.exists(config_file):
        raise ConfigError("%s not found" % config_file)
    
    pidfile = 'triage2mh.pid'
    if not cmp(action, 'stop') or not cmp(action, 'restart'):
        for elem in stopd(pidfile):
            log.error(elem)
        if not cmp(action, 'restart'):
            action = 'start'
    if not cmp(action, 'start'):
        x = MsgGenerator(config_file)
        log.info("Daemon PID %d" % startd(pidfile))
        x.run()

if __name__ == '__main__':
    smsfile = '-'
    log = get_logger("triage2mh")
    try:
        main()
    except Exception, e:
        log.error('Exception processing "%s": %s' % (smsfile, e))
        raise
else:
    log = get_logger("triage2mh")