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()))
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
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))
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()))
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
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()))
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))
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))