當前位置: 首頁>>代碼示例>>Python>>正文


Python Library.default_version_for_key_async方法代碼示例

本文整理匯總了Python中datamodel.Library.default_version_for_key_async方法的典型用法代碼示例。如果您正苦於以下問題:Python Library.default_version_for_key_async方法的具體用法?Python Library.default_version_for_key_async怎麽用?Python Library.default_version_for_key_async使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在datamodel.Library的用法示例。


在下文中一共展示了Library.default_version_for_key_async方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle_get

# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import default_version_for_key_async [as 別名]
  def handle_get(self, owner, repo):
    library_key = ndb.Key(Library, Library.id(owner, repo))
    version = Library.default_version_for_key_async(library_key).get_result()
    if version is None:
      return self.error('no versions for %s' % Library.id(owner, repo))

    bower_key = ndb.Key(Library, Library.id(owner, repo), Version, version, Content, 'bower')
    bower_object = bower_key.get()
    bower = {} if bower_object is None else json.loads(bower_object.content)
    version_key = bower_key.parent()
    library = version_key.parent().get()

    self.update_search_index(owner, repo, version_key, library, bower)

    if library.kind == 'collection':
      self.update_collection_dependencies(version_key, bower)

    default_version = Library.default_version_for_key_async(library_key).get_result()
    if default_version is not None and default_version != version:
      return self.retry('default version changed while updating indexes')
開發者ID:andymutton,項目名稱:v2,代碼行數:22,代碼來源:manage.py

示例2: handle_get

# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import default_version_for_key_async [as 別名]
  def handle_get(self, scope, package, latest=False):
    self.init_library(scope, package)
    if self.library is None:
      self.response.set_status(404)
      self.response.write('could not find library: %s' % Library.id(scope, package))
      return

    if latest:
      version_id = Library.default_version_for_key_async(self.library.key).get_result()
      if version_id:
        version = Version.get_by_id(version_id, parent=self.library.key)
        if version is not None:
          self.trigger_analysis(version_id, version.sha, transactional=False)
    else:
      versions = Version.query(Version.status == Status.ready, ancestor=self.library.key).fetch()
      for version in versions:
        self.trigger_analysis(version.key.id(), version.sha, transactional=False)
開發者ID:customelements,項目名稱:v2,代碼行數:19,代碼來源:manage.py

示例3: handle_post

# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import default_version_for_key_async [as 別名]
  def handle_post(self):
    # Ignore payloads larger than 5 MB.
    if len(self.request.body) > 1048487 * 5:
      return
    message_json = json.loads(urllib.unquote(self.request.body).rstrip('='))
    message = message_json['message']
    data = base64.b64decode(str(message['data']))
    attributes = message['attributes']
    if len(attributes) == 0:
      logging.error(message)
      return
    owner = attributes['owner']
    repo = attributes['repo']
    version = attributes['version']
    error = attributes.get('error', None)

    version_key = ndb.Key(Library, Library.id(owner, repo), Version, version)

    content = Content.get_by_id('analysis', parent=version_key)
    if content is None:
      return
    if data == '':
      content.set_json(None)
    else:
      content.set_json(json.loads(data))

    if error is None:
      content.status = Status.ready
      content.error = None
    else:
      content.status = Status.error
      content.error = error

    content.put()

    if version_key.id() == Library.default_version_for_key_async(version_key.parent()).get_result():
      task_url = util.update_indexes_task(owner, repo)
      util.new_task(task_url, target='manage')
開發者ID:customelements,項目名稱:v2,代碼行數:40,代碼來源:manage.py

示例4: handle_post

# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import default_version_for_key_async [as 別名]
  def handle_post(self):
    message_json = json.loads(urllib.unquote(self.request.body).rstrip('='))
    message = message_json['message']
    data = base64.b64decode(str(message['data']))
    attributes = message['attributes']
    owner = attributes['owner']
    repo = attributes['repo']
    version = attributes['version']
    error = attributes.get('error', None)

    version_key = ndb.Key(Library, Library.id(owner, repo), Version, version)

    content = Content.get_by_id('analysis', parent=version_key)
    if content is None:
      return
    if data == '':
      content.content = None
    elif len(data) > 500000:
      # Max entity size is only 1MB.
      logging.error('content was too large: %d %s %s', len(data), Library.id(owner, repo), version)
      error = 'content was too large: %d' % len(data)
    else:
      content.content = data

    if error is None:
      content.status = Status.ready
      content.error = None
    else:
      content.status = Status.error
      content.error = error

    content.put()

    if version_key.id() == Library.default_version_for_key_async(version_key.parent()).get_result():
      task_url = util.update_indexes_task(owner, repo)
      util.new_task(task_url, target='manage')
開發者ID:andymutton,項目名稱:v2,代碼行數:38,代碼來源:manage.py


注:本文中的datamodel.Library.default_version_for_key_async方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。