diff --git a/aura.py b/aura.py index 50388b62dec83caaa5ceac9b51f7852ab5256444..97dd95be8b198447876748b1f07dbff64bcf4f5b 100755 --- a/aura.py +++ b/aura.py @@ -56,7 +56,9 @@ class Aura(AuraLogger): signal.signal(signal.SIGUSR1, receive_signal) self.join_comm() - # self.start_web_service() + + # dafuq? when starting web service, logging messages appear twice + self.start_web_service() def join_comm(self): # start listener thread @@ -64,6 +66,7 @@ class Aura(AuraLogger): def start_web_service(self): try: + self.logger.info("Listening on Port 5000 for API or Webcalls") Routes(self.scheduler, self.liquidsoapcommunicator, self.messenger) except OSError as e: self.messenger.halt() diff --git a/modules/communication/liquidsoap/communicator.py b/modules/communication/liquidsoap/communicator.py index 503f9d39d75d1bee1c184ab4f4a04a5d805307ff..6c6a7593ab46f67d453323e258ef0bc461f688dd 100644 --- a/modules/communication/liquidsoap/communicator.py +++ b/modules/communication/liquidsoap/communicator.py @@ -32,7 +32,7 @@ class LiquidSoapCommunicator(ExceptionLogger): connection_attempts = 0 # ------------------------------------------------------------------------------------------ # - def __init__(self, config): + def __init__(self, config, logger=True): """ Constructor """ @@ -603,6 +603,11 @@ class LiquidSoapCommunicator(ExceptionLogger): self.disable_transaction(force=True) self.error("channel_volume", errnum="03") + # ------------------------------------------------------------------------------------------ # + def auraengine_state(self): + state = self.__send_lqc_command__(self.client, "auraengine", "state") + return state + # ------------------------------------------------------------------------------------------ # def current_data(self): """ diff --git a/modules/communication/liquidsoap/playerclient.py b/modules/communication/liquidsoap/playerclient.py index 79bbb204ffe23687d35de6e8c308f4ad6b64784a..46f87a731f7b39072ab1203b5a87fe0fa663bce4 100644 --- a/modules/communication/liquidsoap/playerclient.py +++ b/modules/communication/liquidsoap/playerclient.py @@ -34,6 +34,18 @@ class LiquidSoapPlayerClient(LiquidSoapClient): return "LiquidSoapPlayerClient does not understand fs." + command + str(args) + # ------------------------------------------------------------------------------------------ # + def auraengine(self, command, *args): + if command == "state": + return self.auraengine_state() + + return "LiquidSoapPlayerClient does not understand auraengine." + command + str(args) + + # ------------------------------------------------------------------------------------------ # + def auraengine_state(self): + self.command('auraengine', 'state') + return self.message + # ------------------------------------------------------------------------------------------ # def fs_push(self, uri): self.command('fs', 'push', uri) diff --git a/modules/liquidsoap/in_alsa.liq b/modules/liquidsoap/in_alsa.liq deleted file mode 100644 index 21997c408f693aeedafa2104f089ce05af156629..0000000000000000000000000000000000000000 --- a/modules/liquidsoap/in_alsa.liq +++ /dev/null @@ -1,36 +0,0 @@ - -if a0_in != "" then - # we can ignore the result, since it is stored in the list 'inputs' - set_input(a0_in, "aura_linein_0") -end - -if a1_in != "" then - ignore(set_input(a1_in, "aura_linein_1")) - -# input_1 = ref output.dummy(blank()) -# set_input(input_1, a1_in, "aura_linein_1") -# inputs := list.append([!input_1], !inputs) -end - -if a2_in != "" then - ignore(set_input(a2_in, "aura_linein_2")) - -# input_2 = ref output.dummy(blank()) -# set_input(input_2, a2_in, "aura_linein_2") -# inputs := list.append([!input_2], !inputs) -end - -if a3_in != "" then - ignore(set_input(a3_in, "aura_linein_3")) - -# input_3 = ref output.dummy(blank()) -# set_input(input_3, a3_in, "aura_linein_3") -# inputs := list.append([!input_3], !inputs) -end - -if a4_in != "" then - ignore(set_input(a4_in, "aura_linein_4")) -# input_4 = ref output.dummy(blank()) -# set_input(input_4, a4_in, "aura_linein_4") -# inputs := list.append([!input_4], !inputs) -end \ No newline at end of file diff --git a/modules/liquidsoap/out_recorder.liq b/modules/liquidsoap/out_recorder.liq deleted file mode 100644 index eb5800a76d27460eb6c93f9957efead3083e0e50..0000000000000000000000000000000000000000 --- a/modules/liquidsoap/out_recorder.liq +++ /dev/null @@ -1,74 +0,0 @@ -r0_enable = list.assoc("rec_0", ini) == "y" -r1_enable = list.assoc("rec_1", ini) == "y" -r2_enable = list.assoc("rec_2", ini) == "y" -r3_enable = list.assoc("rec_3", ini) == "y" -r4_enable = list.assoc("rec_4", ini) == "y" - -r0_folder = list.assoc("rec_0_folder", ini) -r0_duration = int_of_string(list.assoc("rec_0_duration", ini)) -r0_encoding = list.assoc("rec_0_encoding", ini) -r0_bitrate = int_of_string(list.assoc("rec_0_bitrate", ini)) -r0_channels = list.assoc("rec_0_channels", ini) -r0_filenamepattern = r0_folder^"/%Y-%m-%d/%Y-%m-%d-%H-%M."^r0_encoding - -r1_folder = list.assoc("rec_1_folder", ini) -r1_duration = int_of_string(list.assoc("rec_1_duration", ini)) -r1_encoding = list.assoc("rec_1_encoding", ini) -r1_bitrate = int_of_string(list.assoc("rec_1_bitrate", ini)) -r1_channels = list.assoc("rec_1_channels", ini) -r1_filenamepattern = r1_folder^"/%Y-%m-%d/%Y-%m-%d-%H-%M."^r1_encoding - -r2_folder = list.assoc("rec_2_folder", ini) -r2_duration = int_of_string(list.assoc("rec_2_duration", ini)) -r2_encoding = list.assoc("rec_2_encoding", ini) -r2_bitrate = int_of_string(list.assoc("rec_2_bitrate", ini)) -r2_channels = list.assoc("rec_2_channels", ini) -r2_filenamepattern = r2_folder^"/%Y-%m-%d/%Y-%m-%d-%H-%M."^r2_encoding - -r3_folder = list.assoc("rec_3_folder", ini) -r3_duration = int_of_string(list.assoc("rec_3_duration", ini)) -r3_encoding = list.assoc("rec_3_encoding", ini) -r3_bitrate = int_of_string(list.assoc("rec_3_bitrate", ini)) -r3_channels = list.assoc("rec_3_channels", ini) -r3_filenamepattern = r3_folder^"/%Y-%m-%d/%Y-%m-%d-%H-%M."^r3_encoding - -r4_folder = list.assoc("rec_4_folder", ini) -r4_duration = int_of_string(list.assoc("rec_4_duration", ini)) -r4_encoding = list.assoc("rec_4_encoding", ini) -r4_bitrate = int_of_string(list.assoc("rec_4_bitrate", ini)) -r4_channels = list.assoc("rec_4_channels", ini) -r4_filenamepattern = r4_folder^"/%Y-%m-%d/%Y-%m-%d-%H-%M."^r4_encoding - -r0_is_recording = ref false -r1_is_recording = ref false -r2_is_recording = ref false -r3_is_recording = ref false -r4_is_recording = ref false - -if r0_enable == true then - # enable recording status for that recorder - server.register(namespace="recorder_0", "recording", fun (s) -> begin if !r0_is_recording == false then "false" else "true" end end) - - # start the recorder - start_recorder(r0_folder, r0_duration, r0_encoding, r0_bitrate, r0_channels, r0_filenamepattern, r0_is_recording, output_source, "0") -end - -if r1_enable == true then - server.register(namespace="recorder_1", "recording", fun (s) -> begin if !r1_is_recording == false then "false" else "true" end end) - start_recorder(r1_folder, r1_duration, r1_encoding, r1_bitrate, r1_channels, r1_filenamepattern, r1_is_recording, output_source, "1") -end - -if r2_enable == true then - server.register(namespace="recorder_2", "recording", fun (s) -> begin if !r2_is_recording == false then "false" else "true" end end) - start_recorder(r2_folder, r2_duration, r2_encoding, r2_bitrate, r2_channels, r2_filenamepattern, r2_is_recording, output_source, "2") -end - -if r3_enable == true then - server.register(namespace="recorder_3", "recording", fun (s) -> begin if !r3_is_recording == false then "false" else "true" end end) - start_recorder(r3_folder, r3_duration, r3_encoding, r3_bitrate, r3_channels, r3_filenamepattern, r3_is_recording, output_source, "3") -end - -if r4_enable == true then - server.register(namespace="recorder_4", "recording", fun (s) -> begin if !r4_is_recording == false then "false" else "true" end end) - start_recorder(r4_folder, r4_duration, r4_encoding, r4_bitrate, r4_channels, r4_filenamepattern, r4_is_recording, output_source, "4") -end \ No newline at end of file diff --git a/modules/liquidsoap/recorder.liq b/modules/liquidsoap/recorder.liq deleted file mode 100644 index bc92f4cc86abdbc59084d2d3ddcd033d90dc8fe1..0000000000000000000000000000000000000000 --- a/modules/liquidsoap/recorder.liq +++ /dev/null @@ -1,138 +0,0 @@ -# define file name pattern -filenamepattern = ref audiobase^"/%Y-%m-%d/%Y-%m-%d-%H-%M.flac" - -# Der aktuelle Dateiname für die Aufnahme -recordingfile = ref "" - -# bewahre uns davor, dass zweimal gleichzeitig die gleiche Date aufgenommen wird -is_record_active = ref false - -#wir definieren eine Referenz für die Stop-Funktion, die aber bisher noch nichts tun kann -stop_f = ref (fun () -> ()) - - - -def start_wav_output(recfile, filenamepattern, recorder_number) - duration = int_of_string(list.assoc("rec_"^recorder_number^"_duration", ini)) - channels = int_of_string(list.assoc("rec_"^recorder_number^"_channels", ini)) - samplesize = int_of_string(list.assoc("rec_"^recorder_number^"_samplesize", ini)) - - ignore(duration) - ignore(channels) - ignore(samplesize) - -# def on_start() -# recfile := list.hd(get_process_lines("date +#{!filenamepattern}")) -# end -# def on_close(filename) -# recordingfile := list.hd(get_process_lines("date +#{!filenamepattern}")) -# end - - print(channels) - print(samplesize) - #out_wav = output.file(id="recorder", perm = 0o664, on_start=on_start, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }) - #out_wav(%wav(stereo=true, channels=2, samplesize=8, header=true, !filenamepattern, output_source) - #ignore(out_wav) - - output.dummy(id="wav_dummy_recording", blank()) - -# if channels == 2 then -# output.file(id="recorder", %wav(stereo=true, channels=2, samplesize=8, header=true), perm = 0o664, on_start=on_start, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }, !filenamepattern, audio_to_stereo(output_source)) -## out_wav(output_source) -# else -# output.file(id="recorder", %wav(stereo=true, channels=1, samplesize=8, header=true), perm = 0o664, on_start=on_start, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }, !filenamepattern, output_source) - # out_wav(output_source) -# end - - #if channels == 2 then - # if samplesize < 12 then - # ignore(out_wav(%wav(stereo=true, channels=2, samplesize=8, header=true), !filenamepattern, output_source)) - # else - # ignore(out_wav(%wav(stereo=true, channels=2, samplesize=16, header=true), !filenamepattern, output_source)) - # end - #else - # if samplesize < 12 then - # ignore(out_wav(%wav(stereo=true, channels=1, samplesize=8, header=true), !filenamepattern, output_source)) - # else - # ignore(out_wav(%wav(stereo=true, channels=1, samplesize=16, header=true), !filenamepattern, output_source)) - # end - #end -end - -def start_flac_output(recorder_number, filenamepattern, duration) -# duration = int_of_string(list.assoc("rec_"^recorder_number^"_samplerate", ini)) -# samplerate = list.assoc("rec_"^recorder_number^"_samplerate", ini) - channels = int_of_string(list.assoc("rec_"^recorder_number^"_channels", ini)) -# compression = int_of_string(list.assoc("rec_"^recorder_number^"_compression", ini)) -# bits_per_sample = int_of_string(list.assoc("rec_"^recorder_number^"_bits_per_sample", ini)) - #output.file(id="recorder", %flac(samplerate=44100, channels=1, compression=7, bits_per_sample=32), perm = 0o664, on_start=on_start, !filenamepattern, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }, output_source) - - recfile = ref '' - - def on_start() - recfile := list.hd(get_process_lines("date +#{filenamepattern}")) - end - def on_close(filename) - recfile := list.hd(get_process_lines("date +#{filenamepattern}")) - end - - # dumbass liquidsoap cannot handle one output definition for mono and stereo - output_filesystem_mono = output.file(id="recorder", perm = 0o664, on_start=on_start, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }) - output_filesystem_stereo = output.file(id="recorder", perm = 0o664, on_start=on_start, on_close=on_close, reopen_when={ int_of_float(gettimeofday()/60.) mod duration == 0 }) - - ignore(output_filesystem_mono) - ignore(output_filesystem_stereo) - - if channels == 2 then - output.dummy(id="flac_dummy_recording_stereo", blank()) -# output_stereof(%flac(samplerate=44100, channels=1, compression=1, bits_per_sample=16), !filenamepattern, output_source) - else - output.dummy(id="flac_dummy_recording_mono", blank()) -# output_icecast_monof(%flac(samplerate=44100, channels=1, compression=1, bits_per_sample=16), !filenamepattern, output_source) - end - - -end - - - - - -def enable_stop_function(record) - # Die Stopfunkton zeigt nun auf die Shutdown-Funktion der aktuellen Source - stop_f := fun () -> begin - log('stop recording') - # Aufnahme sauber beenden - ignore(server.execute('recorder.stop')) - # Source zerstören - source.shutdown(record) - # Variable zurücksetzen - recordingfile := "" - end -end - -def set_recorder_output(rec_filetype, recorder_number) - # flac output - if rec_filetype == 'flac' then - log("output file type is FLAC") - record = start_flac_output(recorder_number) - enable_stop_function(record) - - # WAV output - else - log("output file type is WAV") - record = start_wav_output(recorder_number) - enable_stop_function(record) - end -end - -# shows current file and how many bytes were written so far -def currecording() - curfile = !recordingfile - if curfile != "" then - bytes_written = list.hd(get_process_lines("echo $(($(stat -c%s "^curfile^")))")) - "#{curfile}, #{bytes_written}B" - else - "" - end -end \ No newline at end of file diff --git a/modules/liquidsoap/serverfunctions.liq b/modules/liquidsoap/serverfunctions.liq index db26a7e35370294d04b421619fcee04debfdf2b5..6db4e104864b41a3ac0dae122acde362a2f9e21a 100644 --- a/modules/liquidsoap/serverfunctions.liq +++ b/modules/liquidsoap/serverfunctions.liq @@ -46,18 +46,18 @@ server.register(namespace="auraengine", ret = '{' ret = ret^'"streams": {' - ret = ret^'"stream_0": {"enabled": #{s0_enable}},' - ret = ret^'"stream_1": {"enabled": #{s1_enable}},' - ret = ret^'"stream_2": {"enabled": #{s2_enable}},' - ret = ret^'"stream_3": {"enabled": #{s3_enable}},' - ret = ret^'"stream_4": {"enabled": #{s4_enable}}' + ret = ret^'"stream_0": {"enabled": #{s0_enable}, "connected": #{!s0_connected}},' + ret = ret^'"stream_1": {"enabled": #{s1_enable}, "connected": #{!s1_connected}},' + ret = ret^'"stream_2": {"enabled": #{s2_enable}, "connected": #{!s2_connected}},' + ret = ret^'"stream_3": {"enabled": #{s3_enable}, "connected": #{!s3_connected}},' + ret = ret^'"stream_4": {"enabled": #{s4_enable}, "connected": #{!s4_connected}}' ret = ret^'},' ret = ret^'"recorder": {' - ret = ret^'"recorder_0": {"enabled": #{r0_enable}},' - ret = ret^'"recorder_1": {"enabled": #{r1_enable}},' - ret = ret^'"recorder_2": {"enabled": #{r2_enable}},' - ret = ret^'"recorder_3": {"enabled": #{r3_enable}},' - ret = ret^'"recorder_4": {"enabled": #{r4_enable}}' + ret = ret^'"recorder_0": {"enabled": #{r0_enable}, "recording": #{!r0_is_recording}},' + ret = ret^'"recorder_1": {"enabled": #{r1_enable}, "recording": #{!r1_is_recording}},' + ret = ret^'"recorder_2": {"enabled": #{r2_enable}, "recording": #{!r2_is_recording}},' + ret = ret^'"recorder_3": {"enabled": #{r3_enable}, "recording": #{!r3_is_recording}},' + ret = ret^'"recorder_4": {"enabled": #{r4_enable}, "recording": #{!r4_is_recording}}' ret = ret^'},' ret = ret^'"linein": {' ret = ret^'"linein_0": {"enabled": #{a0_in != ""}},' diff --git a/modules/liquidsoap/stream.liq b/modules/liquidsoap/stream.liq deleted file mode 100644 index d1f0aabeeb44495404e3960888513674cfa65c25..0000000000000000000000000000000000000000 --- a/modules/liquidsoap/stream.liq +++ /dev/null @@ -1,125 +0,0 @@ - -def get_icecast_mp3_stream(number) - stream_bitrate = int_of_string(list.assoc("stream_#{number}_bitrate", ini)) - stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) - stream_host = list.assoc("stream_#{number}_host", ini) - stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) - stream_name = list.assoc("stream_#{number}_name", ini) - stream_url = list.assoc("stream_#{number}_url", ini) - stream_genre = list.assoc("stream_#{number}_genre", ini) - stream_description = list.assoc("stream_#{number}_description", ini) - stream_user = list.assoc("stream_#{number}_user", ini) - stream_password = list.assoc("stream_#{number}_password", ini) - - - - if stream_bitrate == 24 then - icecast_stream = output.icecast(%mp3(bitrate = 24, samplerate = 22050), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [icecast_stream] - ) - icecast_stream - else - icecast_stream = output.icecast(%mp3(samplerate = 44100), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [icecast_stream] - ) - icecast_stream - end -end - -def get_icecast_ogg_stream(number) - stream_quality = float_of_string(list.assoc("stream_#{number}_quality", ini)) - - stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) - stream_host = list.assoc("stream_#{number}_host", ini) - stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) - stream_name = list.assoc("stream_#{number}_name", ini) - stream_url = list.assoc("stream_#{number}_url", ini) - stream_genre = list.assoc("stream_#{number}_genre", ini) - stream_description = list.assoc("stream_#{number}_description", ini) - stream_user = list.assoc("stream_#{number}_user", ini) - stream_password = list.assoc("stream_#{number}_password", ini) - - if stream_quality >= 0.5 then - icecast_stream = output.icecast(%vorbis(quality = 1.0), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [icecast_stream] - ) - icecast_stream - else - icecast_stream = output.icecast(%vorbis(quality = 0.1), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [icecast_stream] - ) - icecast_stream - end -end - -def get_harbour_mp3_stream(number) - - stream_bitrate = int_of_string(list.assoc("stream_#{number}_bitrate", ini)) - stream_user = list.assoc("stream_#{number}_user", ini) - stream_password = list.assoc("stream_#{number}_password", ini) - stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) - stream_url = list.assoc("stream_#{number}_url", ini) - stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) - - if stream_bitrate == 24 then - harbourstream = output.harbor(%mp3(bitrate = 24, samplerate = 22050), user=stream_user, password=stream_password, id="stream", port=stream_port, url=stream_url, mount=stream_mountpoint, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [harbourstream] - ) - harbourstream - else - harbourstream = output.harbor(%mp3, user=stream_user, password=stream_password, id="stream", port=stream_port, url=stream_url, mount=stream_mountpoint, icy_metadata="true", fallible=true, buffer(output_source)) - clock.assign_new(id="stream_#{number}", - [harbourstream] - ) - harbourstream - end -end - -def get_stream(number) - stream = list.assoc("stream_#{number}", ini) - stream_type = list.assoc("stream_#{number}_type", ini) - stream_format = list.assoc("stream_#{number}_format", ini) - - # is stream enabled? - if stream == "y" then - log("activating stream #{number}") - if stream_type == "icecast" then - log("its an icecast stream") - if stream_format == "mp3" then - log("filled with mp3") - get_icecast_mp3_stream(number) - elsif stream_format == "vorbis" then - log("filled with ogg") - get_icecast_ogg_stream(number) - else - output.dummy(id="no_valid_stream_format_DUMMY_ICECAST", blank()) - end - - elsif stream_type == "harbor" then - log("its an harbor stream") - if stream_format == "mp3" then - get_harbour_mp3_stream(number) - else - output.dummy(id="no_valid_stream_format_DUMMY_HARBOUR", blank()) - end - else - output.dummy(id="no_valid_stream_type_DUMMY", blank()) - end - else - output.dummy(id="no_stream_enabled_DUMMY", blank()) - end -end - -def set_streams() - stream_0 = get_stream(0) - #stream_1 = get_stream(1) - #stream_2 = get_stream(2) - #stream_3 = get_stream(3) - #stream_4 = get_stream(4) -end - diff --git a/modules/web/routes.py b/modules/web/routes.py index f2968c485a46f6d07735701173bd6fcdc1457359..caa731993679d9ea1978cb4b0846056c954a0b15 100644 --- a/modules/web/routes.py +++ b/modules/web/routes.py @@ -11,6 +11,8 @@ from flask import request, render_template from libraries.database.database import APP from libraries.database.broadcasts import TrackService, Schedule + + def alchemyencoder(obj): logger = logging.getLogger("AuraEngine") logger.warning(str(type(obj))) @@ -34,7 +36,7 @@ class Routes: lqs_communicator = None def __init__(self, scheduler, lqs_communicator, messenger): - self.logger = logging.getLogger("AuraEngine") + #self.logger = logging.getLogger("AuraEngine") self.scheduler = scheduler self.messenger = messenger @@ -92,31 +94,46 @@ class Routes: @staticmethod @APP.route("/logout") def logout(): - session.pop("logged_in", None) + #session.pop("logged_in", None) return "logout" #return render_template("index.html") @staticmethod @APP.route("/api/v1/trackservice/<selected_date>", methods=["GET"]) def api_trackservice(selected_date): - tracks_on_selected_date = None - - # convert date try: + # convert date selected_date = datetime.datetime.strptime(selected_date, "%Y-%m-%d").date() + # select from database tracks_on_selected_date = TrackService.select_by_day(selected_date) - - tracks_on_selected_date_in_json = simplejson.dumps([tracks._asdict() for tracks in tracks_on_selected_date], default=alchemyencoder) + # return as json + return simplejson.dumps([tracks._asdict() for tracks in tracks_on_selected_date], default=alchemyencoder) except Exception as e: import traceback traceback.print_exc() + error = "Cannot transform programme into JSON String. Reason: " + str(e) + logger = logging.getLogger("AuraEngine") - logger.error("Cannot transform programme into JSON String. Reason: " + str(e)) + logger.error(error) - return simplejson.dumps({"Error": str(e)}) + return simplejson.dumps({"Error": error}) + + @staticmethod + @APP.route("/api/v1/soundserver_state", methods=["GET"]) + def soundserver_settings(): + from modules.communication.liquidsoap.communicator import LiquidSoapCommunicator + from modules.base.config import ConfigReader + + try: + cr = ConfigReader() + cr.load_config() + lqs = LiquidSoapCommunicator(cr) + return lqs.auraengine_state() + except Exception as e: + error = "Unable to fetch state from Liquidsoap. Is Soundserver running? Reason: " + str(e) + return simplejson.dumps({"Error": error}) - return tracks_on_selected_date_in_json @staticmethod @APP.route("/api/v1/trackservice/", methods=["GET"])