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


Python Notebook.data方法代码示例

本文整理汇总了Python中notebook.connectors.base.Notebook.data方法的典型用法代码示例。如果您正苦于以下问题:Python Notebook.data方法的具体用法?Python Notebook.data怎么用?Python Notebook.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notebook.connectors.base.Notebook的用法示例。


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

示例1: editor

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def editor(request):
  editor_id = request.GET.get('editor')

  if editor_id:
    editor = Notebook(document=Document2.objects.get(id=editor_id))
  else:
    editor = Notebook()
    data = editor.get_data()
    data['name'] = 'Hive SQL Editor'
    data['snippets'] = json.loads('[{"id":"c111cbb4-f475-4050-c5a1-02df6c31e3d8","name":"","type":"hive","editorMode":"text/x-hiveql","statement_raw":"Example: SELECT * FROM tablename, or press CTRL + space","codemirrorSize":100,"status":"ready","properties":{"settings":[],"files":[]},"variables":[],"variableNames":[],"statement":"Example: SELECT * FROM tablename, or press CTRL + space","result":{"id":"149347d9-3ae7-8d06-4cc8-d4bce5e72dc8","type":"table","hasResultset":true,"handle":{},"meta":[],"cleanedMeta":[],"fetchedOnce":false,"startTime":"2015-07-17T20:38:21.970Z","endTime":"2015-07-17T20:38:21.970Z","executionTime":0,"cleanedNumericMeta":[],"cleanedStringMeta":[],"cleanedDateTimeMeta":[],"data":[],"logs":"","logLines":0,"errors":"","hasSomeResults":false},"showGrid":true,"showChart":false,"showLogs":false,"progress":0,"size":12,"offset":0,"isLoading":false,"klass":"snippet card card-widget","editorKlass":"editor span12","resultsKlass":"results hive","errorsKlass":"results hive alert alert-error","chartType":"bars","chartSorting":"none","chartYMulti":[],"chartData":[],"tempChartOptions":{},"isLeftPanelVisible":false,"codeVisible":true,"settingsVisible":false,"checkStatusTimeout":null}]')
    editor.data = json.dumps(data)

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "Hive SQL", "type": "hive"}],
          'snippet_placeholders' : {
              'scala': _('Example: 1 + 1, or press CTRL + space'),
              'python': _('Example: 1 + 1, or press CTRL + space'),
              'impala': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'hive': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'text': _('<h2>This is a text snippet</h2>Type your text here')
          }
      }),
      'autocomplete_base_url': autocomplete_base_url,
  })
开发者ID:RoxC,项目名称:hue,代码行数:34,代码来源:views.py

示例2: editor

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def editor(request):
  editor_id = request.GET.get('editor')
  editor_type = request.GET.get('type', 'hive')

  if editor_id:  # Open existing saved editor document
    editor = Notebook(document=Document2.objects.get(id=editor_id))
    editor_type = editor.get_data()['type'].rsplit('-', 1)[-1]
    editor = upgrade_session_properties(request, notebook=editor)
  else:  # Create new editor
    editor = Notebook()
    data = editor.get_data()

    data['name'] = ''
    data['type'] = 'query-%s' % editor_type  # TODO: Add handling for non-SQL types
    editor.data = json.dumps(data)

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "%s SQL" % editor_type.title(), "type": editor_type}],
          'mode': 'editor',
          'is_optimizer_enabled': has_optimizer(),
      }),
      'editor_type': editor_type,
  })
开发者ID:277800076,项目名称:hue,代码行数:27,代码来源:views.py

示例3: editor

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def editor(request):
  editor_id = request.GET.get('editor')
  editor_type = request.GET.get('type', 'hive')

  if editor_id:
    editor = Notebook(document=Document2.objects.get(id=editor_id))
  else:
    editor = Notebook()
    data = editor.get_data()
    data['name'] = 'Untitled %s Query' % editor_type.title()
    data['type'] = 'query-%s' % editor_type
    editor.data = json.dumps(data)

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "%s SQL" % editor_type.title(), "type": editor_type}],
          'mode': 'editor',
      }),
      'editor_type': editor_type,
      'autocomplete_base_url': autocomplete_base_url,
  })
开发者ID:shobull,项目名称:hue,代码行数:30,代码来源:views.py

示例4: make_notebook2

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def make_notebook2(name='Browse', description='', is_saved=False, snippets=None):

  from notebook.connectors.hiveserver2 import HS2Api

  editor = Notebook()

  _snippets = []

  for snippet in snippets:
    default_properties = {
        'files': [],
        'functions': [],
        'settings': []
    }

    if snippet['type'] == 'hive':
      pass
    elif snippet['type'] == 'impala':
      pass
    elif snippet['type'] == 'java':
      pass

    _snippets.append(snippet)

  print _snippets

  data = {
    'name': name,
    'uuid': str(uuid.uuid4()),
    'description': description,
    'sessions': [
      {
         'type': _snippet['type'],
         'properties': HS2Api.get_properties(snippet['type']),
         'id': None
      } for _snippet in _snippets # Non unique types currently
    ],
    'selectedSnippet': _snippets[0]['type'],
    'type': 'notebook',
    'showHistory': False,
    'isSaved': is_saved,
    'snippets': [
      {
         'status': _snippet.get('status', 'ready'),
         'id': str(uuid.uuid4()),
         'statement_raw': _snippet.get('statement', ''),
         'statement': _snippet.get('statement', ''),
         'type': _snippet.get('type'),
         'properties': _snippet.properties,
         'name': name,
         'database': _snippet.get('database'),
         'result': {}
      } for _snippet in _snippets
    ]
  }

  editor.data = json.dumps(data)

  return editor
开发者ID:CaeserNieh,项目名称:hue,代码行数:61,代码来源:models.py

示例5: make_notebook

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def make_notebook(name='Browse', description='', editor_type='hive', statement='', status='ready',
                  files=None, functions=None, settings=None):

  from notebook.connectors.hiveserver2 import HS2Api

  editor = Notebook()

  properties = HS2Api.get_properties(editor_type)

  if editor_type == 'hive':
    if files is not None:
      _update_property_value(properties, 'files', files)

    if functions is not None:
      _update_property_value(properties, 'functions', functions)

    if settings is not None:
      _update_property_value(properties, 'settings', settings)
  elif editor_type == 'impala':
    if settings is not None:
      _update_property_value(properties, 'files', files)

  editor.data = json.dumps({
    'name': name,
    'description': description,
    'sessions': [
      {
         'type': editor_type,
         'properties': properties,
         'id': None
      }
    ],
    'selectedSnippet': editor_type,
    'type': 'query-%s' % editor_type,
    'showHistory': True,

    'snippets': [
      {
         'status': status,
         'id': str(uuid.uuid4()),
         'statement_raw': statement,
         'statement': statement,
         'type': editor_type,
         'properties': {
            'files': [] if files is None else files,
            'functions': [] if functions is None else functions,
            'settings': [] if settings is None else settings
         },
         'name': name,
         'database': 'default',
         'result': {}
      }
    ]
  })
  
  return editor
开发者ID:277800076,项目名称:hue,代码行数:58,代码来源:models.py

示例6: browse

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def browse(request, database, table):
  editor_type = request.GET.get('type', 'hive')

  snippet = {'type': editor_type}
  sql_select = get_api(request.user, snippet, request.fs, request.jt).get_select_star_query(snippet, database, table)

  editor = Notebook()
  editor.data = json.dumps({
    'description':'',
    'sessions':[
      {
         'type':'hive',
         'properties':[

         ],
         'id':None
      }
    ],
    'selectedSnippet':'hive',
    'type': 'query-%s' % editor_type,

    'snippets':[
      {
         'status':'ready-execute',
         'id':'e8b323b3-88ef-3a84-6264-af11fa5fbefb',
         'statement_raw': sql_select,
         'statement': sql_select,
         'type': editor_type,
         'properties':{
            'files':[
            ],
            'settings':[
            ]
         },
         'name': 'Browse',
         'database':'default',
         'result':{  }
      }
    ],
    'name':'Browse'
  })

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "%s SQL" % editor_type.title(), "type": editor_type}],
          'mode': 'editor',
      }),
      'editor_type': editor_type,
  })
开发者ID:aguicode,项目名称:hue,代码行数:52,代码来源:views.py

示例7: create_notebook

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def create_notebook(request):
  response = {'status': -1}

  editor_type = request.POST.get('type', 'notebook')
  directory_uuid = request.POST.get('directory_uuid')

  editor = Notebook()
  data = editor.get_data()

  if editor_type != 'notebook':
    data['name'] = ''
    data['type'] = 'query-%s' % editor_type  # TODO: Add handling for non-SQL types

  data['directoryUuid'] = directory_uuid
  editor.data = json.dumps(data)

  response['notebook'] = editor.get_data()
  response['status'] = 0

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

示例8: create_notebook

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def create_notebook(request):
    response = {"status": -1}

    editor_type = request.POST.get("type", "notebook")
    directory_uuid = request.POST.get("directory_uuid")

    editor = Notebook()
    data = editor.get_data()

    if editor_type != "notebook":
        data["name"] = ""
        data["type"] = "query-%s" % editor_type  # TODO: Add handling for non-SQL types

    data["directoryUuid"] = directory_uuid
    editor.data = json.dumps(data)

    response["notebook"] = editor.get_data()
    response["status"] = 0

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

示例9: editor

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def editor(request):
  editor_id = request.GET.get('editor')
  editor_type = request.GET.get('type', 'hive')

  if editor_id:
    editor = Notebook(document=Document2.objects.get(id=editor_id))
  else:
    editor = Notebook()
    data = editor.get_data()
    data['name'] = 'Unsaved %s Query' % editor_type.title()
    data['type'] = 'query-%s' % editor_type
    editor.data = json.dumps(data)

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "%s SQL" % editor_type.title(), "type": editor_type}],
          'mode': 'editor',
      }),
      'editor_type': editor_type,
  })
开发者ID:aguicode,项目名称:hue,代码行数:23,代码来源:views.py

示例10: make_notebook

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def make_notebook(name='Browse', description='', editor_type='hive', statement='', status='ready', files=None, functions=None, settings=None):
  editor = Notebook()

  editor.data = json.dumps({
    'name': name,
    'description': description,
    'sessions': [
      {
         'type': editor_type,
         'properties': [

         ],
         'id': None
      }
    ],
    'selectedSnippet': editor_type,
    'type': 'query-%s' % editor_type,
    'showHistory': True,

    'snippets': [
      {
         'status': status,
         'id': str(uuid.uuid4()),
         'statement_raw': statement,
         'statement': statement,
         'type': editor_type,
         'properties': {
            'files': [] if files is None else files,
            'functions': [] if functions is None else functions,
            'settings': [] if settings is None else settings
         },
         'name': name,
         'database': 'default',
         'result': {}
      }
    ]
  })
  
  return editor
开发者ID:alvarocantador,项目名称:hue,代码行数:41,代码来源:models.py

示例11: editor

# 需要导入模块: from notebook.connectors.base import Notebook [as 别名]
# 或者: from notebook.connectors.base.Notebook import data [as 别名]
def editor(request):
  editor_id = request.GET.get('editor')

  if editor_id:
    editor = Notebook(document=Document2.objects.get(id=editor_id))
  else:
    editor = Notebook()
    data = editor.get_data()
    data['name'] = 'My SQL query'
    editor.data = json.dumps(data)

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "Hive SQL", "type": "hive"}]
      }),
      'autocomplete_base_url': autocomplete_base_url,
  })
开发者ID:zhangxiongfei2012,项目名称:hue,代码行数:26,代码来源:views.py


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