From 89d1fb8565b282567ee5c0489fde2b107854a780 Mon Sep 17 00:00:00 2001 From: Petr Šabata Date: Oct 31 2020 13:06:09 +0000 Subject: Avoid blank lines in log files for lookaside I've noticed a large number of blank lines in my logs whenever I work the lookaside cache. print_progress() already handles that but the download and upload functions don't. This fixes that. Signed-off-by: Petr Šabata --- diff --git a/pyrpkg/lookaside.py b/pyrpkg/lookaside.py index f960908..27a6951 100644 --- a/pyrpkg/lookaside.py +++ b/pyrpkg/lookaside.py @@ -185,8 +185,9 @@ class CGILookasideCache(object): c.close() # Get back a new line, after displaying the download progress - sys.stdout.write('\n') - sys.stdout.flush() + if sys.stdout.isatty(): + sys.stdout.write('\n') + sys.stdout.flush() if status != 200: self.log.info('Remove downloaded invalid file %s', outfile) @@ -341,8 +342,9 @@ class CGILookasideCache(object): output = buf.getvalue().strip() # Get back a new line, after displaying the download progress - sys.stdout.write('\n') - sys.stdout.flush() + if sys.stdout.isatty(): + sys.stdout.write('\n') + sys.stdout.flush() if status != 200: self.raise_upload_error(status)