Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vladimir
noc
Commits
860c1702
Verified
Commit
860c1702
authored
Jul 04, 2022
by
Andrey Vertiprahov
Browse files
Convert streaming.
parent
e7432e2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
services/activator/api/activator.py
View file @
860c1702
...
...
@@ -98,8 +98,9 @@ class ActivatorAPI(API):
if
not
streaming
or
not
result
:
return
result
streaming
=
StreamingConfig
(
**
streaming
)
self
.
service
.
publish
(
value
=
self
.
clean_streaming_result
(
result
,
StreamingConfig
(
**
streaming
)
)
,
value
=
self
.
clean_streaming_result
(
result
,
streaming
),
stream
=
streaming
.
stream
,
partition
=
streaming
.
partition
,
headers
=
{},
...
...
@@ -125,7 +126,7 @@ class ActivatorAPI(API):
@
staticmethod
def
script_get_label
(
name
,
credentials
,
*
args
,
**
kwargs
):
return
"%s %s"
%
(
name
,
credentials
.
get
(
"address"
,
"-"
)
)
return
f
'
{
name
}
{
credentials
.
get
(
"address"
,
"-"
)
}
'
@
api
async
def
snmp_v1_get
(
self
,
address
,
community
,
oid
):
...
...
@@ -158,7 +159,7 @@ class ActivatorAPI(API):
@
staticmethod
def
snmp_v1_get_get_label
(
address
,
community
,
oid
):
return
"%s %s"
%
(
address
,
oid
)
return
f
"
{
address
}
{
oid
}
"
@
api
async
def
snmp_v2c_get
(
self
,
address
,
community
,
oid
):
...
...
@@ -191,7 +192,7 @@ class ActivatorAPI(API):
@
staticmethod
def
snmp_v2_get_get_label
(
address
,
community
,
oid
):
return
"%s %s"
%
(
address
,
oid
)
return
f
"
{
address
}
{
oid
}
"
@
api
async
def
http_get
(
self
,
url
,
ignore_errors
=
False
):
...
...
@@ -212,17 +213,17 @@ class ActivatorAPI(API):
if
200
<=
code
<=
299
:
return
smart_text
(
body
,
errors
=
"replace"
)
elif
ignore_errors
:
metrics
[
"error"
,
(
"type"
,
"http_error_
%s"
%
code
)]
+=
1
metrics
[
"error"
,
(
"type"
,
f
"http_error_
{
code
}
"
)]
+=
1
self
.
logger
.
debug
(
"HTTP GET %s failed: %s %s"
,
url
,
code
,
body
)
return
smart_text
(
header
,
errors
=
"replace"
)
+
smart_text
(
body
,
errors
=
"replace"
)
else
:
metrics
[
"error"
,
(
"type"
,
"http_error_
%s"
%
code
)]
+=
1
metrics
[
"error"
,
(
"type"
,
f
"http_error_
{
code
}
"
)]
+=
1
self
.
logger
.
debug
(
"HTTP GET %s failed: %s %s"
,
url
,
code
,
body
)
return
None
@
staticmethod
def
http_get_get_label
(
url
):
return
"%s"
%
url
return
f
"
{
url
}
"
@
api
@
executor
(
"script"
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment