Cleanup function on keyboard interrupt or exit
Some checks failed
ci/woodpecker/push/linting Pipeline failed
Some checks failed
ci/woodpecker/push/linting Pipeline failed
This commit is contained in:
parent
070a130558
commit
b1aa5ba9bc
@ -59,6 +59,34 @@ def now():
|
||||
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(
|
||||
datafile: str,
|
||||
codec: str,
|
||||
@ -269,7 +297,7 @@ def score_psnr(outputfile: str, inputfile: str) -> float:
|
||||
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user