Exemple #1
0
def install_examples(request):
  response = {'status': -1, 'message': '', 'errorMessage': ''}

  try:
    connector = Connector.objects.get(id=request.POST.get('connector'))
    if connector:
      dialect = connector.dialect
      db_name = request.POST.get('db_name', 'default')
      interpreter = get_interpreter(connector_type=connector.to_dict()['type'], user=request.user)

      successes, errors = beeswax_install_examples.Command().handle(
          dialect=dialect, db_name=db_name, user=request.user, interpreter=interpreter, request=request
      )
      response['message'] = ' '.join(successes)
      response['errorMessage'] = ' '.join(errors)
      response['status'] = len(errors)
    else:
      Command().handle(user=request.user, dialect=request.POST.get('dialect', 'hive'))
      response['status'] = 0
      response['message'] = _('Examples refreshed')
  except Exception as e:
    msg = 'Error during Editor samples installation'
    LOG.exception(msg)
    response['errorMessage'] = msg + ': ' + str(e)

  return JsonResponse(response)
Exemple #2
0
def install_examples(request):
    response = {'status': -1, 'message': ''}

    if request.method == 'POST':
        try:
            connector = Connector.objects.get(id=request.POST.get('connector'))
            if connector:
                app_name = 'beeswax' if connector.dialect == 'hive' else 'impala'
                db_name = request.POST.get('db_name', 'default')
                interpreter = get_interpreter(
                    connector_type=connector.to_dict()['type'],
                    user=request.user)

                beeswax_install_examples.Command().handle(
                    app_name=app_name,
                    db_name=db_name,
                    user=request.user,
                    interpreter=interpreter)
            else:
                Command().handle(user=request.user)
                response['status'] = 0
        except Exception as err:
            LOG.exception(err)
            response['message'] = str(err)
    else:
        response['message'] = _('A POST request is required.')

    return JsonResponse(response)
Exemple #3
0
def install_examples(request):
    response = {'status': -1, 'message': ''}

    if request.method == 'POST':
        try:
            Command().handle(user=request.user)
            response['status'] = 0
        except Exception, err:
            LOG.exception(err)
            response['message'] = str(err)
Exemple #4
0
def install_examples(request):
    response = {'status': -1, 'message': ''}

    if request.method == 'POST':
        try:
            Command().handle(user=request.user)
            response['status'] = 0
        except Exception as err:
            LOG.exception(err)
            response['message'] = str(err)
    else:
        response['message'] = _('A POST request is required.')

    return JsonResponse(response)