def close_notebook(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) response['status'] = 0 for snippet in notebook['snippets']: try: if snippet['result']['handle']: get_api(request.user, snippet).close(snippet) except QueryExpired: pass response['message'] = _('Notebook closed !') return JsonResponse(response)
def close_notebook(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) # Todo perms response['status'] = 0 for snippet in notebook['snippets']: try: if snippet['result']['handle']: get_api(request.user, snippet).close(snippet) except QueryExpired: pass response['message'] = _('Notebook closed !') return HttpResponse(json.dumps(response), mimetype="application/json")
def download(request): notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) file_format = request.POST.get('format', 'csv') return get_api(request.user, snippet).download(notebook, snippet, file_format)
def get_logs(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) startFrom = request.POST.get('from') startFrom = int(startFrom) if startFrom else None size = request.POST.get('size') size = int(size) if size else None db = get_api(request.user, snippet) response['logs'] = db.get_log(snippet, startFrom=startFrom, size=size) response['progress'] = db._progress( snippet, response['logs']) if snippet['status'] != 'available' else 100 response['job_urls'] = [{ 'name': job, 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job}) } for job in db._get_jobs(response['logs'])] response['status'] = 0 return JsonResponse(response)
def create_session(request): response = {'status': -1} snippet = json.loads(request.POST.get('snippet', '{}')) response['session'] = get_api(request.user, snippet).create_session(lang=snippet['type']) response['status'] = 0 return JsonResponse(response)
def close_session(request): response = {'status': -1} session = json.loads(request.POST.get('session', '{}')) response['session'] = get_api(request.user, {'type': session['type']}).close_session(session=session) response['status'] = 0 return JsonResponse(response)
def check_status(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['query_status'] = get_api(request.user, snippet).check_status(notebook, snippet) response['status'] = 0 return JsonResponse(response)
def fetch_result_metadata(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['result'] = get_api(request.user, snippet).fetch_result_metadata(notebook, snippet) response['status'] = 0 return HttpResponse(json.dumps(response), mimetype="application/json")
def check_status(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['query_status'] = get_api(request.user, snippet).check_status(notebook, snippet) response['status'] = 0 return HttpResponse(json.dumps(response), mimetype="application/json")
def create_session(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['session'] = get_api(request.user, snippet).create_session(lang=snippet['type']) response['status'] = 0 return HttpResponse(json.dumps(response), mimetype="application/json")
def cancel_statement(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['result'] = get_api(request.user, snippet).cancel(notebook, snippet) response['status'] = 0 return JsonResponse(response)
def execute(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['handle'] = get_api(request.user, snippet).execute(notebook, snippet) response['status'] = 0 return JsonResponse(response)
def fetch_result_metadata(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) response['result'] = get_api(request.user, snippet).fetch_result_metadata(notebook, snippet) response['status'] = 0 return JsonResponse(response)
def close_notebook(request): response = {'status': -1, 'result': []} notebook = json.loads(request.POST.get('notebook', '{}')) for session in notebook['sessions']: try: response['result'].append(get_api(request.user, session).close_session(session)) except QueryExpired: pass except Exception, e: LOG.exception('Error closing session %s' % e.message)
def fetch_result_data(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) rows = json.loads(request.POST.get('rows', 100)) start_over = json.loads(request.POST.get('startOver', False)) response['result'] = get_api(request.user, snippet).fetch_result(notebook, snippet, rows, start_over) response['status'] = 0 return JsonResponse(response)
def close_statement(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) # Todo perms snippet = json.loads(request.POST.get('snippet', '{}')) try: response['result'] = get_api(request.user, snippet).close(snippet) except QueryExpired: pass response['status'] = 0 return HttpResponse(json.dumps(response), mimetype="application/json")
def close_statement(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) try: response['result'] = get_api(request.user, snippet).close(snippet) except QueryExpired: pass response['status'] = 0 return JsonResponse(response)
def close_statement(request): response = {'status': -1} # Passed by check_document_access_permission but unused by APIs notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) try: response['result'] = get_api(request.user, snippet).close_statement(snippet) except QueryExpired: pass response['status'] = 0 response['message'] = _('Statement closed !') return JsonResponse(response)
def get_logs(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) db = get_api(request.user, snippet) response['logs'] = db.get_log(snippet) response['progress'] = db._progress(snippet, response['logs']) if snippet['status'] != 'available' else 100 response['job_urls'] = [{ 'name': job, 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job}) } for job in db._get_jobs(response['logs'])] response['status'] = 0 return HttpResponse(json.dumps(response), mimetype="application/json")
def get_logs(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) db = get_api(request.user, snippet) response['logs'] = db.get_log(snippet) response['progress'] = db._progress(snippet, response['logs']) if snippet['status'] != 'available' else 100 response['job_urls'] = [{ 'name': job, 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job}) } for job in db._get_jobs(response['logs'])] response['status'] = 0 return JsonResponse(response)
def create_session(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) session = [session for session in notebook['sessions'] if snippet['type'] == session['type']] if any(session) and 'properties' in session[0]: properties = session[0]['properties'] else: properties = None response['session'] = get_api(request.user, snippet).create_session(lang=snippet['type'], properties=properties) response['status'] = 0 return JsonResponse(response)
def create_session(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) session = json.loads(request.POST.get('session', '{}')) properties = session.get('properties', []) # If not properties look for previously used notebook session if not properties: old_session = [_session for _session in notebook['sessions'] if _session['type'] == session['type']] if any(old_session) and 'properties' in old_session[0]: properties = old_session[0]['properties'] response['session'] = get_api(request.user, session).create_session(lang=session['type'], properties=properties) response['status'] = 0 return JsonResponse(response)
def create_session(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) session = json.loads(request.POST.get('session', '{}')) properties = session.get('properties', []) # If not properties look for previously used notebook session if not properties: old_session = [_session for _session in notebook['sessions'] if _session['type'] == session['type']] if any(old_session) and 'properties' in old_session[0]: properties = old_session[0]['properties'] response['session'] = get_api(request.user, session).create_session(lang=session['type'], properties=properties) response['session']['properties'] = properties response['status'] = 0 return JsonResponse(response)
def get_logs(request): response = {'status': -1} notebook = json.loads(request.POST.get('notebook', '{}')) snippet = json.loads(request.POST.get('snippet', '{}')) startFrom = request.POST.get('from') startFrom = int(startFrom) if startFrom else None size = request.POST.get('size') size = int(size) if size else None db = get_api(request.user, snippet) response['logs'] = db.get_log(notebook, snippet, startFrom=startFrom, size=size) response['progress'] = db._progress(snippet, response['logs']) if snippet['status'] != 'available' and snippet['status'] != 'success' else 100 response['job_urls'] = [{ 'name': job, 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job}) } for job in db._get_jobs(response['logs'])] response['status'] = 0 return JsonResponse(response)