-1

When using fabric I sometimes get output like this from programs like apt, git, and others:

[tfb@192.168.59.103:49369] out: Receiving objects:   6% (3318/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:   7% (3871/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:   8% (4424/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:   9% (4977/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:  10% (5529/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:  11% (6082/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:  12% (6635/55289)   
[tfb@192.168.59.103:49369] out: Receiving objects:  13% (7188/55289)   

I suspect this has something to do with the type of terminal not supporting a carriage return properly. Two questions:

  1. Can I stop this from happening when using Fabric?

  2. What is the terminology used to discuss the feature a terminal needs to support to avoid this issue? E.g. why is this happening

Hamy
  • 20,662
  • 15
  • 74
  • 102
  • Thanks, but I'm looking for why this happens at the PTY level - I know how to disable it per command, but the scripts I'm running have thousands of commands and hundreds of times this is happening – Hamy Feb 23 '15 at 17:09
  • Because it is a pty, not a screen. – Antti Haapala -- Слава Україні Feb 23 '15 at 17:13
  • But it doesn't happen on *all* PTYs. If I re-run this command using the root user instead of the tfb user, then git somehow recognized that I don't want this kind of dynamic output and only sends like 4-5 lines total – Hamy Feb 23 '15 at 17:23

2 Answers2

1

Via #fabric on FreeNode

redkrieg: that's not carriage returns, your application is sending those updates to the terminal. Some applications won't do this if you disable pty, others don't care about their environment and try to mess up your screen regardless. if at all possible, look for "batch mode" type options in your program or suppress output in fabric.

Which makes some sense, because Fabric's default featureset claims to support carriage returns properly through line buffering. Just disabling the pty appears to have fixed the issue e.g.

run('git clone foo ~/foo', pty=False)

fixes the problem for git, and similarly apt and most other major offenders. Interestingly, this may not have been an issue when the remote user was root because it was refusing to create a PTY, and not because the PTY used by root had some special properties

Hamy
  • 20,662
  • 15
  • 74
  • 102
0

Try using the following lines

import fabric
from fabric.api import env

fabric.state.output['running'] = False
env.output_prefix = False
Harman
  • 751
  • 1
  • 9
  • 31