Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
a59fc69d17
47 changed files with 37387 additions and 36090 deletions
|
@ -231,6 +231,7 @@ s = switch(id="schedule_noise_switch",
|
|||
|
||||
s = if dj_live_stream_port != 0 and dj_live_stream_mp != "" then
|
||||
dj_live = mksafe(
|
||||
id="dj_live_mksafe",
|
||||
audio_to_stereo(
|
||||
input.harbor(id="live_dj_harbor",
|
||||
dj_live_stream_mp,
|
||||
|
@ -253,14 +254,15 @@ end
|
|||
|
||||
s = if master_live_stream_port != 0 and master_live_stream_mp != "" then
|
||||
master_dj = mksafe(
|
||||
audio_to_stereo(
|
||||
input.harbor(id="master_harbor",
|
||||
master_live_stream_mp,
|
||||
port=master_live_stream_port,
|
||||
auth=check_master_dj_client,
|
||||
max=40.,
|
||||
on_connect=master_dj_connect,
|
||||
on_disconnect=master_dj_disconnect)))
|
||||
id="master_dj_mksafe",
|
||||
audio_to_stereo(
|
||||
input.harbor(id="master_harbor",
|
||||
master_live_stream_mp,
|
||||
port=master_live_stream_port,
|
||||
auth=check_master_dj_client,
|
||||
max=40.,
|
||||
on_connect=master_dj_connect,
|
||||
on_disconnect=master_dj_disconnect)))
|
||||
|
||||
ignore(output.dummy(master_dj, fallible=true))
|
||||
|
||||
|
|
7
python_apps/pypo/pure.py
Normal file
7
python_apps/pypo/pure.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
import re
|
||||
|
||||
|
||||
def version_cmp(version1, version2):
|
||||
def normalize(v):
|
||||
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
|
||||
return cmp(normalize(version1), normalize(version2))
|
|
@ -13,6 +13,7 @@ import signal
|
|||
import logging
|
||||
import locale
|
||||
import os
|
||||
import re
|
||||
|
||||
from Queue import Queue
|
||||
from threading import Lock
|
||||
|
@ -33,6 +34,7 @@ from configobj import ConfigObj
|
|||
# custom imports
|
||||
from api_clients import api_client
|
||||
from std_err_override import LogWriter
|
||||
import pure
|
||||
|
||||
# Set up command-line options
|
||||
parser = OptionParser()
|
||||
|
@ -71,6 +73,8 @@ parser.add_option("-c",
|
|||
# parse options
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
LIQUIDSOAP_MIN_VERSION = "1.1.1"
|
||||
|
||||
|
||||
#need to wait for Python 2.7 for this..
|
||||
#logging.captureWarnings(True)
|
||||
|
@ -152,7 +156,7 @@ def keyboardInterruptHandler(signum, frame):
|
|||
logger.info('\nKeyboard Interrupt\n')
|
||||
sys.exit(0)
|
||||
|
||||
def liquidsoap_running_test(telnet_lock, host, port, logger):
|
||||
def liquidsoap_get_info(telnet_lock, host, port, logger):
|
||||
logger.debug("Checking to see if Liquidsoap is running")
|
||||
try:
|
||||
telnet_lock.acquire()
|
||||
|
@ -161,14 +165,47 @@ def liquidsoap_running_test(telnet_lock, host, port, logger):
|
|||
tn.write(msg)
|
||||
tn.write("exit\n")
|
||||
response = tn.read_all()
|
||||
logger.info("Found: %s", response)
|
||||
except Exception, e:
|
||||
logger.error(str(e))
|
||||
return False
|
||||
return None
|
||||
finally:
|
||||
telnet_lock.release()
|
||||
|
||||
return "Liquidsoap" in response
|
||||
return get_liquidsoap_version(response)
|
||||
|
||||
def get_liquidsoap_version(version_string):
|
||||
m = re.match(r"Liquidsoap (\d+.\d+.\d+)", "Liquidsoap 1.1.1")
|
||||
|
||||
if m:
|
||||
return m.group(1)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
if m:
|
||||
current_version = m.group(1)
|
||||
return pure.version_cmp(current_version, LIQUIDSOAP_MIN_VERSION) >= 0
|
||||
return False
|
||||
|
||||
def liquidsoap_startup_test():
|
||||
|
||||
liquidsoap_version_string = \
|
||||
liquidsoap_get_info(telnet_lock, ls_host, ls_port, logger)
|
||||
while not liquidsoap_version_string:
|
||||
logger.warning("Liquidsoap doesn't appear to be running!, " + \
|
||||
"Sleeping and trying again")
|
||||
time.sleep(1)
|
||||
liquidsoap_version_string = \
|
||||
liquidsoap_get_info(telnet_lock, ls_host, ls_port, logger)
|
||||
|
||||
while pure.version_cmp(liquidsoap_version_string, LIQUIDSOAP_MIN_VERSION) < 0:
|
||||
logger.warning("Liquidsoap is running but in incorrect version! " + \
|
||||
"Make sure you have at least Liquidsoap %s installed" % LIQUIDSOAP_MIN_VERSION)
|
||||
time.sleep(1)
|
||||
liquidsoap_version_string = \
|
||||
liquidsoap_get_info(telnet_lock, ls_host, ls_port, logger)
|
||||
|
||||
logger.info("Liquidsoap version string found %s" % liquidsoap_version_string)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -204,9 +241,8 @@ if __name__ == '__main__':
|
|||
|
||||
ls_host = config['ls_host']
|
||||
ls_port = config['ls_port']
|
||||
while not liquidsoap_running_test(telnet_lock, ls_host, ls_port, logger):
|
||||
logger.warning("Liquidsoap not started yet. Sleeping one second and trying again")
|
||||
time.sleep(1)
|
||||
|
||||
liquidsoap_startup_test()
|
||||
|
||||
if options.test:
|
||||
g.test_api()
|
||||
|
|
|
@ -528,10 +528,6 @@ class PypoFetch(Thread):
|
|||
|
||||
|
||||
def main(self):
|
||||
# Bootstrap: since we are just starting up, we need to grab the
|
||||
# most recent schedule. After that we can just wait for updates.
|
||||
success = self.persistent_manual_schedule_fetch(max_attempts=5)
|
||||
|
||||
#Make sure all Liquidsoap queues are empty. This is important in the
|
||||
#case where we've just restarted the pypo scheduler, but Liquidsoap still
|
||||
#is playing tracks. In this case let's just restart everything from scratch
|
||||
|
@ -539,6 +535,10 @@ class PypoFetch(Thread):
|
|||
#Liquidsoap is playing much more easily.
|
||||
self.pypo_liquidsoap.clear_all_queues()
|
||||
|
||||
# Bootstrap: since we are just starting up, we need to grab the
|
||||
# most recent schedule. After that we can just wait for updates.
|
||||
success = self.persistent_manual_schedule_fetch(max_attempts=5)
|
||||
|
||||
if success:
|
||||
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
||||
self.set_bootstrap_variables()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue