Merge branch 'master' of https://hyde.infosys.tuwien.ac.at/aic20/g4t2
This commit is contained in:
commit
ce34ce8562
@ -126,6 +126,23 @@ else:
|
|||||||
|
|
||||||
# main input loop
|
# main input loop
|
||||||
command = "dummy"
|
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"]):
|
while (command.lower() not in ["exit", "quit", "end"]):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -261,6 +278,16 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
|||||||
delete_image(filename[:-4])
|
delete_image(filename[:-4])
|
||||||
index = index + 1
|
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 command.lower() == "rapid":
|
||||||
if metadata is None:
|
if metadata is None:
|
||||||
print("No metadata loaded")
|
print("No metadata loaded")
|
||||||
|
|||||||
@ -72,4 +72,14 @@ class MongoDBService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deleteAll():
|
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'^test/', TestApiClass.test_api),
|
||||||
url(r'^image/get/all$', ImageEndpoint.image_api_get_all),
|
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/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/delete/(?P<identifier>[\w-]+)$', ImageEndpoint.image_api_delete),
|
||||||
url(r'^image/post$', ImageEndpoint.image_api_post)
|
url(r'^image/post$', ImageEndpoint.image_api_post)
|
||||||
]
|
]
|
||||||
|
|||||||
@ -114,3 +114,14 @@ class ImageEndpoint:
|
|||||||
print(resp)
|
print(resp)
|
||||||
|
|
||||||
return JsonResponse({'Result': 'success1'}, safe=False)
|
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