Browse Source

Send header to stderr; omit instructions if piped

master
Jim Paris 10 years ago
parent
commit
b029c79e63
1 changed files with 9 additions and 7 deletions
  1. +9
    -7
      terminal.py

+ 9
- 7
terminal.py View File

@@ -123,13 +123,15 @@ class Jimterm:
self.add_cr = add_cr
self.raw = raw

def print_header(self, nodes, bauds):
def print_header(self, nodes, bauds, output = sys.stdout, piped = False):
for (n, (node, baud)) in enumerate(zip(nodes, bauds)):
print (self.color.code(n)
+ node + ", " + str(baud) + " baud"
+ self.color.reset)
print "^C to exit"
print "----------"
output.write(self.color.code(n)
+ node + ", " + str(baud) + " baud"
+ self.color.reset + "\n")
if not piped:
output.write("^C to exit\n")
output.write("----------\n")
output.flush()

def start(self):
self.alive = True
@@ -352,5 +354,5 @@ if __name__ == "__main__":
raw = raw,
color = (os.name == "posix" and not args.mono))
if not quiet:
term.print_header(nodes, bauds)
term.print_header(nodes, bauds, sys.stderr, piped)
term.run()

Loading…
Cancel
Save