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