def getAll(url): data = Flow.getData(url, Flow.getToken()) formInstances = data.get('formInstances') for dataPoint in formInstances: dataPoints.append(dataPoint) try: print( checkTime(time.time()) + ' GET DATA FROM[' + INSTANCE + "," + url.split("?")[1].replace("&", ",") + ']') url = data.get('nextPageUrl') getAll(url) except: print(checkTime(time.time()) + ' DOWNLOAD COMPLETE') return "done"
def getList(): token = Flow.getToken() dashboards = Flow.getData(lumenInstance + '/api/library', token) ds = pd.DataFrame(dashboards['datasets']) return ds.to_dict('records')
data = Flow.getData(url, Flow.getToken()) formInstances = data.get('formInstances') for dataPoint in formInstances: dataPoints.append(dataPoint) try: print( checkTime(time.time()) + ' GET DATA FROM[' + INSTANCE + "," + url.split("?")[1].replace("&", ",") + ']') url = data.get('nextPageUrl') getAll(url) except: print(checkTime(time.time()) + ' DOWNLOAD COMPLETE') return "done" apiData = Flow.getData(surveyURI, Flow.getToken()).get("forms") questions = lambda x: [{ 'id': a['id'], 'name': a['name'], 'questions': details(a['questions']) } for a in x] details = lambda x: [{ 'id': a['id'], 'name': a['name'].replace(' ', '_'), 'type': a['type'], 'code': a['variableName'] } for a in x] meta = questions(apiData[0]['questionGroups']) mt = pd.DataFrame(meta) groupID = mt['id'][0] metadata = mt['questions'][0]
print('INFO : PENDING...WAITING NEXT RESPONSE IN 10 SECONDS') sleep(5) checkUpdate(url) def updateDataset(instance, dataset): api = 'https://' + instance + '.akvolumen.org/api/' try: data = getResponse(api+ 'datasets/' + dataset + '/update', "post") check = api + "job_executions/" + data['updateId'] sleep(5) checkUpdate(check) except: return try: token = Flow.getToken() with open('datasets.csv', newline='') as csvfile: reader = csv.DictReader(csvfile) print('--- STARTING TO UPDATE ---') for idx, row in enumerate(reader): instance = row['instance'] dataset = row['dataset'] print('INFO : UPDATING INSTANCE https://' + instance + '.akvolumen.org' + ' DATASET ID[' + dataset + ']') if idx <= 5: updateDataset(instance, dataset) else: print('WARNING:USAGE LIMIT EXCEEDED') print('--- JOB IS DONE ---') except: print('---TOKEN IS INVALID----')