Brute-force clean out tmp at exit
This commit is contained in:
parent
9b16857d44
commit
0fe9f4c42b
1 changed files with 13 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
import uuid
|
import uuid
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
import datetime
|
import datetime
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import atexit
|
||||||
|
|
||||||
pil_formats = ['JPG', 'JPEG', 'PNG', 'TIF', 'TIFF']
|
pil_formats = ['JPG', 'JPEG', 'PNG', 'TIF', 'TIFF']
|
||||||
thumbnail_size = (60, 60)
|
thumbnail_size = (60, 60)
|
||||||
|
|
@ -12,6 +14,15 @@ thumbnail_size = (60, 60)
|
||||||
BASE_CAPTURE_PATH = os.path.join(os.path.expanduser('~'), 'micrographs')
|
BASE_CAPTURE_PATH = os.path.join(os.path.expanduser('~'), 'micrographs')
|
||||||
TEMP_CAPTURE_PATH = os.path.join(BASE_CAPTURE_PATH, 'tmp')
|
TEMP_CAPTURE_PATH = os.path.join(BASE_CAPTURE_PATH, 'tmp')
|
||||||
|
|
||||||
|
def clear_tmp():
|
||||||
|
global TEMP_CAPTURE_PATH
|
||||||
|
|
||||||
|
logging.info("Clearing {}...".format(TEMP_CAPTURE_PATH))
|
||||||
|
files = glob.glob('{}/*'.format(TEMP_CAPTURE_PATH))
|
||||||
|
for f in files:
|
||||||
|
os.remove(f)
|
||||||
|
logging.debug("Removed {}".format(f))
|
||||||
|
|
||||||
class CaptureObject(object):
|
class CaptureObject(object):
|
||||||
"""
|
"""
|
||||||
StreamObject used to store and process capture data, and metadata.
|
StreamObject used to store and process capture data, and metadata.
|
||||||
|
|
@ -293,3 +304,5 @@ class CaptureObject(object):
|
||||||
self.delete_stream()
|
self.delete_stream()
|
||||||
if not self.keep_on_disk:
|
if not self.keep_on_disk:
|
||||||
self.delete_file()
|
self.delete_file()
|
||||||
|
|
||||||
|
atexit.register(clear_tmp)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue