sanity check to warn if cue_out - cue_in != end - start
This commit is contained in:
parent
c7f377ad3a
commit
3ae3c7e802
|
@ -432,6 +432,7 @@ class PypoFetch(Thread):
|
||||||
for key in media:
|
for key in media:
|
||||||
media_item = media[key]
|
media_item = media[key]
|
||||||
if (media_item['type'] == 'file'):
|
if (media_item['type'] == 'file'):
|
||||||
|
self.sanity_check_media_item(media_item)
|
||||||
fileExt = os.path.splitext(media_item['uri'])[1]
|
fileExt = os.path.splitext(media_item['uri'])[1]
|
||||||
dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt)
|
dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt)
|
||||||
media_item['dst'] = dst
|
media_item['dst'] = dst
|
||||||
|
@ -455,6 +456,20 @@ class PypoFetch(Thread):
|
||||||
try: self.cache_cleanup(media)
|
try: self.cache_cleanup(media)
|
||||||
except Exception, e: self.logger.error("%s", e)
|
except Exception, e: self.logger.error("%s", e)
|
||||||
|
|
||||||
|
#do basic validation of file parameters. Useful for debugging
|
||||||
|
#purposes
|
||||||
|
def sanity_check_media_item(self, media_item):
|
||||||
|
start = datetime.strptime(media_item['start'], "%Y-%m-%d-%H-%M-%S")
|
||||||
|
end = datetime.strptime(media_item['end'], "%Y-%m-%d-%H-%M-%S")
|
||||||
|
|
||||||
|
length1 = (end - start).total_seconds()
|
||||||
|
length2 = media_item['cue_out'] - media_item['cue_in']
|
||||||
|
|
||||||
|
if abs(length2 - length1) > 1:
|
||||||
|
self.logger.error("end - start length: %s", length1)
|
||||||
|
self.logger.error("cue_out - cue_in length: %s", length2)
|
||||||
|
self.logger.error("Two lengths are not equal!!!")
|
||||||
|
|
||||||
def is_file_opened(self, path):
|
def is_file_opened(self, path):
|
||||||
#Capture stderr to avoid polluting py-interpreter.log
|
#Capture stderr to avoid polluting py-interpreter.log
|
||||||
proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE)
|
proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE)
|
||||||
|
|
Loading…
Reference in New Issue