diff --git a/changelog b/changelog index 9aa22c634..aff42ec52 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ 2.3.0 - Jan 21st, 2013 * New features - * Localization (Brazilian, Chinese, Czech, English, French, German, Italian, Korean, Portugese, Russian, Spanish) + * Localization (Chinese, Czech, English, French, German, Italian, Korean, + Portuguese, Russian, Spanish) * User management page for non-admin users * Listener statistics (Icecast/Shoutcast) * Airtime no longer requires Apache document root diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index ed0ca3520..8f39e6acd 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -176,7 +176,7 @@ if __name__ == '__main__': sys.exit() api_client = api_client.AirtimeApiClient() - + ReplayGainUpdater.start_reply_gain(api_client) api_client.register_component("pypo") diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index b0cbdc69a..e073efda9 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -18,7 +18,8 @@ from std_err_override import LogWriter from configobj import ConfigObj # configure logging -logging.config.fileConfig("logging.cfg") +logging_cfg = os.path.join(os.path.dirname(__file__), "logging.cfg") +logging.config.fileConfig(logging_cfg) logger = logging.getLogger() LogWriter.override_std_err(logger) diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 6fedfab1b..f438b3bb1 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -9,6 +9,7 @@ import logging.config import telnetlib import calendar import math +import os from pypofetch import PypoFetch from Queue import Empty @@ -21,7 +22,8 @@ from configobj import ConfigObj # configure logging -logging.config.fileConfig("logging.cfg") +logging_cfg = os.path.join(os.path.dirname(__file__), "logging.cfg") +logging.config.fileConfig(logging_cfg) logger = logging.getLogger() LogWriter.override_std_err(logger) @@ -249,7 +251,7 @@ class PypoPush(Thread): self.start_web_stream_buffer(current_item) self.start_web_stream(current_item) if is_file(current_item): - self.modify_cue_point(file_chain[0]) + file_chain = self.modify_first_link_cue_point(file_chain) self.push_to_liquidsoap(file_chain) #we've changed the queue, so let's refetch it liquidsoap_queue_approx = self.get_queue_items_from_liquidsoap() @@ -279,7 +281,7 @@ class PypoPush(Thread): chain_to_push = file_chain[problem_at_iteration:] if len(chain_to_push) > 0: - self.modify_cue_point(chain_to_push[0]) + chain_to_push = self.modify_first_link_cue_point(chain_to_push) self.push_to_liquidsoap(chain_to_push) @@ -363,6 +365,18 @@ class PypoPush(Thread): original_cue_in_td = timedelta(seconds=float(link['cue_in'])) link['cue_in'] = self.date_interval_to_seconds(original_cue_in_td) + diff_sec + def modify_first_link_cue_point(self, chain): + if not len(chain): + return [] + + first_link = chain[0] + + self.modify_cue_point(first_link) + if float(first_link['cue_in']) >= float(first_link['cue_out']): + chain = chain [1:] + + return chain + """ Returns two chains, original chain and current_chain. current_chain is a subset of original_chain but can also be equal to original chain. diff --git a/python_apps/pypo/tests/run_tests.sh b/python_apps/pypo/tests/run_tests.sh new file mode 100755 index 000000000..830a9bb85 --- /dev/null +++ b/python_apps/pypo/tests/run_tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +which py.test +pytest_exist=$? + +if [ "$pytest_exist" != "0" ]; then + echo "Need to have py.test installed. Exiting..." + exit 1 +fi + +SCRIPT=`readlink -f $0` +# Absolute directory this script is in +SCRIPTPATH=`dirname $SCRIPT` + +export PYTHONPATH=$PYTHONPATH:$SCRIPTPATH/..:$SCRIPTPATH/../.. + +py.test + diff --git a/python_apps/pypo/tests/test_modify_cue_in.py b/python_apps/pypo/tests/test_modify_cue_in.py new file mode 100644 index 000000000..d5049bde5 --- /dev/null +++ b/python_apps/pypo/tests/test_modify_cue_in.py @@ -0,0 +1,29 @@ +from pypopush import PypoPush +from threading import Lock +from Queue import Queue + +import datetime + +pypoPush_q = Queue() +telnet_lock = Lock() + +pp = PypoPush(pypoPush_q, telnet_lock) + +def test_modify_cue_in(): + + link = pp.modify_first_link_cue_point([]) + assert len(link) == 0 + + min_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes = 1) + link = [{"start":min_ago.strftime("%Y-%m-%d-%H-%M-%S"), + "cue_in":"0", "cue_out":"30"}] + link = pp.modify_first_link_cue_point(link) + assert len(link) == 0 + + link = [{"start":min_ago.strftime("%Y-%m-%d-%H-%M-%S"), + "cue_in":"0", "cue_out":"70"}] + link = pp.modify_first_link_cue_point(link) + assert len(link) == 1 + + +