当前位置: 首页>>代码示例>>Python>>正文


Python hostname.HostnameConf类代码示例

本文整理汇总了Python中cloudinit.distros.parsers.hostname.HostnameConf的典型用法代码示例。如果您正苦于以下问题:Python HostnameConf类的具体用法?Python HostnameConf怎么用?Python HostnameConf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HostnameConf类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _write_hostname

 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)
开发者ID:davejohnston,项目名称:cloud-init,代码行数:12,代码来源:debian.py

示例2: _write_hostname

 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)
开发者ID:cloud-init,项目名称:cloud-init,代码行数:14,代码来源:gentoo.py

示例3: _write_hostname

 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)
开发者ID:cloud-init,项目名称:cloud-init,代码行数:17,代码来源:opensuse.py

示例4: _read_hostname_conf

 def _read_hostname_conf(self, filename):
     conf = HostnameConf(util.load_file(filename))
     conf.parse()
     return conf
开发者ID:davejohnston,项目名称:cloud-init,代码行数:4,代码来源:debian.py


注:本文中的cloudinit.distros.parsers.hostname.HostnameConf类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。