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
3755eda0
Commit
3755eda0
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Get Engine Status via API.
parent
036652af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
engine-api.py
+12
-9
12 additions, 9 deletions
engine-api.py
modules/communication/redis/adapter.py
+4
-1
4 additions, 1 deletion
modules/communication/redis/adapter.py
with
16 additions
and
10 deletions
engine-api.py
+
12
−
9
View file @
3755eda0
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
import
logging
import
logging
import
os
,
os
.
path
import
os
,
os
.
path
import
subprocess
import
json
from
datetime
import
datetime
,
date
,
timedelta
from
datetime
import
datetime
,
date
,
timedelta
...
@@ -109,6 +111,7 @@ class EngineApi:
...
@@ -109,6 +111,7 @@ class EngineApi:
spec
.
components
.
schema
(
"
Report
"
,
schema
=
ReportSchema
)
spec
.
components
.
schema
(
"
Report
"
,
schema
=
ReportSchema
)
spec
.
components
.
schema
(
"
Schedule
"
,
schema
=
ScheduleSchema
)
spec
.
components
.
schema
(
"
Schedule
"
,
schema
=
ScheduleSchema
)
spec
.
components
.
schema
(
"
Clock
"
,
schema
=
ClockDataSchema
)
spec
.
components
.
schema
(
"
Clock
"
,
schema
=
ClockDataSchema
)
spec
.
components
.
schema
(
"
Status
"
,
schema
=
StatusSchema
)
# TODO Generates HTML for specification
# TODO Generates HTML for specification
#self.logger.info(spec.to_yaml())
#self.logger.info(spec.to_yaml())
...
@@ -129,7 +132,7 @@ class EngineApi:
...
@@ -129,7 +132,7 @@ class EngineApi:
self
.
api
.
add_resource
(
ReportResource
,
config
.
api_prefix
+
"
/report/<string:year_month>
"
)
self
.
api
.
add_resource
(
ReportResource
,
config
.
api_prefix
+
"
/report/<string:year_month>
"
)
self
.
api
.
add_resource
(
UpcomingSchedulesResource
,
config
.
api_prefix
+
"
/schedule/upcoming
"
)
self
.
api
.
add_resource
(
UpcomingSchedulesResource
,
config
.
api_prefix
+
"
/schedule/upcoming
"
)
self
.
api
.
add_resource
(
ClockDataResource
,
config
.
api_prefix
+
"
/clock
"
)
self
.
api
.
add_resource
(
ClockDataResource
,
config
.
api_prefix
+
"
/clock
"
)
self
.
api
.
add_resource
(
ClockData
Resource
,
config
.
api_prefix
+
"
/status
"
)
self
.
api
.
add_resource
(
Status
Resource
,
config
.
api_prefix
+
"
/status
"
)
self
.
logger
.
info
(
"
Engine API routes successfully set!
"
)
self
.
logger
.
info
(
"
Engine API routes successfully set!
"
)
...
@@ -283,8 +286,11 @@ class ReportSchema(ma.Schema):
...
@@ -283,8 +286,11 @@ class ReportSchema(ma.Schema):
class
StatusSchema
(
ma
.
Schema
):
class
StatusSchema
(
ma
.
Schema
):
class
Meta
:
class
Meta
:
fields
=
(
fields
=
(
"
is_liquidsoap_running
"
,
"
engine
"
,
"
is_core_running
"
"
soundsystem
"
,
"
api
"
,
"
redis_ready
"
,
"
audio_store
"
)
)
...
@@ -420,12 +426,9 @@ class StatusResource(Resource):
...
@@ -420,12 +426,9 @@ class StatusResource(Resource):
self
.
logger
=
logging
.
getLogger
(
"
engine-api
"
)
self
.
logger
=
logging
.
getLogger
(
"
engine-api
"
)
def
get
(
self
):
def
get
(
self
):
status
=
subprocess
.
check_output
([
"
python3
"
,
"
guru.py
"
,
"
-s
"
,
"
-q
"
])
# FIXME Not yet implemented!
status
=
status
.
decode
(
"
utf-8
"
).
replace
(
"'"
,
'"'
)
status
=
json
.
loads
(
status
,
strict
=
False
)
# #ss = SoundSystem(cr)
# return "check removed!" #ss.auraengine_state()
status
=
None
if
not
status
:
if
not
status
:
return
abort
(
204
)
# No content available
return
abort
(
204
)
# No content available
...
...
This diff is collapsed.
Click to expand it.
modules/communication/redis/adapter.py
+
4
−
1
View file @
3755eda0
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
import
sys
import
sys
import
time
import
time
import
json
import
redis
import
redis
import
logging
import
logging
import
threading
import
threading
...
@@ -159,7 +160,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
...
@@ -159,7 +160,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
elif
item
[
"
data
"
]
==
"
get_status
"
:
elif
item
[
"
data
"
]
==
"
get_status
"
:
def
get_status_string
():
def
get_status_string
():
status
=
self
.
soundsystem
.
monitoring
.
get_status
()
status
=
self
.
soundsystem
.
monitoring
.
get_status
()
return
str
(
status
)
return
json
.
dumps
(
status
)
self
.
execute
(
RedisChannel
.
GS_REPLY
.
value
,
get_status_string
)
self
.
execute
(
RedisChannel
.
GS_REPLY
.
value
,
get_status_string
)
...
@@ -186,6 +187,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
...
@@ -186,6 +187,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
elif
item
[
"
data
"
]
==
"
recreate_db
"
:
elif
item
[
"
data
"
]
==
"
recreate_db
"
:
self
.
execute
(
RedisChannel
.
RDB_REPLY
.
value
,
self
.
scheduler
.
recreate_database
)
self
.
execute
(
RedisChannel
.
RDB_REPLY
.
value
,
self
.
scheduler
.
recreate_database
)
elif
item
[
"
data
"
]
==
"
status
"
:
return
True
else
:
else
:
raise
RedisConnectionException
(
"
ServerRedisAdapter Cannot understand command:
"
+
item
[
"
data
"
])
raise
RedisConnectionException
(
"
ServerRedisAdapter Cannot understand command:
"
+
item
[
"
data
"
])
...
...
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