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
401392ed
Commit
401392ed
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Removed dysfunctional web part.
parent
ae4f1a25
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aura.py
+28
-71
28 additions, 71 deletions
aura.py
with
28 additions
and
71 deletions
aura.py
+
28
−
71
View file @
401392ed
#!/usr/bin/python3.7
#
# engine
#
# Playout Daemon for autoradio project
#
#
# Copyright (C) 2017-2018 Gottfried Gaisbauer <gottfried.gaisbauer@servus.at>
#
# This file is part of engine.
#
# engine is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# engine 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with engine. If not, see <http://www.gnu.org/licenses/>.
# Aura Engine
#
# Copyright (C) 2017-2020
# David Trattnig <david.trattnig@subsquare.at>
# Gottfried Gaisbauer <gottfried.gaisbauer@servus.at>
# 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/>.
import
os
import
sys
...
...
@@ -32,44 +29,22 @@ import unittest
from
pathlib
import
Path
from
flask
import
request
,
render_template
,
Flask
,
Response
from
flask_sqlalchemy
import
SQLAlchemy
from
sqlalchemy.ext.declarative
import
declarative_base
#from modules.web.routes import Routes
from
modules.monitoring.diskspace_watcher
import
DiskSpaceWatcher
from
libraries.base.logger
import
AuraLogger
from
libraries.base.config
import
AuraConfig
# def get_config_file():
# if len(sys.argv) >= 3 and "--config-file" in sys.argv:
# idx = sys.argv.index("--config-file")
# return sys.argv[idx + 1]
def
get_database_uri
():
db_name
=
config
.
get
(
"
db_name
"
)
db_user
=
config
.
get
(
"
db_user
"
)
db_pass
=
config
.
get
(
"
db_pass
"
)
db_host
=
config
.
get
(
"
db_host
"
)
db_charset
=
config
.
get
(
"
db_charset
"
,
"
utf8
"
)
return
"
mysql://
"
+
db_user
+
"
:
"
+
db_pass
+
"
@
"
+
db_host
+
"
/
"
+
db_name
+
"
?charset=
"
+
db_charset
# from modules.monitoring.diskspace_watcher import DiskSpaceWatcher
def
configure_flask
():
app
.
config
[
"
SQLALCHEMY_DATABASE_URI
"
]
=
get_database_uri
()
app
.
config
[
"
SQLALCHEMY_DATABASE_URI
"
]
=
config
.
get_database_uri
()
app
.
config
[
'
BABEL_DEFAULT_LOCALE
'
]
=
'
de
'
app
.
config
[
'
SQLALCHEMY_TRACK_MODIFICATIONS
'
]
=
False
config
=
AuraConfig
()
app
=
Flask
(
__name__
,
template_folder
=
config
.
get
(
"
install_dir
"
)
+
"
/modules/web/templates
"
)
app
=
Flask
(
__name__
)
configure_flask
()
DB
=
SQLAlchemy
(
app
)
Base
=
declarative_base
()
class
Aura
:
logger
=
None
config
=
None
...
...
@@ -89,44 +64,30 @@ class Aura:
from
modules.communication.liquidsoap.communicator
import
LiquidSoapCommunicator
from
modules.communication.redis.adapter
import
ServerRedisAdapter
# Check if the database has to be re-created
if
self
.
config
.
get
(
"
recreate_db
"
)
is
not
None
:
AuraScheduler
(
self
.
config
)
# handles recreate and exits program
AuraScheduler
(
self
.
config
)
# create scheduler and ls_communicator
# Create scheduler and Liquidsoap communicator
self
.
liquidsoapcommunicator
=
LiquidSoapCommunicator
(
self
.
config
)
self
.
scheduler
=
AuraScheduler
(
self
.
config
)
#
g
ive both a reference of each other
#
G
ive both a reference of each other
self
.
liquidsoapcommunicator
.
scheduler
=
self
.
scheduler
self
.
scheduler
.
liquidsoapcommunicator
=
self
.
liquidsoapcommunicator
#
c
reate the
r
edis adapter
#
C
reate the
R
edis adapter
self
.
messenger
=
ServerRedisAdapter
(
self
.
config
)
self
.
messenger
.
scheduler
=
self
.
scheduler
self
.
messenger
.
liquidsoapcommunicator
=
self
.
liquidsoapcommunicator
#
FIXME
Check if it's working / needed.
#
TODO
Check if it's working / needed.
#self.diskspace_watcher = DiskSpaceWatcher(self.config, self.logger, self.liquidsoapcommunicator)
#self.diskspace_watcher.start()
#
a
nd finally wait for redis message / start listener thread
#
A
nd finally wait for redis message / start listener thread
self
.
messenger
.
start
()
# start the web service
self
.
start_web_service
()
def
start_web_service
(
self
):
# FIXME Test current state of Web Services
try
:
self
.
logger
.
info
(
"
Listening on Port 5000 for API or Webcalls
"
)
# Routes(self.scheduler, self.liquidsoapcommunicator, self.messenger, self.config)
except
OSError
as
e
:
self
.
messenger
.
halt
()
self
.
logger
.
critical
(
"
AuraEngine already running? Exception:
"
+
e
.
strerror
+
"
. Exiting...
"
)
os
.
_exit
(
0
)
# # ## ## ## ## ## # #
...
...
@@ -135,10 +96,6 @@ class Aura:
def
main
():
aura
=
Aura
()
# FIXME MAKE THE STARTTIME OF A SCHEDULE TO ITS PK
aura
.
logger
.
critical
(
"
MAKE THE STARTTIME OF A SCHEDULE TO ITS PK
"
)
if
len
(
sys
.
argv
)
>=
2
:
if
"
--use-test-data
"
in
sys
.
argv
:
aura
.
config
.
set
(
"
use_test_data
"
,
True
)
...
...
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