From e197117c0e417c6c3423716f84b143a2873376d9 Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 31 Mar 2021 04:47:25 +0200 Subject: [PATCH] [CI] fix a few lint errors --- timer.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/timer.py b/timer.py index 1204552..af7501f 100755 --- a/timer.py +++ b/timer.py @@ -1,5 +1,9 @@ #!/usr/bin/python +""" +OBS countdown timer for OBS +""" + import argparse import os import time @@ -13,16 +17,17 @@ args = parser.parse_args() def write_countdown(filename, stimer): - t = stimer - with open(filename, 'w') as f: - while t > 0: - t -= 1 - min, sec = divmod(t, 60) - print(f'{min:02d}:{sec:02d}') - f.seek(0) - f.write(f'{min:02d}:{sec:02d}') - os.fsync(f) + """ decrease counter anf write synchronously to dest file """ + tsec = stimer + with open(filename, 'w') as destfile: + while tsec > 0: + tsec -= 1 + minutes, sec = divmod(tsec, 60) + print(f'{minutes:02d}:{sec:02d}') + destfile.seek(0) + destfile.write(f'{minutes:02d}:{sec:02d}') + os.fsync(destfile) time.sleep(1) -write_countdown(args.file, args.timer) \ No newline at end of file +write_countdown(args.file, args.timer)