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


Python Credentials.all方法代码示例

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


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

示例1: get

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
  def get(self):
    video_url = self.request.get("url")

    """Render the main page."""
    logging.info('Inserting timeline item to all users')
    users = Credentials.all()
    total_users = users.count()

    if total_users > 10:
      return 'Total user count is %d. Aborting broadcast to save your quota' % (
          total_users)

    body = {
        'notification': {'level': 'DEFAULT'}, 
        'text': video_url,
    }
    if 'youtube' in video_url:
        body['menuItems'] = [{'action' : 'PLAY_VIDEO', 'payload' : video_url}]

    batch_responses = _BatchCallback()
    batch = BatchHttpRequest(callback=batch_responses.callback)
    for user in users:
      creds = StorageByKeyName(
          Credentials, user.key().name(), 'credentials').get()
      mirror_service = util.create_service('mirror', 'v1', creds)
      timeline = retrieve_all_timeline_items(mirror_service)
      batch.add(
          mirror_service.timeline().insert(body=body),
          request_id=user.key().name())


    batch.execute(httplib2.Http())

    self._render_template('')
开发者ID:Repraptor,项目名称:sendtoglassgae,代码行数:36,代码来源:main_handler.py

示例2: _insert_item_all_users

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
  def _insert_item_all_users(self):
    """Insert a timeline item to all authorized users."""
    logging.info('Inserting timeline item to all users')
    users = Credentials.all()
    total_users = users.count()

    if total_users > 10:
      return 'Total user count is %d. Aborting broadcast to save your quota' % (
          total_users)
    body = {
        'text': 'Hello Everyone!',
        'notification': {'level': 'DEFAULT'}
    }

    batch_responses = _BatchCallback()
    batch = BatchHttpRequest(callback=batch_responses.callback)
    for user in users:
      creds = StorageByKeyName(
          Credentials, user.key().name(), 'credentials').get()
      mirror_service = util.create_service('mirror', 'v1', creds)
      batch.add(
          mirror_service.timeline().insert(body=body),
          request_id=user.key().name())

    batch.execute(httplib2.Http())
    return 'Successfully sent cards to %d users (%d failed).' % (
        batch_responses.success, batch_responses.failure)
开发者ID:xaro,项目名称:glass_appalooza,代码行数:29,代码来源:main_handler.py

示例3: get

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
 def get(self):
   """Insert a timeline item to all authorized users."""
   logging.info('Inserting horoscopes item to all users')
   users = Credentials.all()
   total_users = users.count()
   
   scopes = horoscopes.getHoroscopes(self)
   body   = horoscopes.createHoroscopeBundle(self, scopes) 
   
   for user in users:
     creds = StorageByKeyName(
         Credentials, user.key().name(), 'credentials').get()
     mirror_service = util.create_service('mirror', 'v1', creds)
     mirror_service.timeline().insert(body=body).execute()
       
   self._render_template()
开发者ID:niketdesai,项目名称:glassscopes,代码行数:18,代码来源:main_handler.py

示例4: _insert_item_all_users

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
    def _insert_item_all_users(self):
        """Insert a timeline item to all authorized users."""
        logging.info("Inserting timeline item to all users")
        users = Credentials.all()
        total_users = users.count()

        if total_users > 10:
            return "Total user count is %d. Aborting broadcast to save your quota" % (total_users)
        body = {"text": "Hello Everyone!", "notification": {"level": "DEFAULT"}}

        batch_responses = _BatchCallback()
        batch = BatchHttpRequest(callback=batch_responses.callback)
        for user in users:
            creds = StorageByKeyName(Credentials, user.key().name(), "credentials").get()
            mirror_service = util.create_service("mirror", "v1", creds)
            batch.add(mirror_service.timeline().insert(body=body), request_id=user.key().name())

        batch.execute(httplib2.Http())
        return "Successfully sent cards to %d users (%d failed)." % (batch_responses.success, batch_responses.failure)
开发者ID:jnegre,项目名称:ingress-for-glass,代码行数:21,代码来源:main_handler.py

示例5: sendMessage

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
def sendMessage(html):
    REPLY_HTML = getReply(html)
    body = {
            'html': REPLY_HTML,
            'notification': {'level': 'DEFAULT'}
        }

    users = Credentials.all()
    batch_responses = _BatchCallback()
    batch = BatchHttpRequest(callback=batch_responses.callback)
    for user in users:
      creds = StorageByKeyName(
          Credentials, user.key().name(), 'credentials').get()
      mirror_service = util.create_service('mirror', 'v1', creds)
      batch.add(
          mirror_service.timeline().insert(body=body),
          request_id=user.key().name())

    batch.execute(httplib2.Http())
    return 'Successfully sent cards to %d users (%d failed).' % (
        batch_responses.success, batch_responses.failure)
开发者ID:mookiejones,项目名称:Our_Sailing_Family,代码行数:23,代码来源:handler.py

示例6: _insert_playcard_all_users

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
    def _insert_playcard_all_users(self):
        """Insert a paginated timeline item."""
        logging.info("Inserting paginated timeline item")
        users = Credentials.all()
        total_users = users.count()

        playImg = self.request.get("play-img")
        playTitle = self.request.get("play-title")
        playDescription = self.request.get("play-desc")

        PLAYCARD_HTML = (
            """
    <article class='photo' style='left:0px;visibility:visible'>
    <img src='"""
            + playImg
            + """' width='100%' height='100%'>
    <section><p class='text-normal' style='text-align:right'>"""
            + playTitle
            + """</p></section></article>
    """
        )

        body = {
            "html": PLAYCARD_HTML,
            "notification": {"level": "DEFAULT"},
            "text": playDescription,
            "menuItems": [{"action": "READ_ALOUD"}],
        }
        batch_responses = _BatchCallback()
        batch = BatchHttpRequest(callback=batch_responses.callback)
        for user in users:
            creds = StorageByKeyName(Credentials, user.key().name(), "credentials").get()
            mirror_service = util.create_service("mirror", "v1", creds)
            batch.add(mirror_service.timeline().insert(body=body), request_id=user.key().name())

        batch.execute(httplib2.Http())
        return "Successfully sent playcards to %d players (%d failed)" % (
            batch_responses.success,
            batch_responses.failure,
        )
开发者ID:pdugan20,项目名称:husky-glass,代码行数:42,代码来源:main_handler.py

示例7: _insert_item_all_users

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import all [as 别名]
  def _insert_item_all_users(self):
    """Insert a timeline item to all authorized users."""
    logging.info('Inserting timeline item to all users')
    users = Credentials.all()
    total_users = users.count()

    if total_users > 10:
      return 'Total user count is %d. Aborting broadcast to save your quota' % (
          total_users)
    body = {
        'text': 'Hello Everyone!',
        'notification': {'level': 'DEFAULT'}
    }
    for user in users:
      creds = StorageByKeyName(
          Credentials, user.key().name(), 'credentials').get()
      mirror_service = util.create_service('mirror', 'v1', creds)
      try:
        mirror_service.timeline().insert(body=body).execute()
      except errors.HttpError, error:
        logging.error(
            'Unable to send item to user %s: %s', user.key().name(), error)
开发者ID:CoolCloud,项目名称:mirror-quickstart-python,代码行数:24,代码来源:main_handler.py


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