Permalink
Browse files

Merge pull request #106 from davehughes/file_write-fix

Apply sudo parameter and handle errors in file_write
  • Loading branch information...
2 parents 84eec2e + bffc391 commit 612dd279c950906ec7d78cd26a07bf55a8f9b54c @sebastien sebastien committed Sep 20, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/cuisine.py
View
@@ -408,10 +408,14 @@ def file_write(location, content, mode=None, owner=None, group=None, sudo=None,
# Hides the output, which is especially important
with fabric.context_managers.settings(
fabric.api.hide('warnings', 'running', 'stdout'),
- warn_only=True
+ warn_only=True,
+ **{MODE_SUDO: use_sudo}
):
# We send the data as BZipped Base64
- run("echo '%s' | base64 -d | bzcat > \"%s\"" % (base64.b64encode(bz2.compress(content)), location))
+ result = run("echo '%s' | base64 -d | bzcat > \"%s\"" % (base64.b64encode(bz2.compress(content)), location))
+ if result.failed:
+ fabric.api.abort('Encountered error writing the file %s: %s' % (location, result))
+
# Remove the local temp file
os.close(fd)
os.unlink(local_path)

0 comments on commit 612dd27

Please sign in to comment.