-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteIncidenciasCB.py
71 lines (48 loc) · 1.97 KB
/
deleteIncidenciasCB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
#import pandas as pd
import numpy as np
import copy
import requests
import threading
from datetime import datetime as dt
from configAverageScript import datesIntervals, folderWithCSVs, averageLogFile, averageExportFile, listOfDataToRecoverToCalculateAverages, \
USE_THREADING, CB_FIWARE_SERVICE, CB_FIWARE_SERVICEPATH, CB_URL_TO_SEND_DATA
def deleteItem(item):
print(str(item['id']))
rDelete = requests.delete(url=CB_URL_TO_SEND_DATA+"/"+str(item['id']), timeout=300, data='', headers=headersDelete)
print(rDelete)
print (rDelete.json)
if __name__ == '__main__':
print("Starts!!!")
startdate = dt.utcnow()
print(startdate)
print("[INFO] ["+str(dt.utcnow())+"] ------------------------------------------------")
print("[INFO] ["+str(dt.utcnow())+"] Starts Delete PoI data from CB")
#headers to send data to CB
headersGet = {'Fiware-Service': CB_FIWARE_SERVICE, 'Fiware-ServicePath': CB_FIWARE_SERVICEPATH}
headersDelete = {'Fiware-Service': CB_FIWARE_SERVICE, 'Fiware-ServicePath': CB_FIWARE_SERVICEPATH}
threads = list()
i = 0
while i <= 100:
print("i="+str(i))
r = requests.get(url=CB_URL_TO_SEND_DATA+"?type=PointOfInterest&limit=1000", timeout=300, data='', headers=headersGet)
#print("CB_URL_TO_SEND_DATA")
#print(CB_URL_TO_SEND_DATA)
#print ("response")
#print (r.status_code)
#print (r.json)
#print (r.text)
#print("---------")
data = r.json()
for item in data:
#print(item['id'])
t = threading.Thread(target=deleteItem, args=(item,))
threads.append(t)
t.start()
i += 1
print("End!!!")
currentdate = dt.utcnow()
print("start date")
print(startdate)
print("end date")
print(currentdate)