Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is this a python-related issue like the one described in <a href="http://www.mail-archive.com/fab-user@nongnu.org/msg00853.html" rel="nofollow noreferrer">this thread</a>?</p> <blockquote> <p>The main problem with this is that the <code>stdout</code>/<code>stderr</code> capturing is per-run/sudo invocation and not per-task.</p> <p>It would be wonderful if you could explain me how I could collect <em>output</em>and <em>error</em> by only modifying the file called <em><code>fabfile_runner.py</code></em>.<br> Idealy the fabric task itself could be unmodified, this would allow to upload the the factory the same file that you have tested manually.</p> <p>Check out the Fabric source and look in the 'tests' folder, specifically tests/utils.py. It contains a single decorator, <code>@mock_streams</code>, which is capable of wrapping a function (any function in any Python code -- it's not Fabric specific, as I mentioned) and redirecting <code>sys.stdout</code> and/or <code>sys.stderr</code> for capture/examination.</p> <p>It's designed for use around functions, being a decorator, so you could use it directly by modifying your <code>fabfile_runner.py</code> like so:</p> </blockquote> <p><em>fabfile_runner.py</em></p> <pre><code>from StringIO import StringIO import sys from test_fabfile import hello_world def execute(task): output = StringIO() error = StringIO() sys.stdout = output sys.stderr = error task() sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ return (output.getvalue(), error.getvalue()) output, error = execute(hello_world) print "output : %s" %output print "error : %s" %error </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload