Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2fefe47
authored
Mar 23, 2021
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change get_disk_images function in store API to get list of files with given extensions
parent
f99b5852
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
circle/dashboard/forms.py
+3
-1
circle/dashboard/store_api.py
+8
-6
No files found.
circle/dashboard/forms.py
View file @
c2fefe47
...
@@ -935,7 +935,9 @@ class VmImportDiskForm(OperationForm):
...
@@ -935,7 +935,9 @@ class VmImportDiskForm(OperationForm):
self
.
user
=
kwargs
.
pop
(
'user'
)
self
.
user
=
kwargs
.
pop
(
'user'
)
super
(
VmImportDiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
VmImportDiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
disk_paths
=
Store
(
self
.
user
)
.
get_disk_images
()
disk_paths
=
Store
(
self
.
user
)
.
get_files_with_exts
(
[
f
[
0
]
for
f
in
Disk
.
EXPORT_FORMATS
]
)
disk_filenames
=
[
os
.
path
.
basename
(
item
)
for
item
in
disk_paths
]
disk_filenames
=
[
os
.
path
.
basename
(
item
)
for
item
in
disk_paths
]
self
.
choices
=
zip
(
disk_paths
,
disk_filenames
)
self
.
choices
=
zip
(
disk_paths
,
disk_filenames
)
...
...
circle/dashboard/store_api.py
View file @
c2fefe47
...
@@ -110,14 +110,16 @@ class Store(object):
...
@@ -110,14 +110,16 @@ class Store(object):
else
:
else
:
return
result
return
result
def
get_disk_images
(
self
,
path
=
'/'
):
def
get_files_with_exts
(
self
,
exts
,
path
=
'/'
):
images
=
[]
"""
Get list of files from store with the given file extensions.
"""
matching_files
=
[]
file_list
=
self
.
list
(
path
,
process
=
False
)
file_list
=
self
.
list
(
path
,
process
=
False
)
export_formats
=
[
item
[
0
]
for
item
in
Disk
.
EXPORT_FORMATS
]
for
item
in
file_list
:
for
item
in
file_list
:
if
os
.
path
.
splitext
(
item
[
'NAME'
])[
1
]
.
strip
(
'.'
)
in
ex
port_forma
ts
:
if
os
.
path
.
splitext
(
item
[
'NAME'
])[
1
]
.
strip
(
'.'
)
in
exts
:
imag
es
.
append
(
os
.
path
.
join
(
path
,
item
[
'NAME'
]))
matching_fil
es
.
append
(
os
.
path
.
join
(
path
,
item
[
'NAME'
]))
return
imag
es
return
matching_fil
es
def
request_download
(
self
,
path
):
def
request_download
(
self
,
path
):
r
=
self
.
_request_cmd
(
"DOWNLOAD"
,
PATH
=
path
,
timeout
=
10
)
r
=
self
.
_request_cmd
(
"DOWNLOAD"
,
PATH
=
path
,
timeout
=
10
)
...
...
Write
Preview
Markdown
is supported
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