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


Python Channel.get方法代码示例

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


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

示例1: updateInfo

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import get [as 别名]
def updateInfo(key, gogo_id):
    channel = Channel.get(key)
    programs = list(Program.gql("WHERE channel = :channel", channel = channel))
    for p in programs:
        p.delete()
    for day in range(1,8): #iterate week
        logging.info('updating info of ' + channel.name)
        try:
            updatePrograms(channel, day, gogo_id)
        except Exception, e:
            logging.error('error happened, while updating: ' + e.message)
开发者ID:aadaa88,项目名称:tv-feeder,代码行数:13,代码来源:crawler.py

示例2: add_bot

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import get [as 别名]
 def add_bot(self, channel, name):
     channel = channel.lower()
     name = name.lower()
     try:
         Bot.get(Bot.name == name)
     except peewee.DoesNotExist:
         pass  # this seems really unpythonic somehow
     else:
         raise KeyError('Bot already exists')
     try:
         chan_o = Channel.get(Channel.name == channel)
     except peewee.DoesNotExist:
         chan_o = Channel.create(name=channel)
     Bot.create(name=name,
                channel=chan_o)
开发者ID:Bevinsky,项目名称:packlist-assembler,代码行数:17,代码来源:assembler.py

示例3: _initialize_channels_and_users

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import get [as 别名]
 def _initialize_channels_and_users(self):
   self.info('Loading channels and users...')
   channel_id_to_name_map, channel_name_to_id_map = \
       self.slack.channel_id_name_maps()
   with self.database_manager.transaction():
     for k, v in channel_id_to_name_map.items():
       is_direct = True if k.startswith('D0') else False
       try:
         channel = Channel.get(
             Channel.slack_id == k
         )
         channel.slack_name = v
         channel.is_direct = is_direct
         channel.save()
       except Channel.DoesNotExist:
         channel = Channel.create(
             slack_name=v,
             slack_id=k,
             is_direct=is_direct
         )
       except Exception as e:
         self.error(e)
       channel_members = self.slack.channel_members(channel.slack_name)
       for channel_member in channel_members:
         is_slackbot = True if channel_member[1] == 'USLACKBOT' else False
         try:
           user = User.get(
               User.slack_name == channel_member[1],
               User.slack_id == channel_member[0],
               User.is_slackbot == is_slackbot
           )
         except User.DoesNotExist:
           user = User.create(
               slack_name=channel_member[1],
               slack_id=channel_member[0],
               is_slackbot=is_slackbot
           )
         except Exception as e:
           self.error(e)
         try:
           ChannelUserRelationship.create(
               channel=channel,
               user=user
           )
         except:
           pass
开发者ID:gabeos,项目名称:slackotron,代码行数:48,代码来源:slackotron.py

示例4: _process_rmq_message

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import get [as 别名]
 def _process_rmq_message(self, rmq_message):
   try:
     rmq_message = json.loads(rmq_message)
     channel = Channel.get(
         Channel.id == rmq_message['channel_id']
     )
     user = User.get(
         User.id == rmq_message['user_id']
     )
     message = Message.get(
         Message.id == rmq_message['message_id']
     )
     plugin_name = rmq_message['plugin_name']
     plugin_response = rmq_message['plugin_response']
     return channel, user, message, plugin_name, plugin_response
   except Exception as e:
     self.error(e)
     return None, None, None, None, None
开发者ID:gabeos,项目名称:slackotron,代码行数:20,代码来源:slackotron.py

示例5: get

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import get [as 别名]
 def get(self, server, channel):
     key = db.Key.from_path(Channel.kind(), '%s/%s' % (unquote(channel), server))
     channel = Channel.get(key)
     date = self.request.GET.get('date')
     if date:
         start_date = datetime.strptime(date, '%Y-%m-%d').date()
     else:
         start_date = datetime.utcnow().date()
     end_date = start_date + timedelta(days=1)
     messages = Message.all().filter('channel =', channel) \
                 .filter('timestamp >= ', start_date) \
                 .filter('timestamp < ', end_date) \
                 .order('timestamp')
     # date based pagination
     next_day = start_date + timedelta(days=1)
     if next_day > datetime.utcnow().date():
         next_day = None
     previous_day = end_date - timedelta(days=2)
     self.response.out.write(render('templates/channel.html', locals()))
     
开发者ID:sanyaade,项目名称:ircarchive,代码行数:21,代码来源:archive.py


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