当前位置: 首页>>代码示例>>Python>>正文


Python models.escape_rows函数代码示例

本文整理汇总了Python中notebook.models.escape_rows函数的典型用法代码示例。如果您正苦于以下问题:Python escape_rows函数的具体用法?Python escape_rows怎么用?Python escape_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了escape_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: view_results

def view_results(request, id, first_row=0):
  """
  Returns the view for the results of the QueryHistory with the given id.

  The query results MUST be ready.
  To display query results, one should always go through the execute_query view.
  If the result set has has_result_set=False, display an empty result.

  If ``first_row`` is 0, restarts (if necessary) the query read.  Otherwise, just
  spits out a warning if first_row doesn't match the servers conception.
  Multiple readers will produce a confusing interaction here, and that's known.

  It understands the ``context`` GET parameter. (See execute_query().)
  """
  first_row = long(first_row)
  start_over = (first_row == 0)
  results = type('Result', (object,), {
                'rows': 0,
                'columns': [],
                'has_more': False,
                'start_row': 0,
            })
  data = []
  fetch_error = False
  error_message = ''
  log = ''
  columns = []
  app_name = get_app_name(request)

  query_history = authorized_get_query_history(request, id, must_exist=True)
  query_server = query_history.get_query_server_config()
  db = dbms.get(request.user, query_server)

  handle, state = _get_query_handle_and_state(query_history)
  context_param = request.GET.get('context', '')
  query_context = parse_query_context(context_param)

  # Update the status as expired should not be accessible
  expired = state == models.QueryHistory.STATE.expired

  # Retrieve query results or use empty result if no result set
  try:
    if query_server['server_name'] == 'impala' and not handle.has_result_set:
      downloadable = False
    else:
      results = db.fetch(handle, start_over, 100)

      # Materialize and HTML escape results
      data = escape_rows(results.rows())

      # We display the "Download" button only when we know that there are results:
      downloadable = first_row > 0 or data
      log = db.get_log(handle)
      columns = results.data_table.cols()

  except Exception, ex:
    LOG.exception('error fetching results')

    fetch_error = True
    error_message, log = expand_exception(ex, db, handle)
开发者ID:FashtimeDotCom,项目名称:hue,代码行数:60,代码来源:views.py

示例2: execute

def execute(request):
  response = {'status': -1}

  notebook = json.loads(request.POST.get('notebook', '{}'))
  snippet = json.loads(request.POST.get('snippet', '{}'))

  try:
    response['handle'] = get_api(request, snippet).execute(notebook, snippet)
  finally:
    if notebook['type'].startswith('query-'):
      _snippet = [s for s in notebook['snippets'] if s['id'] == snippet['id']][0]
      if 'handle' in response: # No failure
        _snippet['result']['handle'] = response['handle']
      else:
        _snippet['status'] = 'failed'
      history = _historify(notebook, request.user)
      response['history_id'] = history.id
      response['history_uuid'] = history.uuid
      if notebook['isSaved']: # Keep track of history of saved queries
        response['history_parent_uuid'] = history.dependencies.filter(type__startswith='query-').latest('last_modified').uuid

  # Materialize and HTML escape results
  if response['handle'].get('sync') and response['handle']['result'].get('data'):
    response['handle']['result']['data'] = escape_rows(response['handle']['result']['data'])

  response['status'] = 0

  return JsonResponse(response)
开发者ID:kevinhjk,项目名称:hue,代码行数:28,代码来源:api.py

示例3: execute

def execute(request):
  response = {'status': -1}

  notebook = json.loads(request.POST.get('notebook', '{}'))
  snippet = json.loads(request.POST.get('snippet', '{}'))

  try:
    response['handle'] = get_api(request, snippet).execute(notebook, snippet)
  finally:
    if notebook['type'].startswith('query-'):
      _snippet = [s for s in notebook['snippets'] if s['id'] == snippet['id']][0]
      if 'handle' in response: # No failure
        _snippet['result']['handle'] = response['handle']
        _snippet['result']['statements_count'] = response['handle']['statements_count']
      else:
        _snippet['status'] = 'failed'
      history = _historify(notebook, request.user)
      response['history_id'] = history.id
      response['history_uuid'] = history.uuid

  # Materialize and HTML escape results
  if response['handle'].get('sync') and response['handle']['result'].get('data'):
    response['handle']['result']['data'] = escape_rows(response['handle']['result']['data'])

  response['status'] = 0

  return JsonResponse(response)
开发者ID:OSUser,项目名称:hue,代码行数:27,代码来源:api.py

示例4: _get_sample_data

def _get_sample_data(db, database, table):
  table_obj = db.get_table(database, table)
  sample_data = db.get_sample(database, table_obj)
  response = {'status': -1}

  if sample_data:
    response['status'] = 0
    response['headers'] = sample_data.cols()
    response['rows'] = escape_rows(sample_data.rows(), nulls_only=True)
  else:
    response['message'] = _('Failed to get sample data.')

  return response
开发者ID:dgs414,项目名称:hue,代码行数:13,代码来源:api.py

示例5: get_indexes

def get_indexes(request, database, table):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1, 'error_message': ''}

  indexes = db.get_indexes(database, table)
  if indexes:
    response['status'] = 0
    response['headers'] = indexes.cols()
    response['rows'] = escape_rows(indexes.rows(), nulls_only=True)
  else:
    response['error_message'] = _('Index data took too long to be generated')

  return JsonResponse(response)
开发者ID:dimonge,项目名称:hue,代码行数:14,代码来源:api.py

示例6: get_indexes

def get_indexes(request, database, table):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1}

  indexes = db.get_indexes(database, table)
  if indexes:
    response['status'] = 0
    response['headers'] = indexes.cols()
    response['rows'] = escape_rows(indexes.rows(), nulls_only=True)
  else:
    response['message'] = _('Failed to get indexes.')

  return JsonResponse(response)
开发者ID:HaNeul-Kim,项目名称:hue,代码行数:14,代码来源:api.py

示例7: execute

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, request.fs, request.jt).execute(notebook, snippet)

    # Materialize and HTML escape results
    if response["handle"].get("sync") and response["handle"]["result"].get("data"):
        response["handle"]["result"]["data"] = escape_rows(response["handle"]["result"]["data"])

    response["status"] = 0

    return JsonResponse(response)
开发者ID:shobull,项目名称:hue,代码行数:15,代码来源:api.py

示例8: execute

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, snippet).execute(notebook, snippet)

  # Materialize and HTML escape results
  if response['handle'].get('sync') and response['handle']['result'].get('data'):
    response['handle']['result']['data'] = escape_rows(response['handle']['result']['data'])

  response['status'] = 0

  return JsonResponse(response)
开发者ID:bmannava-invn,项目名称:hue,代码行数:15,代码来源:api.py

示例9: get_sample_data

def get_sample_data(request, database, table):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1}

  table_obj = db.get_table(database, table)
  sample_data = db.get_sample(database, table_obj)
  if sample_data:
    response['status'] = 0
    response['headers'] = sample_data.cols()
    response['rows'] = escape_rows(sample_data.rows(), nulls_only=True)
  else:
    response['message'] = _('Failed to get sample data.')

  return JsonResponse(response)
开发者ID:HaNeul-Kim,项目名称:hue,代码行数:15,代码来源:api.py

示例10: get_functions

def get_functions(request):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1}

  prefix = request.GET.get('prefix', None)
  functions = db.get_functions(prefix)
  if functions:
    response['status'] = 0
    rows = escape_rows(functions.rows(), nulls_only=True)
    response['functions'] = [row[0] for row in rows]
  else:
    response['message'] = _('Failed to get functions.')

  return JsonResponse(response)
开发者ID:HaNeul-Kim,项目名称:hue,代码行数:15,代码来源:api.py

示例11: get_sample_data

def get_sample_data(request, database, table):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1, 'error_message': ''}

  table_obj = db.get_table(database, table)
  sample_data = db.get_sample(database, table_obj)
  if sample_data:
    response['status'] = 0
    response['headers'] = sample_data.cols()
    response['rows'] = escape_rows(sample_data.rows(), nulls_only=True)
  else:
    response['error_message'] = _('Sample data took too long to be generated')

  return JsonResponse(response)
开发者ID:dimonge,项目名称:hue,代码行数:15,代码来源:api.py

示例12: get_sample_data

def get_sample_data(request, database, table):
  db = dbms.get(request.user)
  response = {'status': -1, 'error_message': ''}

  try:
    table_obj = db.get_table(database, table)
    sample_data = db.get_sample(database, table_obj)
    if sample_data:
      response['status'] = 0
      response['headers'] = sample_data.cols()
      response['rows'] = escape_rows(sample_data.rows(), nulls_only=True)
    else:
      response['error_message'] = _('Sample data took too long to be generated')
  except Exception, ex:
    error_message, logs = dbms.expand_exception(ex, db)
    response['error_message'] = error_message
开发者ID:shobull,项目名称:hue,代码行数:16,代码来源:api.py

示例13: get_indexes

def get_indexes(request, database, table):
  query_server = dbms.get_query_server_config(get_app_name(request))
  db = dbms.get(request.user, query_server)
  response = {'status': -1, 'error_message': ''}

  try:
    indexes = db.get_indexes(database, table)
    if indexes:
      response['status'] = 0
      response['headers'] = indexes.cols()
      response['rows'] = escape_rows(indexes.rows(), nulls_only=True)
    else:
      response['error_message'] = _('Index data took too long to be generated')
  except Exception, ex:
    error_message, logs = dbms.expand_exception(ex, db)
    response['error_message'] = error_message
开发者ID:vmax-feihu,项目名称:hue,代码行数:16,代码来源:api.py

示例14: fetch_result_data

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, snippet).fetch_result(notebook, snippet, rows, start_over)

    # Materialize and HTML escape results
    if response["result"].get("data") and response["result"].get("type") == "table":
        response["result"]["data"] = escape_rows(response["result"]["data"])

    response["status"] = 0

    return JsonResponse(response)
开发者ID:fangxingli,项目名称:hue,代码行数:17,代码来源:api.py

示例15: fetch_result_data

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, snippet).fetch_result(notebook, snippet, rows, start_over)

  # Materialize and HTML escape results
  if response['result'].get('data') and response['result'].get('type') == 'table':
    response['result']['data'] = escape_rows(response['result']['data'])

  response['status'] = 0

  return JsonResponse(response)
开发者ID:heshunwq,项目名称:hue,代码行数:17,代码来源:api.py


注:本文中的notebook.models.escape_rows函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。