Пример #1
0
    def post(self):
        from esphome import wizard

        kwargs = {k: ''.join(v) for k, v in self.request.arguments.items()}
        destination = os.path.join(CONFIG_DIR, kwargs['name'] + '.yaml')
        wizard.wizard_write(path=destination, **kwargs)
        self.redirect('/?begin=True')
Пример #2
0
    def post(self):
        from esphome import wizard

        kwargs = {
            k: "".join(x.decode() for x in v) for k, v in self.request.arguments.items()
        }
        destination = settings.rel_path(kwargs["name"] + ".yaml")
        wizard.wizard_write(path=destination, **kwargs)
        self.redirect("./?begin=True")
Пример #3
0
    def post(self):
        from esphome import wizard

        kwargs = {
            k: u''.join(decode_text(x) for x in v)
            for k, v in self.request.arguments.items()
        }
        destination = settings.rel_path(kwargs['name'] + u'.yaml')
        wizard.wizard_write(path=destination, **kwargs)
        self.redirect('./?begin=True')
Пример #4
0
    def post(self):
        from esphome import wizard

        kwargs = {
            k: "".join(x.decode() for x in v)
            for k, v in self.request.arguments.items()
            if k in ("name", "platform", "board", "ssid", "psk", "password")
        }
        kwargs["ota_password"] = secrets.token_hex(16)
        destination = settings.rel_path(kwargs["name"] + ".yaml")
        wizard.wizard_write(path=destination, **kwargs)
        self.set_status(200)
        self.finish()
Пример #5
0
    def post(self):
        from esphome import wizard

        kwargs = {
            k: v
            for k, v in json.loads(self.request.body.decode()).items()
            if k in ("name", "platform", "board", "ssid", "psk", "password")
        }
        kwargs["ota_password"] = secrets.token_hex(16)
        destination = settings.rel_path(f"{kwargs['name']}.yaml")
        wizard.wizard_write(path=destination, **kwargs)
        self.set_status(200)
        self.finish()
Пример #6
0
def test_wizard_write_sets_platform(default_config, tmp_path, monkeypatch):
    """
    If the platform is not explicitly set, use "ESP8266" if the board is one of the ESP8266 boards
    """
    # Given
    monkeypatch.setattr(wz, "write_file", MagicMock())

    # When
    wz.wizard_write(tmp_path, **default_config)

    # Then
    generated_config = wz.write_file.call_args.args[1]
    assert f"platform: {default_config['platform']}" in generated_config
Пример #7
0
def test_wizard_write_defaults_platform_from_board_esp32(
        default_config, tmp_path, monkeypatch):
    """
    If the platform is not explicitly set, use "ESP32" if the board is not one of the ESP8266 boards
    """
    # Given
    del default_config["platform"]
    default_config["board"] = "foo"

    monkeypatch.setattr(wz, "write_file", MagicMock())

    # When
    wz.wizard_write(tmp_path, **default_config)

    # Then
    generated_config = wz.write_file.call_args.args[1]
    assert "esp32:" in generated_config