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
a79e03fd
Commit
a79e03fd
authored
May 24, 2018
by
Gottfried Gaisbauer
Browse files
solved startup issues (aura.py has to run before lqs, but does not complain if lqs is not running)
parent
8781f775
Changes
10
Hide whitespace changes
Inline
Side-by-side
configuration/engine.ini
View file @
a79e03fd
...
...
@@ -76,11 +76,14 @@ soundsystem="jack"
# - pulseaudio with ONE input and ONE output (should work with multiple ins/outs)
# - jack with multiple inputs and outputs
#
# boundaries:
# - if you use jack, you have to kill liquidsoap. somehow liquidsoap cannot disconnect from jackd when shutting down
#
# with alsa you have to write the devicenames like hw:0
# with pulse and jack => an non empty value means it is used
# devices with empty string are ignored and not used
input_device_0
=
"
y
"
input_device_1
=
"
y
"
input_device_0
=
""
input_device_1
=
""
input_device_2
=
""
input_device_3
=
""
input_device_4
=
""
...
...
guru.py
View file @
a79e03fd
...
...
@@ -72,7 +72,7 @@ class Guru(AuraConfig):
print
(
"...result: "
)
if
p
.
stringreply
!=
""
:
print
(
p
.
stringreply
)
#
print(p.stringreply)
if
p
.
stringreply
[
len
(
p
.
stringreply
)
-
1
]
==
"
\n
"
:
print
(
p
.
stringreply
[
0
:
len
(
p
.
stringreply
)
-
1
])
else
:
...
...
modules/cli_tool/padavan.py
View file @
a79e03fd
...
...
@@ -305,10 +305,21 @@ class Padavan:
if
next_file
==
""
:
next_file
=
"/var/audio/blank.flac"
# if type == "timeslot":
# next_file = ""
# elif type == "show":
# next_file = ""
# else:
# next_file = "/var/audio/fallback/music.flac"
if
type
==
"timeslot"
:
next_file
=
""
if
type
==
"show"
:
next_file
=
""
#print("stringreply: "+next_file)
self
.
stringreply
=
next_file
self
.
send_redis
(
"aura"
,
"set_next_file "
+
type
)
#
self.send_redis("aura", "set_next_file " + type)
# ------------------------------------------------------------------------------------------ #
def
set_next_file
(
self
,
type
,
file
):
...
...
modules/communication/liquidsoap/client.py
View file @
a79e03fd
...
...
@@ -218,7 +218,7 @@ class LiquidSoapClient:
return
self
.
message
else
:
msg
=
"LiquidsoapClient not connected to LiquidSoap Server"
self
.
logger
.
debug
(
msg
)
self
.
logger
.
error
(
msg
)
raise
LQConnectionError
(
msg
)
# ------------------------------------------------------------------------------------------ #
...
...
modules/communication/liquidsoap/communicator.py
View file @
a79e03fd
...
...
@@ -42,15 +42,15 @@ from libraries.exceptions.exception_logger import ExceptionLogger
"""
class
LiquidSoapCommunicator
(
ExceptionLogger
):
client
=
None
lqcr
=
None
client
=
None
logger
=
None
transaction
=
0
channels
=
None
scheduler
=
None
error_data
=
None
auramailer
=
None
aborttransaction
=
False
is_liquidsoap_running
=
False
connection_attempts
=
0
# ------------------------------------------------------------------------------------------ #
...
...
@@ -71,6 +71,20 @@ class LiquidSoapCommunicator(ExceptionLogger):
self
.
auramailer
=
AuraMailer
(
self
.
config
)
self
.
is_liquidsoap_up_and_running
()
# ------------------------------------------------------------------------------------------ #
def
is_liquidsoap_up_and_running
(
self
):
try
:
self
.
uptime
()
self
.
is_liquidsoap_running
=
True
except
LQConnectionError
as
e
:
self
.
logger
.
info
(
"Liquidsoap is not running so far"
)
self
.
is_liquidsoap_running
=
False
except
Exception
as
e
:
self
.
logger
.
error
(
"Cannot check if Liquidsoap is running. Reason: "
+
str
(
e
))
self
.
is_liquidsoap_running
=
False
# ------------------------------------------------------------------------------------------ #
def
set_volume
(
self
,
mixernumber
,
volume
):
return
self
.
__send_lqc_command__
(
self
.
client
,
"mixer"
,
"volume"
,
mixernumber
,
volume
)
...
...
@@ -164,6 +178,14 @@ class LiquidSoapCommunicator(ExceptionLogger):
# ------------------------------------------------------------------------------------------ #
def
recorder_start
(
self
,
num
=-
1
):
if
not
self
.
is_liquidsoap_running
:
if
num
==-
1
:
msg
=
"Want to start recorder, but LiquidSoap is not running"
else
:
msg
=
"Want to start recorder "
+
str
(
num
)
+
", but LiquidSoap is not running"
self
.
logger
.
warning
(
msg
)
return
False
self
.
enable_transaction
()
if
num
==
-
1
:
...
...
@@ -175,6 +197,10 @@ class LiquidSoapCommunicator(ExceptionLogger):
# ------------------------------------------------------------------------------------------ #
def
recorder_start_all
(
self
):
if
not
self
.
is_liquidsoap_running
:
self
.
logger
.
warning
(
"Want to start all recorder, but LiquidSoap is not running"
)
return
False
self
.
enable_transaction
()
for
i
in
range
(
5
):
self
.
recorder_start_one
(
i
)
...
...
@@ -182,6 +208,8 @@ class LiquidSoapCommunicator(ExceptionLogger):
# ------------------------------------------------------------------------------------------ #
def
recorder_start_one
(
self
,
num
):
if
not
self
.
is_liquidsoap_running
:
return
False
if
self
.
config
.
get
(
"rec_"
+
str
(
num
))
==
"y"
:
returnvalue
=
self
.
__send_lqc_command__
(
self
.
client
,
"recorder"
,
str
(
num
),
"status"
)
...
...
@@ -376,7 +404,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
"""
get version
"""
data
=
self
.
__send_lqc_command__
(
self
.
client
,
"version"
)
data
=
self
.
__send_lqc_command__
(
self
.
client
,
"version"
,
""
)
self
.
logger
.
debug
(
"Got Liquidsoap's version"
)
return
data
...
...
@@ -385,8 +413,8 @@ class LiquidSoapCommunicator(ExceptionLogger):
"""
get uptime
"""
data
=
self
.
__send_lqc_command__
(
self
.
client
,
"uptime"
)
self
.
logger
.
debug
(
"Got Liquidsoap's
help
"
)
data
=
self
.
__send_lqc_command__
(
self
.
client
,
"uptime"
,
""
)
self
.
logger
.
debug
(
"Got Liquidsoap's
uptime
"
)
return
data
# ------------------------------------------------------------------------------------------ #
...
...
@@ -408,7 +436,10 @@ class LiquidSoapCommunicator(ExceptionLogger):
if
namespace
==
"recorder"
:
self
.
logger
.
info
(
"LiquidSoapCommunicator is calling "
+
str
(
namespace
)
+
"_"
+
str
(
command
)
+
"."
+
str
(
args
))
else
:
self
.
logger
.
info
(
"LiquidSoapCommunicator is calling "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
))
if
command
==
""
:
self
.
logger
.
info
(
"LiquidSoapCommunicator is calling "
+
str
(
namespace
)
+
str
(
args
))
else
:
self
.
logger
.
info
(
"LiquidSoapCommunicator is calling "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
))
# call wanted function ...
func
=
getattr
(
lqs_instance
,
namespace
)
...
...
@@ -422,7 +453,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
return
result
except
LQConnectionError
as
e
:
self
.
logger
.
info
(
"Connection Error when sending "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
))
self
.
logger
.
error
(
"Connection Error when sending "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
))
if
self
.
try_to_reconnect
():
time
.
sleep
(
0.2
)
self
.
connection_attempts
+=
1
...
...
@@ -437,7 +468,12 @@ class LiquidSoapCommunicator(ExceptionLogger):
# return the val
return
retval
else
:
self
.
logger
.
info
(
"Rethrowing Exception while trying to send "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
))
if
command
==
""
:
msg
=
"Rethrowing Exception while trying to send "
+
str
(
namespace
)
+
str
(
args
)
else
:
msg
=
"Rethrowing Exception while trying to send "
+
str
(
namespace
)
+
"."
+
str
(
command
)
+
str
(
args
)
self
.
logger
.
info
(
msg
)
self
.
disable_transaction
(
socket
=
self
.
client
,
force
=
True
)
raise
e
else
:
...
...
modules/communication/liquidsoap/initthread.py
View file @
a79e03fd
...
...
@@ -51,53 +51,64 @@ class LiquidSoapInitThread(threading.Thread):
# enable lqs transaction
self
.
liquidsoapcommunicator
.
enable_transaction
()
# reset channels and reload them
channels
=
self
.
liquidsoapcommunicator
.
reload_channels
()
# for all available channels
for
c
in
channels
:
# set volume to zero
self
.
liquidsoapcommunicator
.
channel_volume
(
c
,
"0"
)
# and activate this channel
self
.
liquidsoapcommunicator
.
channel_activate
(
c
,
True
)
# setting init params like a blank file..
self
.
liquidsoapcommunicator
.
playlist_push
(
self
.
liquidsoapcommunicator
.
config
.
get
(
"install_dir"
)
+
"/configuration/blank.flac"
)
# .. or the radio fro stream (it is overwritten as soon as one http overtake is planned)
self
.
liquidsoapcommunicator
.
set_http_url
(
"http://stream.fro.at/fro-128.ogg"
)
# wait another second. lqs really starts slow..
# wait another second. lqs really starts slow.. be prepared you liquidsoap you!
time
.
sleep
(
1
)
# set active
if
self
.
active_entry
is
not
None
:
self
.
logger
.
info
(
"LiquidSoapInitThread sets activechannel: "
+
str
(
self
.
active_entry
))
# set some parameters
self
.
set_start_parameters
()
channel
=
self
.
active_entry
.
type
# set active
self
.
set_active_show
()
# have to seek?
if
channel
==
ScheduleEntryType
.
FILESYSTEM
:
# calc how many seconds were missed
now_unix
=
time
.
mktime
(
datetime
.
datetime
.
now
().
timetuple
())
seconds_to_seek
=
now_unix
-
self
.
active_entry
.
entry_start_unix
# disable lqs transaction again
self
.
liquidsoapcommunicator
.
disable_transaction
()
# and seek these seconds forward
self
.
liquidsoapcommunicator
.
playlist_seek
(
seconds_to_seek
)
# the rest of the system now can use liquidsoap connection
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
=
True
except
Exception
as
e
:
self
.
logger
.
critical
(
"Liquidsoap connection ERROR! Restart LQ Server! Reason: "
+
str
(
e
))
# finally make something hearable :-)
if
channel
!=
""
and
channel
is
not
None
:
# activate http stream if needed
self
.
liquidsoapcommunicator
.
http_start_stop
(
channel
==
ScheduleEntryType
.
STREAM
)
# finally set the volume up
self
.
liquidsoapcommunicator
.
channel_volume
(
channel
.
value
,
self
.
active_entry
.
volume
)
else
:
self
.
logger
.
error
(
"Channel is NULL or empty! Cannot set "
)
def
set_active_show
(
self
):
if
self
.
active_entry
is
not
None
:
self
.
logger
.
info
(
"LiquidSoapInitThread sets activechannel: "
+
str
(
self
.
active_entry
))
else
:
self
.
logger
.
warning
(
"No active entry in the scheduler! Is a programme loaded?"
)
channel
=
self
.
active_entry
.
type
self
.
liquidsoapcommunicator
.
disable_transaction
()
except
Exception
as
e
:
self
.
logger
.
critical
(
"Liquidsoap connection ERROR! Restart LQ Server! Reason: "
+
str
(
e
))
# have to seek?
if
channel
==
ScheduleEntryType
.
FILESYSTEM
:
# calc how many seconds were missed
now_unix
=
time
.
mktime
(
datetime
.
datetime
.
now
().
timetuple
())
seconds_to_seek
=
now_unix
-
self
.
active_entry
.
entry_start_unix
# and seek these seconds forward
if
seconds_to_seek
>
0
:
self
.
liquidsoapcommunicator
.
playlist_seek
(
seconds_to_seek
)
# finally make something hearable :-)
if
channel
!=
""
and
channel
is
not
None
:
# activate http stream if needed
self
.
liquidsoapcommunicator
.
http_start_stop
(
channel
==
ScheduleEntryType
.
STREAM
)
# finally set the volume up
self
.
liquidsoapcommunicator
.
channel_volume
(
channel
.
value
,
self
.
active_entry
.
volume
)
else
:
self
.
logger
.
error
(
"Channel is NULL or empty! Cannot set "
)
else
:
self
.
logger
.
warning
(
"No active entry in the scheduler! Is a programme loaded?"
)
def
set_start_parameters
(
self
):
# reset channels and reload them
channels
=
self
.
liquidsoapcommunicator
.
reload_channels
()
# for all available channels
for
c
in
channels
:
# set volume to zero
self
.
liquidsoapcommunicator
.
channel_volume
(
c
,
"0"
)
# and activate this channel
self
.
liquidsoapcommunicator
.
channel_activate
(
c
,
True
)
# setting init params like a blank file..
install_dir
=
self
.
liquidsoapcommunicator
.
config
.
get
(
"install_dir"
)
self
.
liquidsoapcommunicator
.
playlist_push
(
install_dir
+
"/configuration/blank.flac"
)
# .. or the radio fro stream (it is overwritten as soon as one http overtake is planned)
self
.
liquidsoapcommunicator
.
set_http_url
(
"http://stream.fro.at/fro-128.ogg"
)
modules/communication/liquidsoap/playerclient.py
View file @
a79e03fd
...
...
@@ -74,6 +74,10 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
return
"LiquidSoapPlayerClient does not understand fs."
+
command
+
str
(
args
)
# ------------------------------------------------------------------------------------------ #
def
uptime
(
self
,
command
=
""
):
# no command will come
return
self
.
command
(
"uptime"
,
""
)
# ------------------------------------------------------------------------------------------ #
def
auraengine
(
self
,
command
,
*
args
):
if
command
==
"state"
:
...
...
modules/communication/redis/messenger.py
View file @
a79e03fd
...
...
@@ -289,7 +289,7 @@ class RedisMessenger():
# ------------------------------------------------------------------------------------------ #
def
get_next_file_for
(
self
,
playlisttype
):
next
=
self
.
rstore
.
db
.
get
(
'next_'
+
playlisttype
+
'
_
file'
)
next
=
self
.
rstore
.
db
.
get
(
'next_'
+
playlisttype
+
'file'
)
if
next
is
None
:
next
=
b
""
...
...
modules/monitoring/diskspace_watcher.py
View file @
a79e03fd
...
...
@@ -62,16 +62,17 @@ class DiskSpaceWatcher(threading.Thread):
seconds_to_wait
=
600
while
not
self
.
exit_event
.
is_set
():
try
:
# calc next time
next_time
=
datetime
.
datetime
.
now
()
+
datetime
.
timedelta
(
seconds
=
seconds_to_wait
)
# write to logger
self
.
logger
.
info
(
"Diskspace watcher every "
+
str
(
seconds_to_wait
)
+
"s started. Going to start next time "
+
str
(
next_time
))
# check disk space
self
.
check_disk_space
()
# write to logger
self
.
logger
.
info
(
"Diskspace checked! Going to start next time "
+
str
(
next_time
))
# and wait
self
.
exit_event
.
wait
(
seconds_to_wait
)
except
BrokenPipeError
as
e
:
...
...
@@ -112,11 +113,17 @@ class DiskSpaceWatcher(threading.Thread):
try
:
self
.
check_disk_space_of_folder
(
folder
)
# ensure recorder is running
self
.
liquidsoapcommunicator
.
recorder_start
(
num
)
if
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
:
self
.
liquidsoapcommunicator
.
recorder_start
(
num
)
else
:
self
.
logger
.
warning
(
"Cannot enable recorder. Liquidsoap is not running!"
)
except
DiskSpaceException
as
e
:
self
.
logger
.
critical
(
str
(
e
))
# stop recorder when diskspace is critical
self
.
liquidsoapcommunicator
.
recorder_stop
(
num
)
if
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
:
self
.
liquidsoapcommunicator
.
recorder_stop
(
num
)
else
:
self
.
logger
.
warning
(
"Cannot stop recorder. Liquidsoap is not running!"
)
# ------------------------------------------------------------------------------------------ #
def
check_logging_disk_space
(
self
):
...
...
@@ -153,7 +160,10 @@ class DiskSpaceWatcher(threading.Thread):
subj
=
"Diskspace warning"
msg
=
"Free space in "
+
folder
+
" under "
+
warning_value_raw
+
". "
+
str
(
usage
(
total
,
used
,
free
))
self
.
send_mail
(
subj
,
msg
)
self
.
liquidsoapcommunicator
.
recorder_start
()
if
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
:
self
.
liquidsoapcommunicator
.
recorder_start
()
else
:
self
.
logger
.
warning
(
"Cannot enable recorder. Liquidsoap is not running!"
)
self
.
sent_a_mail
=
True
elif
free
<
critical_value
:
...
...
modules/scheduling/scheduler.py
View file @
a79e03fd
...
...
@@ -102,9 +102,6 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
self
.
redismessenger
.
set_channel
(
'scheduler'
)
self
.
redismessenger
.
set_section
(
'execjob'
)
# load schedulerconfig...
self
.
schedulerconfig
=
self
.
config
.
get
(
"scheduler_config_file"
)
# load error messages
error_file
=
self
.
config
.
get
(
"install_dir"
)
+
"/errormessages/scheduler_error.js"
f
=
open
(
error_file
)
...
...
@@ -114,7 +111,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
# init database ?
self
.
init_database
()
self
.
redismessenger
.
send
(
'Scheduler started'
,
'0000'
,
'success'
,
'initApp'
,
None
,
'appinternal'
)
#
self.redismessenger.send('Scheduler started', '0000', 'success', 'initApp', None, 'appinternal')
# create exit event
self
.
exit_event
=
threading
.
Event
()
...
...
@@ -201,7 +198,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
# when do we have to start?
diff
=
entry
.
entry_start_unix
-
now_unix
diff
=
diff
/
1000
# testing purpose
diff
=
diff
/
1000
00
# testing purpose
# create the activation threads and run them after <diff> seconds
if
entry
.
source
.
startswith
(
"linein"
):
...
...
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