Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
f6f0af4e
Commit
f6f0af4e
authored
Jun 28, 2020
by
David Trattnig
Browse files
Linting and grouping.
parent
8f0891f0
Changes
17
Hide whitespace changes
Inline
Side-by-side
engine-api.py
View file @
f6f0af4e
...
...
@@ -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
...
...
engine-core.py
View file @
f6f0af4e
...
...
@@ -181,7 +181,7 @@ class AuraEngine:
if
__name__
==
"__main__"
:
engine
=
AuraEngine
()
lqs_
start
up
=
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_
start
up
=
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_
start
up
)
engine
.
startup
(
start
_lqs
)
modules/base/mail.py
View file @
f6f0af4e
...
...
@@ -26,7 +26,7 @@ class MailingException(Exception):
"""
Thrown when some mail cannot be sent.
"""
pass
...
...
modules/base/models.py
View file @
f6f0af4e
...
...
@@ -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
()
...
...
modules/base/utils.py
View file @
f6f0af4e
...
...
@@ -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
...
...
modules/cli/padavan.py
View file @
f6f0af4e
...
...
@@ -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
...
...
modules/cli/redis/adapter.py
View file @
f6f0af4e
...
...
@@ -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
...
...
modules/cli/redis/channels.py
0 → 100644
View file @
f6f0af4e
#
# 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"
modules/cli/redis/messenger.py
View file @
f6f0af4e
...
...
@@ -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
"""
...
...
modules/
base/enum
.py
→
modules/
core/channels
.py
View file @
f6f0af4e
...
...
@@ -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
modules/core/engine.py
View file @
f6f0af4e
...
...
@@ -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
():
...
...
modules/core/events.py
View file @
f6f0af4e
...
...
@@ -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
)
...
...
modules/core/liquidsoap/playerclient.py
View file @
f6f0af4e
...
...
@@ -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)
# ------------------------------------------------------------------------------------------ #
...
...
modules/scheduling/calendar.py
View file @
f6f0af4e
...
...
@@ -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
...
...
modules/scheduling/fallback_manager.py
View file @
f6f0af4e
...
...
@@ -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
:
...
...
modules/scheduling/scheduler.py
View file @
f6f0af4e
...
...
@@ -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?
...
...
modules/scheduling/types.py
0 → 100644
View file @
f6f0af4e
#
# 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"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment