コード例 #1
0
def run(arguments=[]):
    """Start a broker instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    _ioloop = tornado.ioloop.IOLoop.current()
    app = BrokerApplication(keys, options=options)
    _server = app.listen(options.port)

    signal.signal(signal.SIGTERM, partial(sig_handler, _server))
    signal.signal(signal.SIGINT, partial(sig_handler, _server))

    _ioloop.start()
    logger.debug("Application stopped")
コード例 #2
0
def run(arguments=[]):
    """Start the CoAP gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    try:
        parse_command_line()
    except SyntaxError as e:
        logger.critical("Invalid config file: {}".format(e))
        return
    except FileNotFoundError as e:
        logger.error("Config file not found: {}".format(e))
        return

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    if not tornado.platform.asyncio.AsyncIOMainLoop().initialized():
        tornado.platform.asyncio.AsyncIOMainLoop().install()

    start_application(CoapGateway(keys, options=options),
                      port=options.coap_port, close_client=True)
コード例 #3
0
ファイル: gateway.py プロジェクト: forksbot/pyaiot
def run(arguments=[]):
    """Start the CoAP gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)
        logging.getLogger("pyaiot.gw.client").setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    try:
        # Application ioloop initialization
        if not tornado.platform.asyncio.AsyncIOMainLoop().initialized():
            tornado.platform.asyncio.AsyncIOMainLoop().install()

        # Initialize the gateway application
        CoapGatewayApplication(keys, options=options)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logger.debug("Stopping application")
        tornado.ioloop.IOLoop.instance().stop()
コード例 #4
0
ファイル: application.py プロジェクト: bergzand/pyaiot
def run(arguments=[]):
    """Start the websocket gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    try:
        parse_command_line()
    except SyntaxError as e:
        logger.error("Invalid config file: {}".format(e))
        return
    except FileNotFoundError as e:
        logger.error("Config file not found: {}".format(e))
        return

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    start_application(WebsocketGateway(keys, options=options),
                      port=options.gateway_port,
                      close_client=True)
コード例 #5
0
ファイル: broker.py プロジェクト: rfuentess/pyaiot
def run(arguments=[]):
    """Start a broker instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as exc:
        logger.error(exc)
        return

    start_application(BrokerApplication(keys, options=options),
                      port=options.port)
コード例 #6
0
ファイル: gateway.py プロジェクト: rfuentess/pyaiot
def run(arguments=[]):
    """Start the websocket gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    start_application(WebsocketGatewayApplication(keys, options=options),
                      port=options.gateway_port,
                      close_client=True)
コード例 #7
0
ファイル: application.py プロジェクト: fjmolinas/pyaiot
def run(arguments=[]):
    """Start the CoAP gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments
    try:
        parse_command_line(extra_args_func=extra_args)
    except SyntaxError as exc:
        logger.error("Invalid config file: {}".format(exc))
        return
    except FileNotFoundError as exc:
        logger.error("Config file not found: {}".format(exc))
        return

    try:
        keys = check_key_file(options.key_file)
    except ValueError as exc:
        logger.error(exc)
        return

    start_application(MQTTGateway(keys, options=options),
                      close_client=True)
コード例 #8
0
def run(arguments=[]):
    """Start a broker instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    try:
        parse_command_line()
    except SyntaxError as exc:
        logger.error("Invalid config file: {}".format(exc))
        return
    except FileNotFoundError as exc:
        logger.error("Config file not found: {}".format(exc))
        return

    try:
        keys = check_key_file(options.key_file)
    except ValueError as exc:
        logger.error(exc)
        return

    start_application(Broker(keys, options=options), port=options.broker_port)
コード例 #9
0
def run(arguments=[]):
    """Start the CoAP gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    # Application ioloop initialization
    if not tornado.platform.asyncio.AsyncIOMainLoop().initialized():
        tornado.platform.asyncio.AsyncIOMainLoop().install()

    start_application(MQTTGatewayApplication(keys, options=options),
                      close_client=True)
コード例 #10
0
ファイル: application.py プロジェクト: cgundogan/pyaiot
def run(arguments=[]):
    """Start the CoAP gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments
    try:
        parse_command_line(extra_args_func=extra_args)
    except SyntaxError as exc:
        logger.error("Invalid config file: {}".format(exc))
        return
    except FileNotFoundError as exc:
        logger.error("Config file not found: {}".format(exc))
        return

    try:
        keys = check_key_file(options.key_file)
    except ValueError as exc:
        logger.error(exc)
        return

    # Application ioloop initialization
    if not tornado.platform.asyncio.AsyncIOMainLoop().initialized():
        tornado.platform.asyncio.AsyncIOMainLoop().install()

    start_application(MQTTGateway(keys, options=options), close_client=True)
コード例 #11
0
def run(arguments=[]):
    """Start the websocket gateway instance."""
    if arguments != []:
        sys.argv[1:] = arguments

    parse_command_line()

    if options.debug:
        logger.setLevel(logging.DEBUG)

    try:
        keys = check_key_file(options.key_file)
    except ValueError as e:
        logger.error(e)
        return

    try:
        # Initialize the websocket gateway application
        app = WebsocketGatewayApplication(keys, options=options)
        app.listen(options.gateway_port)
        ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logger.debug("Stopping application")
        ioloop.IOLoop.instance().stop()