added delete all
This commit is contained in:
parent
7eb728968a
commit
325f083448
@ -126,6 +126,23 @@ else:
|
||||
|
||||
# main input loop
|
||||
command = "dummy"
|
||||
|
||||
|
||||
def delete_all_image():
|
||||
print("Deleting all images")
|
||||
|
||||
baseurl = "http://127.0.0.1:8000"
|
||||
get_url = "/image/delete/all"
|
||||
|
||||
try:
|
||||
response = requests.delete(baseurl + get_url)
|
||||
payload = response.json()
|
||||
print(payload)
|
||||
except os.error:
|
||||
print("Error deleting request")
|
||||
return True
|
||||
|
||||
|
||||
while (command.lower() not in ["exit", "quit", "end"]):
|
||||
|
||||
try:
|
||||
@ -261,6 +278,16 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
||||
delete_image(filename[:-4])
|
||||
index = index + 1
|
||||
|
||||
if command.lower() == "deleteall":
|
||||
if metadata is None:
|
||||
print("No metadata loaded")
|
||||
continue
|
||||
if image_folder is None:
|
||||
print("No image folder selected")
|
||||
continue
|
||||
delete_all_image()
|
||||
index = index + 1
|
||||
|
||||
if command.lower() == "rapid":
|
||||
if metadata is None:
|
||||
print("No metadata loaded")
|
||||
|
||||
@ -72,4 +72,14 @@ class MongoDBService:
|
||||
|
||||
@staticmethod
|
||||
def deleteAll():
|
||||
print("im Delete all")
|
||||
instance = MongoManager.getInstance()
|
||||
|
||||
db = instance.AIC
|
||||
col = db.metadata
|
||||
|
||||
try:
|
||||
resp = col.delete_many({})
|
||||
return resp
|
||||
except:
|
||||
print("Could not delete Metadata")
|
||||
return resp
|
||||
@ -25,6 +25,7 @@ urlpatterns = [
|
||||
url(r'^test/', TestApiClass.test_api),
|
||||
url(r'^image/get/all$', ImageEndpoint.image_api_get_all),
|
||||
url(r'^image/get/(?P<identifier>[\w-]+)$', ImageEndpoint.image_api_get_single),
|
||||
url(r'^image/delete/all$', ImageEndpoint.image_api_delete_all),
|
||||
url(r'^image/delete/(?P<identifier>[\w-]+)$', ImageEndpoint.image_api_delete),
|
||||
url(r'^image/post$', ImageEndpoint.image_api_post)
|
||||
]
|
||||
|
||||
@ -107,4 +107,15 @@ class ImageEndpoint:
|
||||
print(resp)
|
||||
|
||||
|
||||
return JsonResponse({'Result': 'success1'}, safe=False)
|
||||
|
||||
@staticmethod
|
||||
@api_view(['DELETE'])
|
||||
def image_api_delete_all(request: HttpRequest):
|
||||
|
||||
logger.debug('Image DELETE single call: {}'.format(request))
|
||||
|
||||
resp = MongoDBService.deleteAll()
|
||||
print(resp)
|
||||
|
||||
return JsonResponse({'Result': 'success1'}, safe=False)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user