예제 #1
0
 def _write_hostname(self, your_hostname, out_fn):
     conf = None
     try:
         # Try to update the previous one
         # so lets see if we can read it first.
         conf = self._read_hostname_conf(out_fn)
     except IOError:
         pass
     if not conf:
         conf = HostnameConf('')
     conf.set_hostname(your_hostname)
     util.write_file(out_fn, str(conf), 0644)
예제 #2
0
 def _write_hostname(self, your_hostname, out_fn):
     conf = None
     try:
         # Try to update the previous one
         # so lets see if we can read it first.
         conf = self._read_hostname_conf(out_fn)
     except IOError:
         pass
     if not conf:
         conf = HostnameConf('')
     conf.set_hostname(your_hostname)
     util.write_file(out_fn, str(conf), 0o644)
 def _write_hostname(self, hostname, filename):
     conf = None
     try:
         # Try to update the previous one
         # so lets see if we can read it first.
         conf = self._read_hostname_conf(filename)
     except IOError:
         pass
     if not conf:
         conf = HostnameConf("")
     conf.set_hostname(hostname)
     util.write_file(filename, str(conf), 0o644)
예제 #4
0
 def _write_hostname(self, your_hostname, out_fn):
     conf = None
     try:
         # Try to update the previous one
         # so lets see if we can read it first.
         conf = self._read_hostname_conf(out_fn)
     except IOError:
         pass
     if not conf:
         conf = HostnameConf('')
     conf.set_hostname(your_hostname)
     gentoo_hostname_config = 'hostname="%s"' % conf
     gentoo_hostname_config = gentoo_hostname_config.replace('\n', '')
     util.write_file(out_fn, gentoo_hostname_config, 0o644)
예제 #5
0
 def _write_hostname(self, your_hostname, out_fn):
     conf = None
     try:
         # Try to update the previous one
         # so lets see if we can read it first.
         conf = self._read_hostname_conf(out_fn)
     except IOError:
         pass
     if not conf:
         conf = HostnameConf('')
     conf.set_hostname(your_hostname)
     gentoo_hostname_config = 'hostname="%s"' % conf
     gentoo_hostname_config = gentoo_hostname_config.replace('\n', '')
     util.write_file(out_fn, gentoo_hostname_config, 0o644)
예제 #6
0
    def _write_hostname(self, hostname, filename):
        conf = None
        try:
            # Try to update the previous one
            # so lets see if we can read it first.
            conf = self._read_hostname_conf(filename)
        except IOError:
            pass
        if not conf:
            conf = HostnameConf("")

        # Many distro's format is the hostname by itself, and that is the
        # way HostnameConf works but gentoo expects it to be in
        #     hostname="the-actual-hostname"
        conf.set_hostname('hostname="%s"' % hostname)
        util.write_file(filename, str(conf), 0o644)
예제 #7
0
 def _write_hostname(self, hostname, out_fn):
     if self.uses_systemd() and out_fn.endswith('/previous-hostname'):
         util.write_file(out_fn, hostname)
     elif self.uses_systemd():
         subp.subp(['hostnamectl', 'set-hostname', str(hostname)])
     else:
         conf = None
         try:
             # Try to update the previous one
             # so lets see if we can read it first.
             conf = self._read_hostname_conf(out_fn)
         except IOError:
             pass
         if not conf:
             conf = HostnameConf('')
         conf.set_hostname(hostname)
         util.write_file(out_fn, str(conf), 0o644)
예제 #8
0
 def _write_hostname(self, hostname, out_fn):
     if self.uses_systemd() and out_fn.endswith('/previous-hostname'):
         util.write_file(out_fn, hostname)
     elif self.uses_systemd():
         util.subp(['hostnamectl', 'set-hostname', str(hostname)])
     else:
         conf = None
         try:
             # Try to update the previous one
             # so lets see if we can read it first.
             conf = self._read_hostname_conf(out_fn)
         except IOError:
             pass
         if not conf:
             conf = HostnameConf('')
         conf.set_hostname(hostname)
         util.write_file(out_fn, str(conf), 0o644)
예제 #9
0
 def _write_hostname(self, hostname, filename):
     if self.uses_systemd() and filename.endswith("/previous-hostname"):
         util.write_file(filename, hostname)
     elif self.uses_systemd():
         subp.subp(["hostnamectl", "set-hostname", str(hostname)])
     else:
         conf = None
         try:
             # Try to update the previous one
             # so lets see if we can read it first.
             conf = self._read_hostname_conf(filename)
         except IOError:
             pass
         if not conf:
             conf = HostnameConf("")
         conf.set_hostname(hostname)
         util.write_file(filename, str(conf), 0o644)
예제 #10
0
 def _write_hostname(self, hostname, filename):
     conf = None
     try:
         # Try to update the previous one
         # Let's see if we can read it first.
         conf = HostnameConf(util.load_file(filename))
         conf.parse()
     except IOError:
         pass
     if not conf:
         conf = HostnameConf('')
     conf.set_hostname(hostname)
     util.write_file(filename, str(conf), mode=0o644)
예제 #11
0
 def _read_hostname_conf(self, filename):
     conf = HostnameConf(util.load_file(filename))
     conf.parse()
     return conf
예제 #12
0
 def _read_hostname_conf(self, filename):
     conf = HostnameConf(util.load_file(filename))
     conf.parse()
     return conf