From 3ae3c7e802cec08ae3a204a85775e063a9971647 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 7 May 2013 15:05:14 -0400 Subject: [PATCH] sanity check to warn if cue_out - cue_in != end - start --- python_apps/pypo/pypofetch.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 20212be51..38a72f363 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -432,6 +432,7 @@ class PypoFetch(Thread): for key in media: media_item = media[key] if (media_item['type'] == 'file'): + self.sanity_check_media_item(media_item) fileExt = os.path.splitext(media_item['uri'])[1] dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt) media_item['dst'] = dst @@ -455,6 +456,20 @@ class PypoFetch(Thread): try: self.cache_cleanup(media) 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): #Capture stderr to avoid polluting py-interpreter.log proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE)