diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 1dbe97070..de76a4ca0 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -171,8 +171,8 @@ class PypoFetch(Thread): self.logger.debug('Getting information needed on bootstrap from Airtime') info = self.api_client.get_bootstrap_info() if info == None: - self.logger.error('Unable to get bootstrap info.. Existing pypo...') - sys.exit(0) + self.logger.error('Unable to get bootstrap info.. Exiting pypo...') + sys.exit(1) else: self.logger.debug('info:%s', info) for k, v in info['switch_status'].iteritems(): @@ -427,6 +427,7 @@ class PypoFetch(Thread): fileExt = os.path.splitext(media_item['uri'])[1] dst = os.path.join(download_dir, media_item['id'] + fileExt) media_item['dst'] = dst + media_item['started_copying'] = False media_filtered[key] = media_item self.media_prepare_queue.put(copy.copy(media_filtered)) diff --git a/python_apps/pypo/pypofile.py b/python_apps/pypo/pypofile.py index 81a48b96d..6f9a213e6 100644 --- a/python_apps/pypo/pypofile.py +++ b/python_apps/pypo/pypofile.py @@ -70,6 +70,9 @@ class PypoFile(Thread): if do_copy: self.logger.debug("copying from %s to local cache %s" % (src, dst)) try: + + media_item['started_copying'] = True + """ copy will overwrite dst if it already exists """ diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 9cac4022c..03420b9d9 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -80,8 +80,7 @@ class PypoPush(Thread): self.modify_cue_point(current_event_chain[0]) next_media_item_chain = current_event_chain time_until_next_play = 0 - #sleep for 0.2 seconds to give pypo-file time to copy. This is a quick - #fix that will be improved in 2.1.1 + #sleep for 0.2 seconds to give pypo-file time to copy. time.sleep(0.2) else: media_chain = filter(lambda item: (item["type"] == "file"), current_event_chain) @@ -313,7 +312,20 @@ class PypoPush(Thread): try: for media_item in event_chain: if media_item['type'] == "file": - self.telnet_to_liquidsoap(media_item) + + """ + Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise + give up on it. + """ + iter_num = 0 + while not media_item['started_copying'] and iter_num < 50: + time.sleep(0.1) + iter_num += 1 + + if media_item['started_copying']: + self.telnet_to_liquidsoap(media_item) + else: + self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst']) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj")