Only print the progress message if on a TTY
[stgit] / stg-prof
index 8bbb623..de7bd13 100755 (executable)
--- a/stg-prof
+++ b/stg-prof
@@ -40,13 +40,14 @@ if bin == 'bin' and prefix != sys.prefix:
 
 from stgit.main import main
 
-start_time = time.time()
-def timer():
-    return time.time() - start_time
-
-prof = profile.Profile(timer)
-try:
-    prof.run('main()')
-except SystemExit:
-    pass
-pstats.Stats(prof).strip_dirs().sort_stats(-1).print_stats().print_callees()
+if __name__ == '__main__':
+    start_time = time.time()
+    def timer():
+        return time.time() - start_time
+
+    prof = profile.Profile(timer)
+    try:
+        prof.run('main()')
+    except SystemExit:
+        pass
+    pstats.Stats(prof).strip_dirs().sort_stats(-1).print_stats().print_callees()