[Cryptech-Commits] [user/sra/build-tools] 02/02: Flush stdout to interleave properly with subprocesses.

git at cryptech.is git at cryptech.is
Sun Jun 19 18:52:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository user/sra/build-tools.

commit 9ebba5607f2e09c96eb88248499973ca3f3e1005
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Jun 19 14:50:21 2016 -0400

    Flush stdout to interleave properly with subprocesses.
---
 repo-foreach.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/repo-foreach.py b/repo-foreach.py
index ea18a39..85a2888 100755
--- a/repo-foreach.py
+++ b/repo-foreach.py
@@ -5,7 +5,7 @@
 from subprocess import call
 from os         import walk
 from argparse   import ArgumentParser
-from sys        import exit
+from sys        import exit, stdout
 
 parser = ArgumentParser()
 parser.add_argument("-t", "--tree", default = ".", help = "repository tree to walk")
@@ -13,12 +13,17 @@ parser.add_argument("-v", "--verbose", action = "store_true", help = "whistle wh
 parser.add_argument("command", nargs = "+", help = "command to run in each repository")
 args = parser.parse_args()
 
+def log(msg):
+    if args.verbose:
+        stdout.write(msg)
+        stdout.write("\n")
+        stdout.flush()
+
 status = 0
 
 for head, dirs, files in walk(args.tree):
     if ".git" in dirs and not head.endswith("/gitolite"):
-        if args.verbose:
-            print head
+        log(head)
         status |= call(args.command, cwd = head)
 
 exit(status)



More information about the Commits mailing list