Commit 507ca276 authored by Rudel Fankep's avatar Rudel Fankep
Browse files

security to delete

parent f2e0e504
...@@ -347,36 +347,40 @@ def download(args): ...@@ -347,36 +347,40 @@ def download(args):
def delete(args): def delete(args):
if args.database in data.keys(): if args.database in data.keys():
if args.tool in data[args.database]['tool'].keys() or args.tool == "raw": if args.tool in data[args.database]['tool'].keys() or args.tool == "raw":
if args.place == 'local': frage = input('Do you want to continue (Y/N)? ')
version = get_local_json_version(args) if frage.lower() == 'y':
dbman_dir = get_local_databases_directory(args) if args.place == 'local':
directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version)) version = get_local_json_version(args)
if os.path.isdir(directory_to_delete): dbman_dir = get_local_databases_directory(args)
shutil.rmtree(directory_to_delete) directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version))
metadata = get_local_metadata(args) if os.path.isdir(directory_to_delete):
for position in range(0, len(metadata)): shutil.rmtree(directory_to_delete)
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version: metadata = get_local_metadata(args)
del metadata[position] for position in range(0, len(metadata)):
break if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
save_local_metadata(args, metadata) del metadata[position]
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir)) break
else: save_local_metadata(args, metadata)
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir)) print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
elif args.place == 's3': else:
version = get_remote_json_version(args) print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
web_store = get_remote_databases_directory(args) elif args.place == 's3':
web_file = path_maker(web_store, get_tar_filename(args, version)) version = get_remote_json_version(args)
if web_file in get_remote_files(): web_store = get_remote_databases_directory(args)
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/delete_remote_file.sh"), web_file]) web_file = path_maker(web_store, get_tar_filename(args, version))
metadata = get_remote_metadata(args) if web_file in get_remote_files():
for position in range(0, len(metadata)): subprocess.run([pkg_resources.resource_filename(__name__, "scripts/delete_remote_file.sh"), web_file])
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version: metadata = get_remote_metadata(args)
del metadata[position] for position in range(0, len(metadata)):
break if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
save_remote_metadata(args, metadata) del metadata[position]
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + web_store) break
else: save_remote_metadata(args, metadata)
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + web_store) 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: else:
print('Tool error. There are following possibility: {}'.format([tool for tool in data[args.database]['tool'].keys()])) print('Tool error. There are following possibility: {}'.format([tool for tool in data[args.database]['tool'].keys()]))
else: else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment