]> git.phdru.name Git - sqlconvert.git/commitdiff
Fix mysql2sql: do not mix output and messages
authorOleg Broytman <phd@phdru.name>
Sun, 19 Mar 2017 16:19:34 +0000 (19:19 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 19 Mar 2017 16:19:34 +0000 (19:19 +0300)
Inhibit progress bar and log messages if the output is stdout.

scripts/mysql2sql

index e4f2e4bbf9fa0eb9c84c1759fcd41cc79b13cfb0..7e29c2e4f1ced3ede855624cf23cfcfafeb36418 100755 (executable)
@@ -31,7 +31,8 @@ def main(infile, encoding, outfile, output_encoding, use_pbar, quoting_style):
         if size is None:
             use_pbar = False
 
-    print("Converting: ", end='', file=sys.stderr)
+    if use_pbar:
+        print("Converting: ", end='', file=sys.stderr)
     sys.stderr.flush()
 
     if use_pbar:
@@ -66,7 +67,7 @@ def main(infile, encoding, outfile, output_encoding, use_pbar, quoting_style):
 
     if use_pbar:
         pbar.erase()
-    print("done.")
+        print("done.")
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='Convert MySQL to SQL')
@@ -133,6 +134,7 @@ if __name__ == '__main__':
 
     if outfile == '-':
         outfile = sys.stdout
+        args.no_pbar = True
     else:
         try:
             outfile = open(outfile, 'wt', encoding=output_encoding)