Exemplo n.º 1
0
def main():
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    if '--debug' in sys.argv:
        logging.basicConfig(level=logging.DEBUG)

    logger = logging.getLogger()
    settings.from_files(cfg='yaml', verbose=True)
    settings.from_args(sys.argv[1:])
    if settings.prometheus:
        start_http_server(settings.prometheus_port)

    b = Board(settings)
    http = HTTPThread(b, settings)
    http.start()
    for file in get_files(settings.yaml_directory, 'yaml'):
        sound_set = SoundSet.from_yaml(file, settings=settings)
        b.register_sound_set(sound_set)

    joystick = Joystick(settings.device_path, backend=settings.input_type,
                        mapping=settings.physical_mapping,
                        offset=settings.scancode_offset)

    b.register_joystick(joystick)
    http_joystick = Joystick(http.queue, backend='queue')
    b.register_joystick(http_joystick)
    b.run()
Exemplo n.º 2
0
def main():
    os.environ["SDL_VIDEODRIVER"] = "dummy"
    if "--debug" in sys.argv:
        logging.basicConfig(level=logging.DEBUG)

    settings.from_files(cfg="yaml", verbose=True)
    settings.from_args(sys.argv[1:])
    if settings.prometheus:
        start_http_server(settings.prometheus_port)

    board = Board(settings)
    for file in Path(settings.yaml_directory).glob("*.yaml"):
        board.register_sound_set(yamlfile=file)

    if settings.http:
        setup_http(board)

    if settings.device_path:
        joystick = Joystick(
            settings.device_path,
            backend=settings.input_type,
            offset=settings.scancode_offset,
        )

        board.register_joystick(joystick)
    else:
        logger.warning("no hardware soundboard")

    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    proto_pb2_grpc.add_SoundboardServicer_to_server(
        SoundboardServicer(board), server,
    )
    reflection.enable_server_reflection(
        (
            "soundboard.Soundboard",
            reflection.SERVICE_NAME,
        ), server,
    )
    server.add_insecure_port('[::]:50051')
    server.start()

    if settings.mqtt:
        mqtt = MQTT(
            path=settings.mqtt_path,
            login=settings.mqtt_login,
            password=settings.mqtt_password,
        )
        mqtt.add_topic_handler(MQTT_TOPIC_DANK, board.on_dankness)
        setup_mqtt_controller(board, mqtt)
    board.run()
Exemplo n.º 3
0
def main():
    logger = logging.getLogger()
    settings.from_args(sys.argv[1:])

    if settings.debug:
        logger.setLevel(logging.DEBUG)
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    b = Board()
    for file in get_files(settings.yaml_directory, 'yaml'):
        sound_set = SoundSet.from_yaml(file, settings=settings)
        b.register_sound_set(sound_set)

    joystick = Joystick(settings.device_path, backend=settings.input_type,
                        mapping=settings.physical_mapping,
                        offset=settings.scancode_offset)

    b.register_joystick(joystick)
    b.run()