コード例 #1
0
ファイル: api.py プロジェクト: zhouyan8603/HueBigSQL
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)
コード例 #2
0
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")
コード例 #3
0
ファイル: api.py プロジェクト: JamesLiChina/hue
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: api.py プロジェクト: zhouyan8603/HueBigSQL
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)
コード例 #6
0
ファイル: api.py プロジェクト: JamesLiChina/hue
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)
コード例 #7
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #8
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #9
0
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")
コード例 #10
0
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")
コード例 #11
0
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")
コード例 #12
0
ファイル: api.py プロジェクト: zhouyan8603/HueBigSQL
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)
コード例 #13
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #14
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #15
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #16
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #17
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #18
0
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")
コード例 #19
0
ファイル: api.py プロジェクト: JamesLiChina/hue
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)
コード例 #20
0
ファイル: api.py プロジェクト: zhouyan8603/HueBigSQL
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)
コード例 #21
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #22
0
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")
コード例 #23
0
ファイル: api.py プロジェクト: JamesLiChina/hue
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)
コード例 #24
0
ファイル: api.py プロジェクト: renxiawang/hue
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)
コード例 #25
0
ファイル: api.py プロジェクト: neiodavince/hue
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)
コード例 #26
0
ファイル: api.py プロジェクト: tclcx111/hue
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)
コード例 #27
0
ファイル: api.py プロジェクト: GorillaTester/hue
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)
コード例 #28
0
ファイル: views.py プロジェクト: javachengwc/hue
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)