示例#1
0
文件: cli.py 项目: j3tm0t0/fauxmo
def cli() -> None:
    """Parse command line options, provide entry point for console scripts."""
    arguments = sys.argv[1:]
    parser = argparse.ArgumentParser(
        description="Emulate Belkin Wemo devices " "for use with Amaazon Echo"
    )
    parser.add_argument(
        "-v",
        "--verbose",
        help="increase verbosity (may " "repeat up to -vvv)",
        action="count",
        default=0,
    )
    parser.add_argument("-c", "--config", help="specify alternate config file")
    parser.add_argument(
        "-V", "--version", action="version", version=__version__
    )
    args = parser.parse_args(arguments)

    # args.verbose defaults to 0
    # 40 - 10 * 0 = 40 == logging.ERROR
    verbosity = max(40 - 10 * args.verbose, 10)
    logger.setLevel(verbosity)

    main(config_path_str=args.config, verbosity=verbosity)
示例#2
0
def test_old_config_fails() -> None:
    """Ensure the config for fauxmo < v0.4.0 fails with SystemExit."""
    with pytest.raises(SystemExit):
        fauxmo.main(config_path_str="tests/old-config-sample.json")
示例#3
0
    def open_netflix(self):
        self.client.connect()
        self.client.exec_command('startApp', {'appid': 'netflix'})
        sleep(5)
        self.client.run_forever()

    def close_netflix(self):
        self.client.connect()
        self.client.exec_command('closeApp', {'appid': 'netflix'})
        sleep(5)
        self.client.run_forever()

    def channel_up(self):
        self.client.connect()
        self.client.exec_command('inputChannelUp', {})
        sleep(5)
        self.client.run_forever()

    def channel_down(self):
        self.client.connect()
        self.client.exec_command('inputChannelDown', {})
        sleep(5)
        self.client.run_forever()


if __name__ == '__main__':
    if len(sys.argv) > 1:
        # means we want to setup
        alexa = AlexaLG(True)
    fauxmo.main('./Alexa/config.json')