Fixed merge conflicts and simplified new capture creation

This commit is contained in:
Joel Collins 2019-04-26 18:32:32 +01:00
commit fface9994e
7 changed files with 49 additions and 26 deletions

View file

@ -345,7 +345,7 @@ class BaseCamera(object):
write_to_file: bool = True,
temporary: bool = False,
filename: str = None,
folder: str = None,
folder: str = "",
fmt: str = 'h264'):
"""

View file

@ -25,9 +25,10 @@ def clear_tmp():
"""
global TEMP_CAPTURE_PATH
logging.info("Clearing {}...".format(TEMP_CAPTURE_PATH))
shutil.rmtree(TEMP_CAPTURE_PATH)
logging.debug("Cleared {}.".format(TEMP_CAPTURE_PATH))
if os.path.isdir(TEMP_CAPTURE_PATH):
logging.info("Clearing {}...".format(TEMP_CAPTURE_PATH))
shutil.rmtree(TEMP_CAPTURE_PATH)
logging.debug("Cleared {}.".format(TEMP_CAPTURE_PATH))
def pull_usercomment_dict(filepath):
@ -37,6 +38,7 @@ def pull_usercomment_dict(filepath):
filepath: Path to the Exif-containing file
"""
exif_dict = piexif.load(filepath)
if 'Exif' in exif_dict and 37510 in exif_dict['Exif']:
return yaml.load(exif_dict['Exif'][37510].decode())
else:
@ -80,9 +82,12 @@ def capture_from_dict(capture_dict):
) # Create a placeholder capture
capture.split_file_path(capture.file)
capture.temporary = capture_dict['temporary']
if capture.format.upper() in EXIF_FORMATS:
md_exif = pull_usercomment_dict(capture.file)
else:
logging.debug("Unsupported format for EXIF data. Skipping.")
md_exif = {}
md_database = capture_dict['metadata']
@ -95,6 +100,9 @@ def capture_from_dict(capture_dict):
capture._metadata = extract_with_priority('custom', md_exif, md_database)
capture.tags = extract_with_priority('tags', md_exif, md_database)
capture.initialise_stream()
return capture