From: Oleg Broytman Date: Sun, 19 Mar 2017 16:19:34 +0000 (+0300) Subject: Fix mysql2sql: do not mix output and messages X-Git-Tag: 0.1.0~4 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=6e7b1489547b4fd5bd5faf49b1172b68fc14a257;p=sqlconvert.git Fix mysql2sql: do not mix output and messages Inhibit progress bar and log messages if the output is stdout. --- diff --git a/scripts/mysql2sql b/scripts/mysql2sql index e4f2e4b..7e29c2e 100755 --- a/scripts/mysql2sql +++ b/scripts/mysql2sql @@ -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)