Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
psotdb
Commits
507ca276
Commit
507ca276
authored
Aug 26, 2019
by
Rudel Fankep
Browse files
security to delete
parent
f2e0e504
Changes
1
Hide whitespace changes
Inline
Side-by-side
dbman/main.py
View file @
507ca276
...
...
@@ -347,36 +347,40 @@ def download(args):
def
delete
(
args
):
if
args
.
database
in
data
.
keys
():
if
args
.
tool
in
data
[
args
.
database
][
'tool'
].
keys
()
or
args
.
tool
==
"raw"
:
if
args
.
place
==
'local'
:
version
=
get_local_json_version
(
args
)
dbman_dir
=
get_local_databases_directory
(
args
)
directory_to_delete
=
path_maker
(
dbman_dir
,
get_tool_directory_name
(
args
,
version
))
if
os
.
path
.
isdir
(
directory_to_delete
):
shutil
.
rmtree
(
directory_to_delete
)
metadata
=
get_local_metadata
(
args
)
for
position
in
range
(
0
,
len
(
metadata
)):
if
metadata
[
position
][
'name'
]
==
args
.
database
and
metadata
[
position
][
'tool'
]
==
args
.
tool
and
metadata
[
position
][
'version'
]
==
version
:
del
metadata
[
position
]
break
save_local_metadata
(
args
,
metadata
)
print
(
"The {} files were successfully delete from: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
os
.
path
.
abspath
(
dbman_dir
))
else
:
print
(
"The {} files aren't existing in: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
os
.
path
.
abspath
(
dbman_dir
))
elif
args
.
place
==
's3'
:
version
=
get_remote_json_version
(
args
)
web_store
=
get_remote_databases_directory
(
args
)
web_file
=
path_maker
(
web_store
,
get_tar_filename
(
args
,
version
))
if
web_file
in
get_remote_files
():
subprocess
.
run
([
pkg_resources
.
resource_filename
(
__name__
,
"scripts/delete_remote_file.sh"
),
web_file
])
metadata
=
get_remote_metadata
(
args
)
for
position
in
range
(
0
,
len
(
metadata
)):
if
metadata
[
position
][
'name'
]
==
args
.
database
and
metadata
[
position
][
'tool'
]
==
args
.
tool
and
metadata
[
position
][
'version'
]
==
version
:
del
metadata
[
position
]
break
save_remote_metadata
(
args
,
metadata
)
print
(
"The {} files were successfully delete from: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
web_store
)
else
:
print
(
"The {} files aren't existing in: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
web_store
)
frage
=
input
(
'Do you want to continue (Y/N)? '
)
if
frage
.
lower
()
==
'y'
:
if
args
.
place
==
'local'
:
version
=
get_local_json_version
(
args
)
dbman_dir
=
get_local_databases_directory
(
args
)
directory_to_delete
=
path_maker
(
dbman_dir
,
get_tool_directory_name
(
args
,
version
))
if
os
.
path
.
isdir
(
directory_to_delete
):
shutil
.
rmtree
(
directory_to_delete
)
metadata
=
get_local_metadata
(
args
)
for
position
in
range
(
0
,
len
(
metadata
)):
if
metadata
[
position
][
'name'
]
==
args
.
database
and
metadata
[
position
][
'tool'
]
==
args
.
tool
and
metadata
[
position
][
'version'
]
==
version
:
del
metadata
[
position
]
break
save_local_metadata
(
args
,
metadata
)
print
(
"The {} files were successfully delete from: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
os
.
path
.
abspath
(
dbman_dir
))
else
:
print
(
"The {} files aren't existing in: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
os
.
path
.
abspath
(
dbman_dir
))
elif
args
.
place
==
's3'
:
version
=
get_remote_json_version
(
args
)
web_store
=
get_remote_databases_directory
(
args
)
web_file
=
path_maker
(
web_store
,
get_tar_filename
(
args
,
version
))
if
web_file
in
get_remote_files
():
subprocess
.
run
([
pkg_resources
.
resource_filename
(
__name__
,
"scripts/delete_remote_file.sh"
),
web_file
])
metadata
=
get_remote_metadata
(
args
)
for
position
in
range
(
0
,
len
(
metadata
)):
if
metadata
[
position
][
'name'
]
==
args
.
database
and
metadata
[
position
][
'tool'
]
==
args
.
tool
and
metadata
[
position
][
'version'
]
==
version
:
del
metadata
[
position
]
break
save_remote_metadata
(
args
,
metadata
)
print
(
"The {} files were successfully delete from: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
web_store
)
else
:
print
(
"The {} files aren't existing in: "
.
format
(
get_tool_directory_name
(
args
,
version
))
+
web_store
)
else
:
print
(
'delete canceled'
)
else
:
print
(
'Tool error. There are following possibility: {}'
.
format
([
tool
for
tool
in
data
[
args
.
database
][
'tool'
].
keys
()]))
else
:
...
...
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