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


Python Event.select方法代码示例

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


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

示例1: query_fulltext_code

# 需要导入模块: from model.event import Event [as 别名]
# 或者: from model.event.Event import select [as 别名]
def query_fulltext_code(code):
    pinyin = Pinyin()
    initials = []
    for letter in pinyin.get_initials(code, splitter=' ').lower().split(' '):
        if letter.isalpha():
            initials.append(letter * 4)
    logging.debug(initials)
    analysed_code = pinyin.get_pinyin(code, splitter=u' ') + ' ' + ' '.join(initials)
    logging.debug(analysed_code)
    clause = "MATCH(`codepinyin`, `codepinyininitials`) AGAINST (%s)"
    query = yield dbutil.do(Event.select(SQL('*, ' + clause + ' AS similarity', analysed_code)).where(
        SQL(clause, analysed_code)).limit(4).dicts)
    events = [event for event in query]
    logging.debug(events)
    return events
开发者ID:zy4290,项目名称:qilaihi.club,代码行数:17,代码来源:event.py

示例2: post

# 需要导入模块: from model.event import Event [as 别名]
# 或者: from model.event.Event import select [as 别名]
 def post(self):
     try:
         data = json.loads(self.request.body.decode())
         logging.debug(data)
         # 默认查询第一页
         page_number = data.get('page_number', 1)
         # 默认每页显示4条数据
         items_per_page = data.get('items_per_page', 4)
         query = yield dbutil.do(
             Event.select().order_by(-Event.createtime).paginate(
                 page_number, items_per_page).dicts)
         result = [event for event in query]
         self.write(Response(status=1, msg='ok', result=result).json())
     except Exception as e:
         self.write(Response(msg='sorry,亲,活动查询失败').json())
         logging.exception('CreateEventHandler error: {0}'.format(str(e)))
开发者ID:zy4290,项目名称:qilaihi.club,代码行数:18,代码来源:eventservice.py

示例3: sync_media_file

# 需要导入模块: from model.event import Event [as 别名]
# 或者: from model.event.Event import select [as 别名]
def sync_media_file():
    while True:
        cur_hour = int(time.strftime('%H'))
        if cur_hour >= syncconfig.start_at and cur_hour < syncconfig.stop_at:
            try:
                event = yield dbutil.do(Event.select().where(
                    (Event.syncfinish != 1) | (Event.syncfinish >> None)).order_by(+Event.createtime).get)
                logging.info('开始处理活动[#{0}] 的media文件'.format(event.code))
                if event.mediaids:
                    all = json.loads(event.mediaids)
                    logging.debug('all ' + str(all))
                    if event.syncstatus:
                        uploaded = json.loads(event.syncstatus)
                    else:
                        uploaded = []
                    if event.imgurls:
                        img_urls = json.loads(event.imgurls)
                    else:
                        img_urls = {}
                    to_upload = list(set(all) - set(uploaded))
                    logging.info('待处理media文件清单' + str(to_upload))
                    results = yield [wxutil.process_temp_resource(media_id) for media_id in to_upload]
                    for i in range(0, len(results)):
                        if results[i] is not None:
                            uploaded.append(to_upload[i])
                            img_urls[to_upload[i]] = results[i]
                    event.syncstatus = json.dumps(uploaded, ensure_ascii=False)
                    event.imgurls = json.dumps(img_urls, ensure_ascii=False)
                    logging.info('已完成media文件清单:' + str(uploaded))
                    if set(all) == set(uploaded):
                        logging.info('活动[#{0}] 所有media文件已完成'.format(event.code))
                else:
                    logging.info('mediaids不存在,没有media文件需要同步')
                event.syncfinish = 1
                yield dbutil.do(event.save)
            except DoesNotExist:
                logging.info('无待同步media文件, sleep...')
                yield gen.sleep(60 * 10)
            except Exception as e:
                logging.exception('同步media文件发生异常:{0}, 退出...'.format(str(e)))
                break
        else:
            yield gen.sleep(60 * 10)
开发者ID:zy4290,项目名称:qilaihi.club,代码行数:45,代码来源:sync_media_file.py


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