Cleanup function on keyboard interrupt or exit
Some checks failed
ci/woodpecker/push/linting Pipeline failed

This commit is contained in:
RealStickman 2022-11-10 13:38:21 +01:00
parent 070a130558
commit b1aa5ba9bc

View File

@ -59,6 +59,34 @@ def now():
return int(time.time()) return int(time.time())
def cleanup(keepencodes: bool, outputfile: str = ""):
"""
Clean up files on program exit/interruption
"""
try:
# REVIEW make removal optional/togglable with cli switch
if not keepencodes:
os.remove(outputfile)
except:
pass
try:
os.remove("vmaf.json")
except:
pass
try:
os.remove("ssim.log")
except:
pass
try:
os.remove("psnr.log")
except:
pass
def write_line( def write_line(
datafile: str, datafile: str,
codec: str, codec: str,
@ -269,7 +297,7 @@ def score_psnr(outputfile: str, inputfile: str) -> float:
return mse_avg return mse_avg
def main(inputfile: str, outputpath: str = "encodes"): def main(inputfile: str, outputpath: str = "encodes", keepencodes: bool = False):
""" """
Main program function so this program can be used from the command line or as a library import. Main program function so this program can be used from the command line or as a library import.