aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2010-07-08 13:47:21 +0200
committerLaurent Bachelier <laurent@bachelier.name>2010-07-08 13:47:21 +0200
commit6fec08e6cdaf444dc16bbb00d5ba145d7c2a00f0 (patch)
tree5c08f950fba6ab82b2e4827b7e12b4c3ec96ef1c
parentAdd support for templates in programmable actions (diff)
downloadconfman-6fec08e6cdaf444dc16bbb00d5ba145d7c2a00f0.tar.xz
Bugfixes for TextAction
* Destination directory wasn't created automatically * It did not truncate the file properly
-rw-r--r--confman.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/confman.py b/confman.py
index 4c8e9e4..13b874f 100644
--- a/confman.py
+++ b/confman.py
@@ -164,11 +164,14 @@ class TextAction(Action):
if osp.islink(dest):
raise ActionException(self, "Destination is a link")
else:
+ self._makedirs()
with open(dest, "a+") as destfile:
if destfile.read() != self.text:
- destfile.truncate()
+ print "Updated file contents: "+dest
+ destfile.truncate(0)
destfile.write(self.text)
+
def __repr__(self):
return self.__class__.__name__+": TEXT => "+self.dest