fixed temp folders bug

This commit is contained in:
k4yt3x 2019-04-18 14:56:30 -04:00
parent 6538abd6e5
commit 837aca371e
2 changed files with 11 additions and 7 deletions

View File

@ -56,20 +56,22 @@ class Upscaler:
self.image_format = 'png'
self.preserve_frames = False
# create temporary folder/directories
def create_temp_folders(self):
"""create temporary folder/directories
"""
self.extracted_frames = tempfile.mkdtemp(dir=self.video2x_cache_folder)
Avalon.debug_info('Extracted frames are being saved to: {}'.format(self.extracted_frames))
self.upscaled_frames = tempfile.mkdtemp(dir=self.video2x_cache_folder)
Avalon.debug_info('Upscaled frames are being saved to: {}'.format(self.upscaled_frames))
def cleanup(self):
# delete temp directories when done
# avalon framework cannot be used if python is shutting down
# therefore, plain print is used
"""delete temp directories when done
"""
if not self.preserve_frames:
for directory in [self.extracted_frames, self.upscaled_frames]:
try:
# avalon framework cannot be used if python is shutting down
# therefore, plain print is used
print('Cleaning up cache directory: {}'.format(directory))
shutil.rmtree(directory)
except (OSError, FileNotFoundError):

View File

@ -52,7 +52,7 @@ import tempfile
import time
import traceback
VERSION = '2.7.0'
VERSION = '2.7.1'
# each thread might take up to 2.5 GB during initialization.
# (system memory, not to be confused with GPU memory)
@ -313,7 +313,8 @@ try:
upscaler.image_format = image_format
upscaler.preserve_frames = preserve_frames
# run upscaler-
# run upscaler
upscaler.create_temp_folders()
upscaler.run()
upscaler.cleanup()
@ -337,6 +338,7 @@ try:
upscaler.preserve_frames = preserve_frames
# run upscaler
upscaler.create_temp_folders()
upscaler.run()
upscaler.cleanup()
else: