Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
cfad2cf1
Commit
cfad2cf1
authored
Jan 21, 2022
by
David Trattnig
Browse files
Less verbose logging when API fails. #33
parent
70ffd1a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/monitor.py
View file @
cfad2cf1
...
...
@@ -197,16 +197,28 @@ class AuraMonitor:
body
[
"is_healthy"
]
=
is_healthy
body
[
"details"
]
=
json
.
dumps
(
data
,
default
=
str
)
json_data
=
json
.
dumps
(
body
,
default
=
str
)
url
=
self
.
config
.
get
(
"api_engine_store_health"
)
url
=
url
.
replace
(
"${ENGINE_NUMBER}"
,
str
(
self
.
config
.
get
(
"api_engine_number"
)))
headers
=
{
'content-type'
:
'application/json'
}
r
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
)
response
=
requests
.
Response
()
response
.
status_code
=
404
if
r
.
status_code
==
204
:
self
.
logger
.
info
(
"Successfully posted healthy=%s state to Engine API!"
%
is_healthy
)
else
:
self
.
logger
.
error
(
"HTTP %s | Error while pushing health state to Engine API: %s"
%
(
r
.
status_code
,
str
(
r
.
json
())))
try
:
response
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
)
if
response
.
status_code
==
204
:
self
.
logger
.
info
(
"Successfully posted healthy=%s state to Engine API!"
%
is_healthy
)
else
:
msg
=
SU
.
red
(
f
"HTTP
{
response
.
status_code
}
| Error while pushing health state to Engine API:
{
response
.
json
()
}
"
)
self
.
logger
.
error
(
msg
)
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"Bad Request when posting health-status to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"Timeout when posting health-status to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"Unknown Exception when posting health-status to
{
url
}
"
))
return
response
def
update_status
(
self
):
...
...
src/plugins/trackservice.py
View file @
cfad2cf1
...
...
@@ -162,16 +162,30 @@ class TrackServiceHandler():
Posts the given `PlaylistEntry` to the Engine API Playlog.
"""
data
=
SU
.
clean_dictionary
(
data
)
self
.
logger
.
info
(
"Posting playlog to Engine API..."
)
url
=
self
.
config
.
get
(
"api_engine_store_playlog"
)
headers
=
{
'content-type'
:
'application/json'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
self
.
logger
.
debug
(
"Playlog Data: "
+
body
)
response
=
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
or
response
.
status_code
!=
204
:
msg
=
f
"Error while posting playlog to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"utf-8"
))
response
=
requests
.
Response
()
response
.
status_code
=
404
try
:
response
=
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
:
msg
=
f
"Error while posting playlog to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"utf-8"
))
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"Bad Request when posting playlog to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"Timeout when posting playlog to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"Unknown Exception when posting playlog to
{
url
}
"
))
return
response
def
store_clock_info
(
self
,
data
):
...
...
@@ -218,10 +232,23 @@ class TrackServiceHandler():
headers
=
{
'content-type'
:
'application/json'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
self
.
logger
.
debug
(
"Clock Data: "
+
body
)
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
or
response
.
status_code
!=
204
:
msg
=
f
"Error while posting clock-info to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"utf-8"
))
response
=
requests
.
Response
()
response
.
status_code
=
404
try
:
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
:
msg
=
f
"Error while posting clock-info to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"utf-8"
))
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"Bad Request when posting clock-info to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"Timeout when posting clock-info to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"Unknown Exception when posting clock-info to
{
url
}
"
))
return
response
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment