Esempio n. 1
0
 def test_chown(self):
     path = LocalPath("/tmp/delme.txt")
     path.delete()
     path.write('test')
     self.assertTrue('nobody' != path.owner)
     self.assertTrue('nogroup' != path.group)
     # chown group
     path.chown(group='nogroup')
     self.assertEqual('nogroup', path.group)
     self.assertTrue('nobody' != path.owner)
     # chown owner
     path.chown('nobody')
     self.assertEqual('nobody', path.owner)
     # chown both / numerical ids
     path.chown(uid=0, gid=0)
     self.assertEqual('root', path.owner)
     self.assertEqual('root', path.group)
     # recursive
     path.chown('root', recursive=True)
         # set properties
     path.owner = 'nobody'
     self.assertEqual('nobody', path.owner)
     path.group = 'nogroup'
     self.assertEqual('nogroup', path.group)
     path.delete()
Esempio n. 2
0
 def __render(path, **kwargs):
     tpl = Template(path.read(encoding='utf-8'))
     result = tpl.safe_substitute(**kwargs)
     dst = LocalPath(path.name)
     log.info("## rendered %s ##\n%s\n## -> %s ##\n", path, result, dst)
     dst.write(result, encoding='utf-8')