當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。