示例#1
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as hostapd:
            for k, v in self._config.iteritems():
                hostapd.write("{}={}\n".format(str(k).strip(), str(v).strip()))
示例#2
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as hostapd:
            for k, v in self._config.iteritems():
                hostapd.write("{}={}\n".format(str(k).strip(), str(v).strip()))
示例#3
0
    def write_interfaces(self):
        # Back up the old interfaces file.
        self._backup_interfaces()

        try:
            # Prepare to write the new interfaces file.
            with toolutils.atomic_write(self._interfaces_path) as interfaces:
                self._write_interfaces_to_file(interfaces)
        except:
            # Any error, let's roll back
            self._restore_interfaces()
            raise
示例#4
0
    def write_interfaces(self):
        # Back up the old interfaces file.
        self._backup_interfaces()

        try:
            # Prepare to write the new interfaces file.
            with toolutils.atomic_write(self._interfaces_path) as interfaces:
                self._write_interfaces_to_file(interfaces)
        except:
            # Any error, let's roll back
            self._restore_interfaces()
            raise
示例#5
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as hostapd:
            for k, v in self._config.iteritems():
                key = str(k).strip()
                value = str(v).strip()
                hostapd.write("{0}={1}\n".format(key, value))
示例#6
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as dnsmasq:
            for k, v in self._config.iteritems():
                if k == "dhcp-range":
                    for r in v:
                        dnsmasq.write("dhcp-range=interface:{},{},{},{}\n".format(
                            r["interface"], r["start"], r["end"], r["lease_time"]
                        ))
                else:
                    dnsmasq.write("{}={}\n".format(str(k).strip(), str(v).strip()))
示例#7
0
    def write_interfaces(self):
        # Back up the old interfaces file.
        self._backup_interfaces()

        try:
            # Prepare to write the new interfaces file.
            with toolutils.atomic_write(self._interfaces_path) as interfaces:
                # Loop through the provided networkAdaprers and
                # write the new file.
                for adapter in self._adapters:
                    # Get dict of details about the adapter.
                    self._write_adapter(interfaces, adapter)
            self._check_interfaces(self._interfaces_path)
        except Exception:
            # Any error, let's roll back
            self._restore_interfaces()
            raise
示例#8
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as dnsmasq:
            for k, v in self._config.iteritems():
                if k == "dhcp-range":
                    for r in v:
                        dnsmasq.write(
                            "dhcp-range=interface:{},{},{},{}\n".format(
                                r["interface"], r["start"], r["end"],
                                r["lease_time"]))
                else:
                    dnsmasq.write("{}={}\n".format(
                        str(k).strip(),
                        str(v).strip()))
示例#9
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as dnsmasq:
            for k, v in self._config.iteritems():
                if k == "dhcp-range":
                    if not v:
                        continue
                    for r in v:
                        line = "dhcp-range=interface:{0},{1},{2},{3}\n".format(
                            r["interface"], r["start"], r["end"],
                            r["lease_time"])
                        dnsmasq.write(line)
                else:
                    key = str(k).strip()
                    value = str(v).strip()
                    dnsmasq.write("{0}={1}\n".format(key, value))
示例#10
0
    def write(self, path=None):
        self.validate()

        if path is None:
            path = self._path

        self.backup()

        with toolutils.atomic_write(path) as dnsmasq:
            for k, v in self._config.iteritems():
                if k == "dhcp-range":
                    if not v:
                        continue
                    for r in v:
                        line = "dhcp-range=interface:{0},{1},{2},{3}\n".format(
                            r["interface"], r["start"],
                            r["end"], r["lease_time"]
                        )
                        dnsmasq.write(line)
                else:
                    key = str(k).strip()
                    value = str(v).strip()
                    dnsmasq.write("{0}={1}\n".format(key, value))