Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
brian-dashboard-manager
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
geant-swd
brian
brian-dashboard-manager
Commits
8e2323e6
Commit
8e2323e6
authored
4 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Move find_folder to the grafana folder module
parent
193c6adc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
brian_dashboard_manager/grafana/folder.py
+16
-4
16 additions, 4 deletions
brian_dashboard_manager/grafana/folder.py
with
16 additions
and
4 deletions
brian_dashboard_manager/grafana/folder.py
+
16
−
4
View file @
8e2323e6
...
...
@@ -6,6 +6,20 @@ from brian_dashboard_manager.grafana.utils.request import TokenRequest
logger
=
logging
.
getLogger
(
__name__
)
def
find_folder
(
token_request
,
title
):
folders
=
get_folders
(
token_request
)
try
:
folder
=
next
(
f
for
f
in
folders
if
f
[
'
title
'
].
lower
()
==
title
.
lower
())
except
StopIteration
:
folder
=
None
if
not
folder
:
logger
.
info
(
f
'
Created folder:
{
title
}
'
)
folder
=
create_folder
(
token_request
,
title
)
return
folder
def
get_folders
(
request
:
TokenRequest
):
return
request
.
get
(
'
api/folders
'
)
...
...
@@ -14,9 +28,7 @@ def create_folder(request: TokenRequest, title):
try
:
data
=
{
'
title
'
:
title
,
'
uid
'
:
title
.
replace
(
'
'
,
'
_
'
)}
r
=
request
.
post
(
'
api/folders
'
,
json
=
data
)
except
HTTPError
as
e
:
message
=
e
.
content
.
get
(
"
message
"
,
""
)
logger
.
exception
(
f
'
Error when creating folder
{
title
}
(
{
message
}
)
'
)
except
HTTPError
:
logger
.
exception
(
f
'
Error when creating folder
{
title
}
'
)
return
None
return
r
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