Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine-api
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-api
Commits
5c642669
Commit
5c642669
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Wiring service via app context.
parent
16157ce8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app.py
+4
-3
4 additions, 3 deletions
src/app.py
src/rest/controllers/internal_controller.py
+8
-0
8 additions, 0 deletions
src/rest/controllers/internal_controller.py
src/rest/controllers/public_controller.py
+4
-2
4 additions, 2 deletions
src/rest/controllers/public_controller.py
with
16 additions
and
5 deletions
src/app.py
+
4
−
3
View file @
5c642669
...
@@ -49,8 +49,8 @@ def build_app(app):
...
@@ -49,8 +49,8 @@ def build_app(app):
ma
.
init_app
(
app
)
ma
.
init_app
(
app
)
return
app
return
app
api
=
connexion
.
App
(
__name__
,
specification_dir
=
'
rest/swagger
'
)
api
=
connexion
.
App
(
__name__
,
specification_dir
=
'
rest/swagger
'
,
arguments
=
{
'
title
'
:
'
AURA Engine API
'
}
)
api
.
add_api
(
'
swagger.yaml
'
,
arguments
=
{
'
title
'
:
'
AURA Engine API
'
},
pythonic_params
=
True
)
api
.
add_api
(
'
swagger.yaml
'
,
pythonic_params
=
True
)
app
=
build_app
(
api
.
app
)
app
=
build_app
(
api
.
app
)
...
@@ -68,7 +68,8 @@ with app.app_context():
...
@@ -68,7 +68,8 @@ with app.app_context():
"""
"""
db
.
create_all
()
db
.
create_all
()
service
=
ApiService
(
config
,
logger
)
service
=
ApiService
(
config
,
logger
)
logger
.
info
(
"
API server initialized.
"
)
app
.
config
[
'
SERVICE
'
]
=
service
logger
.
info
(
"
Engine API server initialized.
"
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
src/rest/controllers/internal_controller.py
+
8
−
0
View file @
5c642669
...
@@ -7,6 +7,8 @@ from src.rest.models.play_log_entry import PlayLogEntry # noqa: E501
...
@@ -7,6 +7,8 @@ from src.rest.models.play_log_entry import PlayLogEntry # noqa: E501
from
src.rest.models.status_entry
import
StatusEntry
# noqa: E501
from
src.rest.models.status_entry
import
StatusEntry
# noqa: E501
from
src.rest
import
util
from
src.rest
import
util
from
flask
import
current_app
def
activate_engine
(
engine_number
):
# noqa: E501
def
activate_engine
(
engine_number
):
# noqa: E501
"""
Set active engine
"""
Set active engine
...
@@ -18,6 +20,7 @@ def activate_engine(engine_number): # noqa: E501
...
@@ -18,6 +20,7 @@ def activate_engine(engine_number): # noqa: E501
:rtype: None
:rtype: None
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
...
@@ -29,6 +32,7 @@ def clock_info(): # noqa: E501
...
@@ -29,6 +32,7 @@ def clock_info(): # noqa: E501
:rtype: ClockInfo
:rtype: ClockInfo
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
...
@@ -40,6 +44,7 @@ def get_active_engine(): # noqa: E501
...
@@ -40,6 +44,7 @@ def get_active_engine(): # noqa: E501
:rtype: StatusEntry
:rtype: StatusEntry
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
...
@@ -53,6 +58,7 @@ def get_engine_health(engine_number): # noqa: E501
...
@@ -53,6 +58,7 @@ def get_engine_health(engine_number): # noqa: E501
:rtype: HealthInfo
:rtype: HealthInfo
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
...
@@ -66,6 +72,7 @@ def get_report(year_month): # noqa: E501
...
@@ -66,6 +72,7 @@ def get_report(year_month): # noqa: E501
:rtype: List[PlayLogEntry]
:rtype: List[PlayLogEntry]
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
...
@@ -79,4 +86,5 @@ def log_engine_health(engine_number): # noqa: E501
...
@@ -79,4 +86,5 @@ def log_engine_health(engine_number): # noqa: E501
:rtype: None
:rtype: None
"""
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
return
'
do some magic!
'
This diff is collapsed.
Click to expand it.
src/rest/controllers/public_controller.py
+
4
−
2
View file @
5c642669
...
@@ -6,6 +6,8 @@ import six
...
@@ -6,6 +6,8 @@ import six
from
src.rest.models.play_log_entry
import
PlayLogEntry
# noqa: E501
from
src.rest.models.play_log_entry
import
PlayLogEntry
# noqa: E501
from
src.rest
import
util
from
src.rest
import
util
from
flask
import
current_app
def
current_track
():
# noqa: E501
def
current_track
():
# noqa: E501
"""
Get current track
"""
Get current track
...
@@ -15,7 +17,7 @@ def current_track(): # noqa: E501
...
@@ -15,7 +17,7 @@ def current_track(): # noqa: E501
:rtype: PlayLogEntry
:rtype: PlayLogEntry
"""
"""
from
src.app
import
service
service
=
current_app
.
config
[
'
SERVICE
'
]
return
service
.
current_track
()
return
service
.
current_track
()
...
@@ -31,5 +33,5 @@ def list_tracks(offset=None, limit=None): # noqa: E501
...
@@ -31,5 +33,5 @@ def list_tracks(offset=None, limit=None): # noqa: E501
:rtype: List[PlayLogEntry]
:rtype: List[PlayLogEntry]
"""
"""
from
src.app
import
service
service
=
current_app
.
config
[
'
SERVICE
'
]
return
service
.
list_tracks
(
offset
,
limit
)
return
service
.
list_tracks
(
offset
,
limit
)
\ No newline at end of file
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