FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sumologic-python-sdk/scripts/mv-parse.py at main · SumoLogic/sumologic-python-sdk · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SumoLogic
/
sumologic-python-sdk
Public
Notifications
You must be signed in to change notification settings
Fork
77
Star
90
Code
Issues
12
Pull requests
12
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sumologic-python-sdk
/
scripts
/
mv-parse.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (39 loc) · 1.6 KB
Breadcrumbs
sumologic-python-sdk
/
scripts
/
mv-parse.py
Copy path
File metadata and controls
45 lines (39 loc) · 1.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Clobbers (unconditional replace) parse expression everywhere in a given content
#
# python mv-parse.py <accessId> <accessKey> <fully_qualified_folder> <from_expression> <to_expression>
#import logging
import
string
import
sys
from
sumologic
import
SumoLogic
## These two lines enable debugging at httplib level (requests->urllib3->http.client)
## You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
## The only thing missing will be the response.body which is not logged.
#try:
# import http.client as http_client
#except ImportError:
# # Python 2
# import httplib as http_client
#http_client.HTTPConnection.debuglevel = 1
#
## You must initialize logging, otherwise you'll not see debug output.
#logging.basicConfig()
#logging.getLogger().setLevel(logging.DEBUG)
#requests_log = logging.getLogger("requests.packages.urllib3")
#requests_log.setLevel(logging.DEBUG)
#requests_log.propagate = True
args
=
sys
.
argv
sumo
=
SumoLogic
(
args
[
1
],
args
[
2
])
path
,
from_expr
,
to_expr
=
args
[
3
],
args
[
4
],
args
[
5
]
cs
=
sumo
.
contents
(
path
)[
'children'
]
for
c
in
cs
:
if
c
[
'type'
]
==
'Search'
:
print
(
'before: '
+
c
[
'searchQuery'
]
+
'
\n
'
)
c
[
'searchQuery'
]
=
string
.
replace
(
c
[
'searchQuery'
],
from_expr
,
to_expr
,
1
)
print
(
'after: '
+
c
[
'searchQuery'
]
+
'
\n
'
)
elif
c
[
'type'
]
==
'Dashboard'
:
for
col
in
c
[
'columns'
]:
for
m
in
col
[
'monitors'
]:
print
(
'before: '
+
m
[
'searchQuery'
]
+
'
\n
'
)
m
[
'searchQuery'
]
=
string
.
replace
(
m
[
'searchQuery'
],
from_expr
,
to_expr
,
1
)
print
(
'after: '
+
m
[
'searchQuery'
]
+
'
\n
'
)
print
(
sumo
.
create_contents
(
string
.
strip
(
path
,
'/'
).
split
(
'/'
)[
0
],
cs
))
Back
|
FazBrowse Home
|
New Git URL