From 39cfed8e6a964c957d5b538682afbcee7d63210e Mon Sep 17 00:00:00 2001 From: Sogolumbo <33571916+Sogolumbo@users.noreply.github.com> Date: Mon, 5 Oct 2020 04:43:17 +0200 Subject: [PATCH] Use boolean toggle variable instead of comment --- spotify-backup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spotify-backup.py b/spotify-backup.py index 1a1fc70..55c1da5 100755 --- a/spotify-backup.py +++ b/spotify-backup.py @@ -111,9 +111,12 @@ class SpotifyAPI: self.access_token = access_token def log(str): - #print('[{}] {}'.format(time.strftime('%I:%M:%S'), str).encode(sys.stdout.encoding, errors='replace')) - sys.stdout.buffer.write('[{}] {}\n'.format(time.strftime('%I:%M:%S'), str).encode(sys.stdout.encoding, errors='replace')) - sys.stdout.flush() + fileOutput = False #replace with the opposite value if errors occur + if not fileOutput: + print('[{}] {}'.format(time.strftime('%I:%M:%S'), str).encode(sys.stdout.encoding, errors='replace')) + else: + sys.stdout.buffer.write('[{}] {}\n'.format(time.strftime('%I:%M:%S'), str).encode(sys.stdout.encoding, errors='replace')) + sys.stdout.flush() def main(): # Parse arguments.