Skip to content

Commit

Permalink
Enable context.write_file(..., sudo=True)
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Oct 11, 2018
1 parent 4164823 commit fb5257a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions executor/contexts.py
Expand Up @@ -750,12 +750,13 @@ def test(self, *command, **options):
cmd.start()
return cmd.succeeded

def write_file(self, filename, contents):
def write_file(self, filename, contents, **options):
"""
Change the contents of a file.
:param filename: The pathname of the file to write (a string).
:param contents: The contents to write to the file (a byte string).
:param options: Optional keyword arguments to :func:`execute()`.
This method uses a combination of cat_ and `output redirection`_ to
change the contents of files so that options like
Expand All @@ -767,7 +768,8 @@ def write_file(self, filename, contents):
.. _output redirection: https://en.wikipedia.org/wiki/Redirection_(computing)
"""
return self.execute('cat > %s' % quote(filename), shell=True, input=contents)
options.update(input=contents, shell=True)
return self.execute('cat > %s' % quote(filename), **options)


class LocalContext(AbstractContext):
Expand Down

0 comments on commit fb5257a

Please sign in to comment.