Beispiel #1
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import argparse, ConfigParser, sys
from lib.NodoMapper import NodoMapper

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Ejecucion de nodo mapper.')
    parser.add_argument('host', help='IP del host donde brinda servicio.')
    parser.add_argument('port', type=int, help='Puerto donde brinda servicio.')    
    args = parser.parse_args(sys.argv[1:])

    config_parser = ConfigParser.SafeConfigParser()
    config_parser.read('config.ini')
    
    #recuperamos configuraciones
    #nodo reducer
    reducer = [config_parser.get('reducer', 'host'), config_parser.getint('reducer', 'port')]

    mapper = NodoMapper(args.host, args.port, reducer)
    mapper.iniciar_server()
Beispiel #2
0
    # configuro el logging
    if config_parser.get('logging', 'log_enabled'):
        logging.basicConfig(
            format=LOG_FORMAT, level=logging.DEBUG,
            filename=config_parser.get('logging', 'log_file'),
            datefmt='%d-%m %H:%M', filemode='w')
        # si verbose está activo, mostrar la información por pantalla
        if args.verbose:
            console = logging.StreamHandler()
            console.setLevel(logging.DEBUG)
            formatter = logging.Formatter(LOG_CONSOLE_FORMAT)
            console.setFormatter(formatter)
            logging.getLogger('').addHandler(console)
    else:
        if args.verbose:
            level = logging.DEBUG
        else:
            level = logging.WARNING
        logging.basicConfig(
            format=LOG_FORMAT, datefmt='%d-%m %H:%M', level=level)

    # correr nodo
    mapper = NodoMapper(
        config_parser.get('connection', 'host'),
        config_parser.getint('connection', 'port'),
        (config_parser.get('reducer', 'host'),
         config_parser.getint('reducer', 'port')))
    mapper.start()
    mapper.stop()