Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Kruse
aura-engine
Commits
955ef8cf
Commit
955ef8cf
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Linting, cleanup and fixes.
parent
8d6f8244
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aura.py
+6
-12
6 additions, 12 deletions
aura.py
modules/communication/redis/adapter.py
+0
-4
0 additions, 4 deletions
modules/communication/redis/adapter.py
modules/scheduling/calendar.py
+29
-22
29 additions, 22 deletions
modules/scheduling/calendar.py
with
35 additions
and
38 deletions
aura.py
+
6
−
12
View file @
955ef8cf
...
@@ -54,8 +54,6 @@ def get_database_uri():
...
@@ -54,8 +54,6 @@ def get_database_uri():
db_pass
=
config
.
get
(
"
db_pass
"
)
db_pass
=
config
.
get
(
"
db_pass
"
)
db_host
=
config
.
get
(
"
db_host
"
)
db_host
=
config
.
get
(
"
db_host
"
)
db_charset
=
config
.
get
(
"
db_charset
"
,
"
utf8
"
)
db_charset
=
config
.
get
(
"
db_charset
"
,
"
utf8
"
)
#### return created database uri ####
return
"
mysql://
"
+
db_user
+
"
:
"
+
db_pass
+
"
@
"
+
db_host
+
"
/
"
+
db_name
+
"
?charset=
"
+
db_charset
return
"
mysql://
"
+
db_user
+
"
:
"
+
db_pass
+
"
@
"
+
db_host
+
"
/
"
+
db_name
+
"
?charset=
"
+
db_charset
...
@@ -82,11 +80,8 @@ class Aura:
...
@@ -82,11 +80,8 @@ class Aura:
# ------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------ #
def
__init__
(
self
):
def
__init__
(
self
):
# set config
self
.
config
=
config
self
.
config
=
config
# init logger
AuraLogger
(
self
.
config
)
AuraLogger
(
self
.
config
)
# use logger
self
.
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
self
.
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
def
startup
(
self
):
def
startup
(
self
):
...
@@ -98,7 +93,6 @@ class Aura:
...
@@ -98,7 +93,6 @@ class Aura:
AuraScheduler
(
self
.
config
)
# handles recreate and exits program
AuraScheduler
(
self
.
config
)
# handles recreate and exits program
# self.controller = AuraController(self.config)
# create scheduler and ls_communicator
# create scheduler and ls_communicator
self
.
liquidsoapcommunicator
=
LiquidSoapCommunicator
(
self
.
config
)
self
.
liquidsoapcommunicator
=
LiquidSoapCommunicator
(
self
.
config
)
self
.
scheduler
=
AuraScheduler
(
self
.
config
)
self
.
scheduler
=
AuraScheduler
(
self
.
config
)
...
@@ -112,21 +106,20 @@ class Aura:
...
@@ -112,21 +106,20 @@ class Aura:
self
.
messenger
.
scheduler
=
self
.
scheduler
self
.
messenger
.
scheduler
=
self
.
scheduler
self
.
messenger
.
liquidsoapcommunicator
=
self
.
liquidsoapcommunicator
self
.
messenger
.
liquidsoapcommunicator
=
self
.
liquidsoapcommunicator
# FIXME Check if it's working / needed.
#self.diskspace_watcher = DiskSpaceWatcher(self.config, self.logger, self.liquidsoapcommunicator)
#self.diskspace_watcher = DiskSpaceWatcher(self.config, self.logger, self.liquidsoapcommunicator)
#self.diskspace_watcher.start()
#self.diskspace_watcher.start()
# and finally wait for redis message
# and finally wait for redis message
/ start listener thread
self
.
join_comm
()
self
.
messenger
.
start
()
# start the web service
# start the web service
self
.
start_web_service
()
self
.
start_web_service
()
def
join_comm
(
self
):
# start listener thread
self
.
messenger
.
start
()
def
start_web_service
(
self
):
def
start_web_service
(
self
):
# FIXME Test current state of Web Services
try
:
try
:
self
.
logger
.
info
(
"
Listening on Port 5000 for API or Webcalls
"
)
self
.
logger
.
info
(
"
Listening on Port 5000 for API or Webcalls
"
)
# Routes(self.scheduler, self.liquidsoapcommunicator, self.messenger, self.config)
# Routes(self.scheduler, self.liquidsoapcommunicator, self.messenger, self.config)
...
@@ -142,6 +135,7 @@ class Aura:
...
@@ -142,6 +135,7 @@ class Aura:
def
main
():
def
main
():
aura
=
Aura
()
aura
=
Aura
()
# FIXME MAKE THE STARTTIME OF A SCHEDULE TO ITS PK
aura
.
logger
.
critical
(
"
MAKE THE STARTTIME OF A SCHEDULE TO ITS PK
"
)
aura
.
logger
.
critical
(
"
MAKE THE STARTTIME OF A SCHEDULE TO ITS PK
"
)
...
@@ -149,7 +143,7 @@ def main():
...
@@ -149,7 +143,7 @@ def main():
if
"
--use-test-data
"
in
sys
.
argv
:
if
"
--use-test-data
"
in
sys
.
argv
:
aura
.
config
.
set
(
"
use_test_data
"
,
True
)
aura
.
config
.
set
(
"
use_test_data
"
,
True
)
if
"
--recreate-database
"
in
sys
.
argv
:
if
"
--recreate-database
"
in
sys
.
argv
:
aura
.
config
.
set
(
"
recreate_db
"
,
True
)
;
aura
.
config
.
set
(
"
recreate_db
"
,
True
)
aura
.
startup
()
aura
.
startup
()
...
...
This diff is collapsed.
Click to expand it.
modules/communication/redis/adapter.py
+
0
−
4
View file @
955ef8cf
...
@@ -223,10 +223,6 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
...
@@ -223,10 +223,6 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
"""
"""
if
self
.
shutdown_event
.
is_set
():
if
self
.
shutdown_event
.
is_set
():
return
return
try
:
del
self
.
auracontroller
except
:
pass
self
.
shutdown_event
.
set
()
self
.
shutdown_event
.
set
()
result
=
'
failed
'
result
=
'
failed
'
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
modules/scheduling/calendar.py
+
29
−
22
View file @
955ef8cf
...
@@ -105,21 +105,23 @@ class AuraCalendarService(threading.Thread):
...
@@ -105,21 +105,23 @@ class AuraCalendarService(threading.Thread):
return
self
.
queue
return
self
.
queue
# ------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------ #
def
get_uri
(
self
):
# FIXME is get_uri() needed?
if
not
self
.
playlistdir
:
return
False
# def get_uri(self):
if
not
self
.
datefrom
:
# if not self.playlistdir:
return
False
# return False
if
not
self
.
__calc_date_to__
():
# if not self.datefrom:
return
# return False
# if not self.__calc_date_to__():
hostname
=
self
.
get
(
"
servername
"
);
# return
port
=
self
.
get
(
"
serviceport
"
);
date_from
=
self
.
datefrom
[
0
:
16
]
+
"
:00
"
;
# hostname = self.get("servername")
date_to
=
self
.
dateto
[
0
:
16
]
+
"
:00
"
;
# port = self.get("serviceport")
uri
=
"
http://
"
+
hostname
+
"
:
"
+
port
+
"
/playlist/
"
+
date_from
+
"
/
"
+
date_to
# date_from = self.datefrom[0:16] + ":00"
# date_to = self.dateto[0:16] + ":00"
return
uri
# uri = "http://" + hostname + ":" + port + "/playlist/" + date_from + "/" + date_to
# return uri
# ------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------ #
def
run
(
self
):
def
run
(
self
):
...
@@ -161,6 +163,7 @@ class AuraCalendarService(threading.Thread):
...
@@ -161,6 +163,7 @@ class AuraCalendarService(threading.Thread):
self
.
queue
.
put
(
ret_schedule
)
self
.
queue
.
put
(
ret_schedule
)
except
Exception
as
e
:
except
Exception
as
e
:
# release the mutex
# release the mutex
self
.
logger
.
warning
(
"
Fetching aborted due to: %s
"
%
str
(
e
))
self
.
queue
.
put
(
"
fetching_aborted
"
+
str
(
e
))
self
.
queue
.
put
(
"
fetching_aborted
"
+
str
(
e
))
# terminate the thread
# terminate the thread
...
@@ -246,7 +249,6 @@ class AuraCalendarService(threading.Thread):
...
@@ -246,7 +249,6 @@ class AuraCalendarService(threading.Thread):
playlistentry_db
.
uri
=
entry
[
"
uri
"
]
playlistentry_db
.
uri
=
entry
[
"
uri
"
]
playlistentry_db
.
filename
=
entry
[
"
filename
"
]
playlistentry_db
.
filename
=
entry
[
"
filename
"
]
playlistentry_db
.
duration
=
entry
[
"
file
"
][
"
duration
"
]
playlistentry_db
.
duration
=
entry
[
"
file
"
][
"
duration
"
]
playlistentry_db
.
store
(
havetoadd
,
True
)
playlistentry_db
.
store
(
havetoadd
,
True
)
self
.
store_playlist_entry_metadata
(
playlistentry_db
,
entry
[
"
file
"
][
"
metadata
"
])
self
.
store_playlist_entry_metadata
(
playlistentry_db
,
entry
[
"
file
"
][
"
metadata
"
])
...
@@ -261,12 +263,16 @@ class AuraCalendarService(threading.Thread):
...
@@ -261,12 +263,16 @@ class AuraCalendarService(threading.Thread):
havetoadd
=
True
havetoadd
=
True
playlistentrymetadata_db
.
artificial_entry_id
=
playlistentry_db
.
artificial_id
playlistentrymetadata_db
.
artificial_entry_id
=
playlistentry_db
.
artificial_id
playlistentrymetadata_db
.
artist
=
metadata
[
"
artist
"
]
if
"
artist
"
not
in
metadata
:
self
.
logger
.
warning
(
"
Artist not found in metadata for track
'
%s
'
. Setting to
'
N/a
'"
%
playlistentry_db
.
filename
)
playlistentrymetadata_db
.
artist
=
"
N/a
"
else
:
playlistentrymetadata_db
.
artist
=
metadata
[
"
artist
"
]
playlistentrymetadata_db
.
title
=
metadata
[
"
title
"
]
playlistentrymetadata_db
.
title
=
metadata
[
"
title
"
]
if
"
album
"
in
metadata
:
if
"
album
"
in
metadata
:
playlistentrymetadata_db
.
album
=
metadata
[
"
album
"
]
playlistentrymetadata_db
.
album
=
metadata
[
"
album
"
]
playlistentrymetadata_db
.
store
(
havetoadd
,
True
)
;
playlistentrymetadata_db
.
store
(
havetoadd
,
True
)
# ------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------ #
def
store_playlist_entry
(
self
,
schedule_db
,
playlist
,
entry
,
lastentry
,
entrynum
,
fallbackplaylist_type
=
0
):
def
store_playlist_entry
(
self
,
schedule_db
,
playlist
,
entry
,
lastentry
,
entrynum
,
fallbackplaylist_type
=
0
):
...
@@ -275,7 +281,8 @@ class AuraCalendarService(threading.Thread):
...
@@ -275,7 +281,8 @@ class AuraCalendarService(threading.Thread):
if
not
schedule_entry_db
:
if
not
schedule_entry_db
:
self
.
logger
.
debug
(
"
no scheduleentry with id
"
+
str
(
playlist
[
"
id
"
])
+
"
and pos
"
+
str
(
entrynum
)
+
"
in database => creating a new one
"
)
self
.
logger
.
debug
(
"
no scheduleentry with id
"
+
str
(
playlist
[
"
id
"
])
+
"
and pos
"
+
str
(
entrynum
)
+
"
in database => creating a new one
"
)
schedule_entry_db
=
ScheduleEntry
()
# FIXME Needed? No active class declaration
#schedule_entry_db = ScheduleEntry()
havetoadd
=
True
havetoadd
=
True
...
@@ -325,9 +332,9 @@ class AuraCalendarService(threading.Thread):
...
@@ -325,9 +332,9 @@ class AuraCalendarService(threading.Thread):
@rtype: int
@rtype: int
@return: Zeit in Sekunden
@return: Zeit in Sekunden
"""
"""
sec1
=
int
(
datetime
.
strptime
(
start
[
0
:
16
].
replace
(
"
"
,
"
T
"
),
"
%Y-%m-%dT%H:%M
"
).
strftime
(
"
%s
"
))
;
sec1
=
int
(
datetime
.
strptime
(
start
[
0
:
16
].
replace
(
"
"
,
"
T
"
),
"
%Y-%m-%dT%H:%M
"
).
strftime
(
"
%s
"
))
sec2
=
int
(
datetime
.
strptime
(
end
[
0
:
16
].
replace
(
"
"
,
"
T
"
),
"
%Y-%m-%dT%H:%M
"
).
strftime
(
"
%s
"
))
;
sec2
=
int
(
datetime
.
strptime
(
end
[
0
:
16
].
replace
(
"
"
,
"
T
"
),
"
%Y-%m-%dT%H:%M
"
).
strftime
(
"
%s
"
))
return
(
sec2
-
sec1
)
;
return
(
sec2
-
sec1
)
# ------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------ #
def
get_length
(
self
,
entry
):
def
get_length
(
self
,
entry
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment