updater.py 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from setux.logger import silent
  2. from setux.core.action import Action
  3. class Updater(Action):
  4. '''Update a file'''
  5. @property
  6. def label(self):
  7. return f'upd {self.path}'
  8. def check(self):
  9. cont = self.target.read(
  10. self.path,
  11. sudo = self.sudo,
  12. report = 'quiet',
  13. )
  14. return self.line in cont
  15. def deploy(self):
  16. self.target.deploy('upd_cfg',
  17. path = self.path,
  18. line = self.line,
  19. select = self.select,
  20. user = self.user,
  21. group = self.group,
  22. mode = self.mode,
  23. sudo = self.sudo,
  24. )
  25. self.target.file(
  26. self.path,
  27. user = self.user,
  28. group = self.group,
  29. mode = self.mode,
  30. sudo = self.sudo,
  31. verbose = False,
  32. )
  33. return True