add chaudum fixes

This commit is contained in:
Kyle Robbertze 2020-01-20 14:44:17 +02:00
parent 8346e89e99
commit ea54493c21
9 changed files with 33 additions and 49 deletions

View File

@ -58,6 +58,7 @@ addons:
- liquidsoap-plugin-faad
- liquidsoap-plugin-vorbis
- liquidsoap-plugin-opus
- python3
- python3-nose
- python3-gst-1.0
- python3-magic

View File

@ -8,7 +8,6 @@
###############################################################################
import sys
import time
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse
import requests
import socket
@ -21,26 +20,6 @@ from configobj import ConfigObj
AIRTIME_API_VERSION = "1.1"
# TODO : Place these functions in some common module. Right now, media
# monitor uses the same functions and it would be better to reuse them
# instead of copy pasting them around
def to_unicode(obj, encoding='utf-8'):
if isinstance(obj, str):
if not isinstance(obj, str):
obj = str(obj, encoding)
return obj
def encode_to(obj, encoding='utf-8'):
if isinstance(obj, str):
obj = obj.encode(encoding)
return obj
def convert_dict_value_to_utf8(md):
#list comprehension to convert all values of md to utf-8
return dict([(item[0], encode_to(item[1], "utf-8")) for item in list(md.items())])
api_config = {}
# URL to get the version number of the server API
@ -407,7 +386,7 @@ class AirtimeApiClient(object):
# Note that we must prefix every key with: mdX where x is a number
# Is there a way to format the next line a little better? The
# parenthesis make the code almost unreadable
md_list = dict((("md%d" % i), json.dumps(convert_dict_value_to_utf8(md))) \
md_list = dict((("md%d" % i), json.dumps(md)) \
for i,md in enumerate(valid_actions))
# For testing we add the following "dry" parameter to tell the
# controller not to actually do any changes

View File

@ -14,6 +14,6 @@ try:
tn.read_all()
except Exception as e:
print(('Error loading config file: %s', e))
print("Error loading config file: {}".format(e))
sys.exit()

View File

@ -120,7 +120,7 @@ try:
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)
except Exception as e:
print(("Couldn't configure logging", e))
print("Couldn't configure logging: {}".format(e))
sys.exit(1)

View File

@ -109,7 +109,7 @@ class ListenerStat(Thread):
#Note that there can be optimizations done, since if all three
#streams are the same server, we will still initiate 3 separate
#connections
for k, v in list(stream_parameters.items()):
for k, v in stream_parameters.items():
if v["enable"] == 'true':
try:
if v["output"] == "icecast":

View File

@ -344,7 +344,7 @@ class PypoFetch(Thread):
media_item = media[key]
if (media_item['type'] == 'file'):
fileExt = self.sanity_check_media_item(media_item)
dst = os.path.join(download_dir, str(media_item['id']) + str(fileExt))
dst = os.path.join(download_dir, media_item['id'] + fileExt)
media_item['dst'] = dst
media_item['file_ready'] = False
media_filtered[key] = media_item
@ -357,7 +357,8 @@ class PypoFetch(Thread):
self.media_prepare_queue.put(copy.copy(media_filtered))
except Exception as e: self.logger.error("%s", e)
except Exception as e:
self.logger.error(e)
# Send the data to pypo-push
self.logger.debug("Pushing to pypo-push")
@ -365,8 +366,10 @@ class PypoFetch(Thread):
# cleanup
try: self.cache_cleanup(media)
except Exception as e: self.logger.error("%s", e)
try:
self.cache_cleanup(media)
except Exception as e:
self.logger.error(e)
#do basic validation of file parameters. Useful for debugging
#purposes
@ -408,7 +411,7 @@ class PypoFetch(Thread):
for mkey in media:
media_item = media[mkey]
if media_item['type'] == 'file':
scheduled_file_set.add(str(media_item["id"]) + str(media_item["file_ext"]))
scheduled_file_set.add(media_item["id"] + media_item["file_ext"])
expired_files = cached_file_set - scheduled_file_set

View File

@ -125,7 +125,7 @@ class PypoLiquidsoap():
scheduled_now_webstream = \
[x for x in scheduled_now if x["type"] == eventtypes.STREAM_OUTPUT_START]
schedule_ids = set([x["row_id"] for x in scheduled_now_files])
schedule_ids = {x["row_id"] for x in scheduled_now_files]}
row_id_map = {}
liq_queue_ids = set()
@ -199,7 +199,7 @@ class PypoLiquidsoap():
return media_item["type"] == eventtypes.FILE
def clear_queue_tracker(self):
for i in list(self.liq_queue_tracker.keys()):
for i in self.liq_queue_tracker.keys():
self.liq_queue_tracker[i] = None
def modify_cue_point(self, link):

View File

@ -37,7 +37,7 @@ def api_client(logger):
try:
config = ConfigObj('/etc/airtime/airtime.conf')
except Exception as e:
print(('Error loading config file: %s', e))
print("Error loading config file: {}".format(e))
sys.exit()
# TODO : add docstrings everywhere in this module
@ -131,7 +131,7 @@ class ShowRecorder(Thread):
register_openers()
# files is what requests actually expects
files = {'file': open(filepath, "rb"), 'name': filename, 'show_instance': str(self.show_instance)}
files = {'file': open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance}
self.api_client.upload_recorded_show(files, self.show_instance)
@ -153,7 +153,7 @@ class ShowRecorder(Thread):
recorded_file['title'] = "%s-%s-%s" % (self.show_name,
full_date, full_time)
#You cannot pass ints into the metadata of a file. Even tracknumber needs to be a string
recorded_file['tracknumber'] = str(self.show_instance)
recorded_file['tracknumber'] = self.show_instance
recorded_file.save()
except Exception as e:

View File

@ -4,11 +4,12 @@ set -xe
[[ "$PYTHON" == false ]] && exit 0
python3 --version
pushd python_apps/airtime_analyzer
pyenv local 3.7
pyenv local 3.4
pip3 install -e .
nosetests -a '!rgain'
echo "replaygain tests where skipped due to not having a reliable replaygain install on travis."
nosetests
popd
echo "Building docs..."