Add a sys.stdout.flush()
call after print
ing, so that even if output is fully buffered (as it is on a pipe, which is the case when running under a git hook), it is sent to the output stream at that point, before running another command.
Fabric show print after executing commands
Question
I have a post-receive hook on my git bare repo that excute this fabfile.py:
def deploy():
print(cyan('Pulling changes to local server'))
with cd('/var/www')
local('git pull')
It executes fine, but it shows the output for the local command before the print, like this:
remote: From /media/projetos/repositorios/test
remote: b057a4b..02d85b3 master -> origin/master
remote: Updating b057a4b..02d85b3
remote: Fast-forward
remote: .../test/template/catalog/product/list.phtml | 98 +++++++++++-----------
remote: 1 file changed, 47 insertions(+), 51 deletions(-)
remote: Pulling changes to local server
If i just ssh on the server and run fab deploy it works normal.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow