Commit f6f0af4e authored by David Trattnig's avatar David Trattnig
Browse files

Linting and grouping.

parent 8f0891f0
......@@ -36,12 +36,11 @@ from flask_restful import Api, Resource, abort
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.flask import FlaskPlugin
# import werkzeug
from werkzeug.exceptions import HTTPException, default_exceptions, Aborter
from modules.base.logger import AuraLogger
from modules.base.config import AuraConfig
from modules.base.models import AuraDatabaseModel, Schedule, Playlist, PlaylistEntry, PlaylistEntryMetaData, TrackService
from modules.base.models import AuraDatabaseModel, Schedule, Playlist, PlaylistEntry, PlaylistEntryMetaData
......
......@@ -181,7 +181,7 @@ class AuraEngine:
if __name__ == "__main__":
engine = AuraEngine()
lqs_startup = True
start_lqs = True
lqs_cmd = False
signal.signal(signal.SIGINT, engine.exit_gracefully)
......@@ -189,7 +189,7 @@ if __name__ == "__main__":
if len(sys.argv) >= 2:
if "--without-lqs" in sys.argv:
lqs_startup = False
start_lqs = False
if "--get-lqs-command" in sys.argv:
lqs_cmd = True
if "--use-test-data" in sys.argv:
......@@ -200,4 +200,4 @@ if __name__ == "__main__":
if lqs_cmd:
print(engine.get_lqs_cmd(True, True))
else:
engine.startup(lqs_startup)
engine.startup(start_lqs)
......@@ -26,7 +26,7 @@ class MailingException(Exception):
"""
Thrown when some mail cannot be sent.
"""
pass
......
......@@ -25,19 +25,18 @@ import datetime
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm, func
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey, ForeignKeyConstraint
from sqlalchemy import orm
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import false, true
from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy import create_engine
from modules.base.enum import Channel, ChannelType, PlaylistType
from modules.scheduling.types import PlaylistType
from modules.base.config import AuraConfig
from modules.base.utils import SimpleUtil, EngineUtil
# Init Config
config = AuraConfig()
......
......@@ -21,7 +21,8 @@ import datetime
import time
from enum import Enum
from modules.base.enum import Channel, ChannelType, PlaylistType
from modules.core.channels import ChannelType
from modules.scheduling.types import PlaylistType
......
......@@ -19,7 +19,7 @@
import json
from modules.base.enum import RedisChannel
from modules.cli.redis.channels import RedisChannel
from modules.base.utils import TerminalColors
from modules.cli.redis.adapter import ClientRedisAdapter, ServerRedisAdapter
from modules.base.models import AuraDatabaseModel
......
......@@ -31,7 +31,7 @@ from modules.cli.redis.messenger import RedisMessenger
from modules.cli.redis.statestore import RedisStateStore
# from modules.communication.connection_tester import ConnectionTester
from modules.base.exceptions import RedisConnectionException
from modules.base.enum import RedisChannel
from modules.cli.redis.channels import RedisChannel
from modules.base.utils import TerminalColors
......
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-2020 - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
class RedisChannel(Enum):
STANDARD = "aura"
DPE_REPLY = "delete_playlist_entry_reply"
FNP_REPLY = "fetch_new_programme_reply"
GAP_REPLY = "get_act_programme_reply"
GS_REPLY = "get_status_reply"
GCS_REPLY = "get_connection_status_reply"
GNF_REPLY = "get_next_file_reply"
IPE_REPLY = "insert_playlist_entry_reply"
IP_REPLY = "init_player_reply"
TS_REPLY = "track_service_reply"
MPE_REPLY = "move_playlist_entry_reply"
PMQ_REPLY = "print_message_queue_reply"
RDB_REPLY = "recreate_database_reply"
SNF_REPLY = "get_next_file_reply"
......@@ -22,7 +22,7 @@ import logging
from modules.cli.redis.statestore import RedisStateStore
from modules.base.enum import RedisChannel
from modules.cli.redis.channels import RedisChannel
"""
......
......@@ -21,24 +21,14 @@ from enum import Enum
class RedisChannel(Enum):
STANDARD = "aura"
DPE_REPLY = "delete_playlist_entry_reply"
FNP_REPLY = "fetch_new_programme_reply"
GAP_REPLY = "get_act_programme_reply"
GS_REPLY = "get_status_reply"
GCS_REPLY = "get_connection_status_reply"
GNF_REPLY = "get_next_file_reply"
IPE_REPLY = "insert_playlist_entry_reply"
IP_REPLY = "init_player_reply"
TS_REPLY = "track_service_reply"
MPE_REPLY = "move_playlist_entry_reply"
PMQ_REPLY = "print_message_queue_reply"
RDB_REPLY = "recreate_database_reply"
SNF_REPLY = "get_next_file_reply"
class TransitionType(Enum):
"""
Types of fade-in and fade-out transition.
"""
INSTANT = "instant"
FADE = "fade"
class Channel(Enum):
"""
Channel name mappings to the Liqidsoap channel IDs
......@@ -94,39 +84,6 @@ class ChannelType(Enum):
return str(self.value["id"])
class TransitionType(Enum):
"""
Types of fade-in and fade-out transition.
"""
INSTANT = "instant"
FADE = "fade"
class PlaylistType(Enum):
DEFAULT = { "id": 0, "name": "default" } # Default play mode
SHOW = { "id": 1, "name": "show" } # The first played when some default playlist fails
TIMESLOT = { "id": 2, "name": "timeslot" } # The second played when the timeslot fallback fails
STATION = { "id": 3, "name": "station" } # The last played when everything else fails
@property
def id(self):
return self.value["id"]
def __str__(self):
return str(self.value["name"])
class TimerType(Enum):
SWITCH = "switch"
FADEIN = "fadein"
FADEOUT = "fadeout"
class EntryQueueState(Enum):
OKAY = "ok"
CUT = "cut"
OUT_OF_SCHEDULE = "oos"
class EntryPlayState(Enum):
UNKNOWN = "unknown"
LOADING = "loading"
......@@ -139,4 +96,4 @@ class LiquidsoapResponse(Enum):
STREAM_STATUS_POLLING = "polling"
STREAM_STATUS_STOPPED = "stopped"
STREAM_STATUS_CONNECTED = "connected"
\ No newline at end of file
......@@ -20,21 +20,18 @@
import time
import logging
from urllib.parse import urlparse, ParseResult
from contextlib import suppress
from threading import Thread
import meta
from modules.base.enum import ChannelType, Channel, TransitionType, LiquidsoapResponse, EntryPlayState
from modules.base.utils import TerminalColors, SimpleUtil as SU, EngineUtil
from modules.base.exceptions import LQConnectionError, InvalidChannelException, NoActiveEntryException, LQStreamException, LoadSourceException
from modules.core.liquidsoap.playerclient import LiquidSoapPlayerClient
# from modules.core.liquidsoap.recorderclient import LiquidSoapRecorderClient
from modules.base.exceptions import LQConnectionError, InvalidChannelException, LQStreamException, LoadSourceException
from modules.core.channels import ChannelType, Channel, TransitionType, LiquidsoapResponse, EntryPlayState
from modules.core.startup import StartupThread
from modules.core.state import PlayerStateService
from modules.core.events import EngineEventDispatcher
from modules.core.liquidsoap.playerclient import LiquidSoapPlayerClient
# from modules.core.liquidsoap.recorderclient import LiquidSoapRecorderClient
class SoundSystem():
......
......@@ -21,7 +21,6 @@ import logging
from modules.base.utils import SimpleUtil as SU
from modules.base.exceptions import NoActiveEntryException
# from modules.base.exceptions import LQConnectionError, InvalidChannelException, NoActiveEntryException, EngineMalfunctionException, LQStreamException, LoadSourceException
from modules.base.mail import AuraMailer
from modules.plugins.monitor import AuraMonitor
from modules.core.state import PlayerStateService
......@@ -203,7 +202,7 @@ class EngineEventDispatcher():
Callend when no entry is playing
"""
self.logger.debug("on_idle(..)")
self.logger.warn(SU.red("Currently there's nothing playing!"))
self.logger.error(SU.red("Currently there's nothing playing!"))
self.call_event("on_idle", None)
......
......@@ -17,7 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from modules.base.enum import Channel
# FIXME Refactor to avoid use of Channel Class here
from modules.core.channels import Channel
from modules.core.liquidsoap.client import LiquidSoapClient
......@@ -257,17 +258,17 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
# ------------------------------------------------------------------------------------------ #
def recorder(self, num, command, *args):
if command == "status":
return self.recorderstatus(num)
# def recorder(self, num, command, *args):
# if command == "status":
# return self.recorderstatus(num)
if command == "start":
return self.recorderstart(num)
# if command == "start":
# return self.recorderstart(num)
if command == "stop":
return self.recorderstop(num)
# if command == "stop":
# return self.recorderstop(num)
return "LiquidSoapPlayerClient does not understand mixer." + command + str(args)
# return "LiquidSoapPlayerClient does not understand mixer." + command + str(args)
# ------------------------------------------------------------------------------------------ #
......
......@@ -26,7 +26,7 @@ import logging
from datetime import datetime
from modules.base.enum import PlaylistType
from modules.scheduling.types import PlaylistType
from modules.base.utils import SimpleUtil
from modules.base.models import Schedule, Playlist, PlaylistEntry, PlaylistEntryMetaData
from modules.scheduling.calender_fetcher import CalendarFetcher
......
......@@ -27,10 +27,10 @@ import random
import librosa
from accessify import private, protected
from modules.base.enum import PlaylistType
from modules.scheduling.types import PlaylistType
from modules.base.utils import SimpleUtil, EngineUtil
from modules.base.mail import AuraMailer
from modules.base.enum import ChannelType
from modules.core.channels import ChannelType
class FallbackManager:
......
......@@ -18,25 +18,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import threading
import time
import json
import decimal
import traceback
import sqlalchemy
import logging
import threading
from operator import attrgetter
from datetime import datetime, timedelta
from modules.base.models import AuraDatabaseModel, Schedule, Playlist, PlaylistEntry, PlaylistEntryMetaData
from modules.base.exceptions import NoActiveScheduleException, NoActiveEntryException, LoadSourceException
from modules.base.enum import Channel, ChannelType, TimerType, TransitionType, EntryQueueState, EntryPlayState
from modules.base.utils import SimpleUtil, TerminalColors, EngineUtil
from modules.cli.redis.messenger import RedisMessenger
from modules.scheduling.calendar import AuraCalendarService
from modules.scheduling.fallback_manager import FallbackManager
from modules.base.utils import SimpleUtil, EngineUtil
from modules.base.models import AuraDatabaseModel, Schedule, Playlist
from modules.base.exceptions import NoActiveScheduleException, LoadSourceException
from modules.core.channels import ChannelType, TransitionType, EntryPlayState
from modules.scheduling.types import EntryQueueState
from modules.scheduling.calendar import AuraCalendarService
from modules.scheduling.fallback_manager import FallbackManager
# FIXME this is probably not needed?
......
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-2020 - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
class PlaylistType(Enum):
"""
Types of playlists.
"""
DEFAULT = { "id": 0, "name": "default" } # Default play mode
SHOW = { "id": 1, "name": "show" } # The first played when some default playlist fails
TIMESLOT = { "id": 2, "name": "timeslot" } # The second played when the timeslot fallback fails
STATION = { "id": 3, "name": "station" } # The last played when everything else fails
@property
def id(self):
return self.value["id"]
def __str__(self):
return str(self.value["name"])
# class TimerType(Enum):
# """
# Types of queue timers.
# """
# SWITCH = "switch"
# FADEIN = "fadein"
# FADEOUT = "fadeout"
class EntryQueueState(Enum):
"""
Types of playlist entrie behaviours.
"""
OKAY = "ok"
CUT = "cut"
OUT_OF_SCHEDULE = "oos"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment