Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
Container Registry
Model registry
Operate
Environments
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
AURA
engine
Commits
1ae381d8
Commit
1ae381d8
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refactor(config): helper location, rm settings
parent
78a77bd6
No related branches found
No related tags found
1 merge request
!35
ORM-less scheduling
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/aura_engine/base/config.py
+0
-41
0 additions, 41 deletions
src/aura_engine/base/config.py
src/aura_engine/resources.py
+42
-7
42 additions, 7 deletions
src/aura_engine/resources.py
src/aura_engine/scheduling/utils.py
+2
-1
2 additions, 1 deletion
src/aura_engine/scheduling/utils.py
with
44 additions
and
49 deletions
src/aura_engine/base/config.py
+
0
−
41
View file @
1ae381d8
...
@@ -43,16 +43,6 @@ template = {
...
@@ -43,16 +43,6 @@ template = {
"
level
"
:
confuse
.
OneOf
([
"
debug
"
,
"
info
"
,
"
warning
"
,
"
error
"
,
"
critical
"
]),
"
level
"
:
confuse
.
OneOf
([
"
debug
"
,
"
info
"
,
"
warning
"
,
"
error
"
,
"
critical
"
]),
},
},
"
monitoring
"
:
{
"
monitoring
"
:
{
"
mail
"
:
{
"
host
"
:
str
,
"
port
"
:
int
,
"
user
"
:
str
,
"
pwd
"
:
str
,
"
from
"
:
str
,
"
subject_prefix
"
:
str
,
"
coordinator
"
:
{
"
enabled
"
:
bool
,
"
mail
"
:
str
},
"
admin
"
:
{
"
enabled
"
:
bool
,
"
mail
"
:
str
},
},
"
heartbeat
"
:
{
"
host
"
:
str
,
"
port
"
:
int
,
"
frequency
"
:
int
},
"
heartbeat
"
:
{
"
host
"
:
str
,
"
port
"
:
int
,
"
frequency
"
:
int
},
},
},
"
api
"
:
{
"
api
"
:
{
...
@@ -67,14 +57,6 @@ template = {
...
@@ -67,14 +57,6 @@ template = {
},
},
},
},
"
scheduler
"
:
{
"
scheduler
"
:
{
"
db
"
:
{
"
type
"
:
confuse
.
OneOf
([
"
postgresql
"
,
"
mysql
"
,
"
sqlite
"
]),
"
name
"
:
str
,
"
user
"
:
str
,
"
pwd
"
:
str
,
"
host
"
:
str
,
"
charset
"
:
str
,
},
"
audio
"
:
{
"
audio
"
:
{
"
source_folder
"
:
str
,
"
source_folder
"
:
str
,
"
source_extension
"
:
str
,
"
source_extension
"
:
str
,
...
@@ -178,26 +160,3 @@ class AuraConfig:
...
@@ -178,26 +160,3 @@ class AuraConfig:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
self
.
config
=
self
.
confuse_config
.
get
(
template
)
self
.
config
=
self
.
confuse_config
.
get
(
template
)
def
to_abs_path
(
self
,
path
):
"""
Transform any given (relative) path to an absolute paths.
Starting at the project root.
"""
if
path
.
startswith
(
"
/
"
):
return
path
else
:
return
self
.
confuse_config
[
"
install_dir
"
].
get
()
+
"
/
"
+
path
def
abs_audio_store_path
(
self
):
"""
Return the absolute path to the audio store, based on the `audio_source_folder` setting.
"""
return
self
.
to_abs_path
(
self
.
config
.
scheduler
.
audio
.
source_folder
)
def
abs_playlist_path
(
self
):
"""
Return the absolute path to the playlist folder.
"""
return
self
.
to_abs_path
(
self
.
config
.
scheduler
.
audio
.
playlist_folder
)
This diff is collapsed.
Click to expand it.
src/aura_engine/resources.py
+
42
−
7
View file @
1ae381d8
...
@@ -178,7 +178,7 @@ class ResourceUtil(Enum):
...
@@ -178,7 +178,7 @@ class ResourceUtil(Enum):
return
ResourceClass
.
PLAYLIST
return
ResourceClass
.
PLAYLIST
@staticmethod
@staticmethod
def
generate_m3u_file
(
target_file_path
:
str
,
items
:
[]
,
config
:
AuraConfig
):
def
generate_m3u_file
(
target_file_path
:
str
,
items
:
[]):
"""
"""
Write a M3U file based on the given playlist object.
Write a M3U file based on the given playlist object.
...
@@ -192,7 +192,7 @@ class ResourceUtil(Enum):
...
@@ -192,7 +192,7 @@ class ResourceUtil(Enum):
for
item
in
items
:
for
item
in
items
:
if
ResourceUtil
.
get_content_type
(
item
.
source
)
==
ResourceType
.
FILE
:
if
ResourceUtil
.
get_content_type
(
item
.
source
)
==
ResourceType
.
FILE
:
path
=
ResourceUtil
.
source_to_filepath
(
item
.
source
,
config
)
path
=
ResourceUtil
.
source_to_filepath
(
item
.
source
)
fb
.
append
(
fb
.
append
(
f
"
#EXTINF:
{
item
.
duration
}
,
{
item
.
metadata
.
artist
}
-
{
item
.
metadata
.
title
}
"
f
"
#EXTINF:
{
item
.
duration
}
,
{
item
.
metadata
.
artist
}
-
{
item
.
metadata
.
title
}
"
)
)
...
@@ -202,7 +202,42 @@ class ResourceUtil(Enum):
...
@@ -202,7 +202,42 @@ class ResourceUtil(Enum):
file
.
close
()
file
.
close
()
@staticmethod
@staticmethod
def
source_to_filepath
(
source_uri
:
str
,
config
:
AuraConfig
)
->
str
:
def
to_abs_path
(
path
):
"""
Transform any given (relative) path to an absolute path.
Starting at the project root.
"""
if
path
.
startswith
(
"
/
"
):
return
path
else
:
ac
=
AuraConfig
.
instance
return
ac
.
confuse_config
[
"
install_dir
"
].
get
()
+
"
/
"
+
path
@staticmethod
def
audio_store_path
()
->
str
:
"""
Get audio store location.
Returns:
(str): Absolute path to audio store folder.
"""
ac
=
AuraConfig
.
instance
return
ResourceUtil
.
to_abs_path
(
ac
.
config
.
scheduler
.
audio
.
source_folder
)
@staticmethod
def
playlist_folder_path
()
->
str
:
"""
Get playlist folder location.
Returns:
(str): Return the absolute path to the playlist folder.
"""
ac
=
AuraConfig
.
instance
return
ResourceUtil
.
to_abs_path
(
ac
.
config
.
scheduler
.
audio
.
playlist_folder
)
@staticmethod
def
source_to_filepath
(
source_uri
:
str
)
->
str
:
"""
"""
Create path from URI and extension.
Create path from URI and extension.
...
@@ -214,18 +249,18 @@ class ResourceUtil(Enum):
...
@@ -214,18 +249,18 @@ class ResourceUtil(Enum):
Args:
Args:
source_uri (str): The URI of the file
source_uri (str): The URI of the file
config (AuraConfig): The configuration
Returns:
Returns:
path
(str): Absolute file path
(str): Absolute file path
.
"""
"""
path
=
source_uri
[
7
:]
path
=
source_uri
[
7
:]
if
path
.
startswith
(
"
/
"
):
if
path
.
startswith
(
"
/
"
):
return
path
return
path
else
:
else
:
base_dir
=
config
.
abs_audio_store_path
()
ac
=
AuraConfig
.
instance
extension
=
config
.
get
(
"
audio_source_extension
"
)
base_dir
=
ResourceUtil
.
audio_store_path
()
extension
=
ac
.
config
.
scheduler
.
audio
.
source_extension
return
base_dir
+
"
/
"
+
path
+
extension
return
base_dir
+
"
/
"
+
path
+
extension
@staticmethod
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
src/aura_engine/scheduling/utils.py
+
2
−
1
View file @
1ae381d8
...
@@ -29,6 +29,7 @@ import logging
...
@@ -29,6 +29,7 @@ import logging
import
aura_engine.scheduling
as
scheduling
import
aura_engine.scheduling
as
scheduling
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.base.utils
import
SimpleUtil
as
SU
from
aura_engine.base.utils
import
SimpleUtil
as
SU
from
aura_engine.resources
import
ResourceUtil
from
aura_engine.scheduling.domain
import
Playlist
,
PlaylistItem
,
Timeslot
from
aura_engine.scheduling.domain
import
Playlist
,
PlaylistItem
,
Timeslot
...
@@ -47,7 +48,7 @@ class M3UPlaylistProcessor:
...
@@ -47,7 +48,7 @@ class M3UPlaylistProcessor:
"""
"""
self
.
config
=
AuraConfig
.
instance
self
.
config
=
AuraConfig
.
instance
self
.
logger
=
logging
.
getLogger
(
"
engine
"
)
self
.
logger
=
logging
.
getLogger
(
"
engine
"
)
self
.
playlist_folder
=
self
.
config
.
abs_
playlist_path
()
self
.
playlist_folder
=
ResourceUtil
.
playlist_
folder_
path
()
def
spread
(
self
,
item
:
PlaylistItem
)
->
list
:
def
spread
(
self
,
item
:
PlaylistItem
)
->
list
:
"""
"""
...
...
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