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
617eaf25
Commit
617eaf25
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refactor: use SimpleApi instead of urllib
parent
5deb8146
No related branches found
No related tags found
1 merge request
!35
ORM-less scheduling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aura_engine/plugins/monitor.py
+12
-13
12 additions, 13 deletions
src/aura_engine/plugins/monitor.py
with
12 additions
and
13 deletions
src/aura_engine/plugins/monitor.py
+
12
−
13
View file @
617eaf25
...
...
@@ -32,12 +32,12 @@ import logging
import
os
import
platform
import
threading
import
urllib
from
enum
import
Enum
from
socket
import
AF_INET
,
SO_BROADCAST
,
SOCK_DGRAM
,
SOL_SOCKET
,
socket
import
requests
from
aura_engine.base.api
import
SimpleRestApi
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.base.utils
import
SimpleUtil
as
SU
...
...
@@ -70,7 +70,9 @@ class AuraMonitor:
"""
api
:
SimpleRestApi
logger
=
None
config
=
None
engine
=
None
status
=
None
already_invalid
=
None
...
...
@@ -86,6 +88,7 @@ class AuraMonitor:
"""
Initialize Monitoring.
"""
self
.
api
=
SimpleRestApi
()
self
.
logger
=
logging
.
getLogger
(
"
engine
"
)
self
.
config
=
AuraConfig
.
config
()
self
.
engine
=
engine
...
...
@@ -315,14 +318,13 @@ class AuraMonitor:
def
validate_url_connection
(
self
,
url
):
"""
Check if connection to passed URL is successful.
# FIXME This should be refactored to a simple ping
"""
try
:
request
=
urllib
.
request
.
Request
(
url
)
response
=
urllib
.
request
.
urlopen
(
request
)
response
.
read
()
except
Exception
:
requests
.
get
(
url
,
timeout
=
5
)
except
requests
.
ConnectionError
:
return
False
return
True
def
validate_directory
(
self
,
dir_path
):
...
...
@@ -355,14 +357,11 @@ class AuraMonitor:
(dict[]): A Python object representing the JSON structure
"""
data
=
None
try
:
request
=
urllib
.
request
.
Request
(
url
)
response
=
urllib
.
request
.
urlopen
(
request
)
data
=
response
.
read
()
return
json
.
loads
(
data
,
strict
=
False
)
except
(
urllib
.
error
.
URLError
,
IOError
,
ValueError
)
as
e
:
result
=
self
.
api
.
get
(
url
)
if
200
==
result
.
response
.
status_code
:
return
result
.
json
except
requests
.
ConnectionError
as
e
:
self
.
logger
.
error
(
"
Error while connecting to URL
'
%s
'
- %s
"
%
(
url
,
e
))
return
MonitorResponseCode
.
INVALID_STATE
.
value
...
...
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