當前位置: 首頁>>代碼示例>>Python>>正文


Python log.Log類代碼示例

本文整理匯總了Python中tools.log.Log的典型用法代碼示例。如果您正苦於以下問題:Python Log類的具體用法?Python Log怎麽用?Python Log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Log類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: put

    def put(self):
        req = ObjectDict(json_decode(self.request.body))
        Log.info("Polymer>>Hotel>>Online>> user:{} req:{}".format(self.current_user, req))
        hotel_mapping_id = req.hotel_mapping_id
        is_online = req.is_online


        hotel_mapping = HotelMapping.get_by_id(self.db, hotel_mapping_id)
        if hotel_mapping and hotel_mapping.status == hotel_mapping.STATUS.valid_complete:
            hotel_mapping = HotelMapping.set_online(self.db, hotel_mapping_id, is_online)
            if hotel_mapping.is_online in [0, -1]:
                RoomTypeMapping.disable_by_provider_hotel_id(self.db, hotel_mapping.provider_hotel_id)

            try:
                redisClient.put('poi_online',hotel_mapping.main_hotel_id)
            except Exception,e:
                traceback.print_exc()
            yield self.notify_stock(hotel_mapping.provider_id, hotel_mapping.provider_hotel_id)
            try:
                module = modules['merge']
                motivation = None
                if is_online in [0, -1]:
                    motivation = motivations['offline_hotel']
                else:
                    motivation = motivations['online_hotel']
                operator = self.current_user
                poi_hotel_id = hotel_mapping.main_hotel_id
                otaId = hotel_mapping.provider_id
                hotelName = hotel_mapping.provider_hotel_name
                hotelModel = Hotel.get_by_id(self.db,id=poi_hotel_id)
                operate_content = hotelName + "<->" + hotelModel.name
                hotel_id = hotel_mapping_id
                PoiOperateLogMapping.record_log(self.db,otaId=otaId,hotelName=hotelName,module=module,motivation=motivation,operator=operator,poi_hotel_id=poi_hotel_id,operate_content=operate_content,hotel_id=hotel_id)
            except Exception,e:
                traceback.print_exc()
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:35,代碼來源:polymer.py

示例2: delete

    def delete(self, roomtype_mapping_id):
        Log.info("Second>>RoomType {}>>Delete>> user:{}".format(roomtype_mapping_id, self.current_user))
        mapping = RoomTypeMapping.get_by_id(self.db, roomtype_mapping_id)
        if mapping and mapping.status == mapping.STATUS.wait_second_valid:
            mapping = RoomTypeMapping.revert_to_firstvalid(self.db, roomtype_mapping_id)

            try:
                module = modules['second_valid']
                motivation = motivations['back_roomtype']
                operator = self.current_user
                poi_hotel_id = mapping.main_hotel_id
                poi_roomtype_id = mapping.main_roomtype_id
                otaId = mapping.provider_id
                hotel_id = mapping.provider_hotel_id
                hotelModel = HotelMapping.get_by_provider_and_main_hotel(self.db,otaId,hotel_id,poi_hotel_id)
                hotelName = hotelModel.provider_hotel_name
                roomType = RoomType.get_by_id(self.db,id=poi_roomtype_id)
                operate_content = mapping.provider_roomtype_name + " <-> " + roomType.name

                PoiOperateLogMapping.record_log(self.db,otaId=otaId,hotelName=hotelName,module=module,motivation=motivation,operator=operator,
                                                poi_hotel_id=poi_hotel_id,operate_content=operate_content,hotel_id=hotel_id,poi_roomtype_id=poi_roomtype_id)
            except Exception,e:
                traceback.print_exc()

            self.finish_json(result=ObjectDict(
                roomtype_mapping=mapping.todict(),
                ))
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:27,代碼來源:secondvalid.py

示例3: pre_check_order

    def pre_check_order(self, order_entity):

        order = self.create_order(order_entity)
        if not order:
            raise JsonException(1, 'create order fail')

        if order.status != 0:
            return order

        # valid is roomtype online
        roomtype = CooperateRoomTypeModel.get_by_id(self.db, order.roomtype_id)
        if roomtype.is_online != 1:
            Log.info('roomtype is not online')
            order.status = 200
            order.exception_info = 'roomtype is not online'
            self.db.commit()
            OrderHistoryModel.set_order_status_by_server(self.db, order, 0, 200)
            return order

        # valid is inventory enough
        if not self.valid_inventory(order_entity):
            Log.info('more room please')
            order.status = 200
            order.exception_info = 'inventory not enough'
            self.db.commit()

            OrderHistoryModel.set_order_status_by_server(self.db, order, 0, 200)
            return order

        return order
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:30,代碼來源:submit_order.py

示例4: send_order_sms

def send_order_sms(self, merchant_id, hotel_name, order_id, confirm_type):
    Log.info(u">>> send sms to merchant {} hotel {} order_id {} confirm type {}".format(merchant_id, hotel_name, order_id, confirm_type))

    order = OrderModel.get_by_id(self.session, order_id)
    breakfast_str = u'含早' if order.get_has_breakfast() else u'無早'
    customers = json.loads(order.customer_info)
    customer_str = " ".join([customer['name'] for customer in customers])


    if confirm_type == OrderModel.CONFIRM_TYPE_AUTO:
        content = u"尊敬的用戶您好,係統收到編號{}自動確認訂單:{},房型:{},入離日期:{}至{}( {}晚 ),入住人:{},總價:{},{}。訂單號:{},請及時關注。客服聯係電話:4006103330".format(merchant_id, hotel_name, order.roomtype_name, order.checkin_date, order.checkout_date, order.get_stay_days(), customer_str, order.total_price / 100, breakfast_str, order_id)
    elif confirm_type == OrderModel.CONFIRM_TYPE_MANUAL:
        content = u"尊敬的用戶您好,係統收到編號{}待確認訂單:{},房型:{},入離日期:{}至{}( {}晚 ),入住人:{},總價:{},{}。訂單號:{},請盡快處理。客服聯係電話:4006103330".format(merchant_id, hotel_name, order.roomtype_name, order.checkin_date, order.checkout_date, order.get_stay_days(), customer_str, order.total_price / 100, breakfast_str, order_id)
    send_sms_to_service(merchant_id, content)

    user =UserModel.get_user_by_merchantid_username(self.session, merchant_id, 'admin')
    if not user:
        Log.info("send sms no user(order {})".format(order_id))
        return
    phone = user.mobile
    if not phone:
        Log.info("send sms no phone(order {})".format(order_id))
        return

    Log.info(">> send sms to {}".format(phone))
    Log.info(u">> sms content: {}".format(content))
    
    send_sms([phone], content)
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:28,代碼來源:sms.py

示例5: generate_html_report

 def generate_html_report(self, report_in_js=True):
     self.generate_report_path()
     reportjs = self.report_path + '/' + 'report.js'
     reporttemplate = self.html_path + '/' + 'report.html'
     reporthtml = self.report_path + '/' + self.dict_all["project"]["name"] + '.html'
     if report_in_js:
         shutil.copy(reporttemplate, reporthtml)
         with open(reportjs, 'w') as f:
             try:
                 d = Log.beautify_json(self.dict_all).encode('utf8').decode('utf8')
                 f.writelines(["report = ", "\n", d, ";", "\n"])
             except UnicodeDecodeError as e:
                 print(e)
     else:
         reporthtml = self.report_path + '/' + self.dict_all["project"]["name"] + '_report.html'
         with open(reporttemplate, 'r') as src, open(reporthtml, 'w') as dst:
             for line in src:
                 if "<script" in line and "src" in line and "report.js" in line:
                     d = Log.beautify_json(self.dict_all)
                     dst.writelines(["<script type='text/javascript' charset='utf-8'>", "\n"])
                     dst.writelines(["var report = ", "\n"])
                     dst.writelines([d.encode("utf8").decode("utf8"), ";", "\n"])
                     dst.writelines(["</script>", "\n"])
                 else:
                     dst.write(line)
     pass
開發者ID:alpha-jacobshih,項目名稱:pyjects,代碼行數:26,代碼來源:efs.py

示例6: put

    def put(self, hotel_mapping_id):
        Log.info("Second>>Hotel {}>>Valid>> user:{}".format(hotel_mapping_id, self.current_user))
        hotel_mapping = HotelMapping.get_by_id(self.db, hotel_mapping_id)
        if hotel_mapping and hotel_mapping.status == hotel_mapping.STATUS.wait_second_valid\
                and hotel_mapping.main_hotel_id != 0:

            hotels = HotelMapping.get_by_chain_id_and_main_hotel_id(self.db, hotel_mapping.provider_id, hotel_mapping.main_hotel_id)
            for hotel in hotels:
                if hotel.id != hotel_mapping.id and hotel.status > hotel_mapping.status:
                    self.finish_json(errcode=402, errmsg=u"已有Hotel{}綁定相同基礎酒店".format(hotel.provider_hotel_name))
                    return

            hotel_mapping = HotelMapping.set_secondvalid_complete(self.db, hotel_mapping_id)

            try:
                module = modules['second_valid']
                motivation = motivations['pass_hotel']
                operator = self.current_user
                poi_hotel_id = hotel_mapping.main_hotel_id
                otaId = hotel_mapping.provider_id
                hotelName = hotel_mapping.provider_hotel_name
                hotelModel = Hotel.get_by_id(self.db,id=poi_hotel_id)
                operate_content = hotelName + "<->" + hotelModel.name
                hotel_id = hotel_mapping_id
                PoiOperateLogMapping.record_log(self.db,otaId=otaId,hotelName=hotelName,module=module,motivation=motivation,operator=operator,poi_hotel_id=poi_hotel_id,operate_content=operate_content,hotel_id=hotel_id)
            except Exception,e:
                traceback.print_exc()

            self.finish_json(result=ObjectDict(
                hotel_mapping=hotel_mapping.todict(),
                ))
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:31,代碼來源:secondvalid.py

示例7: post

    def post(self):
        args = self.get_json_arguments()
        chain_hotel_id, main_hotel_id, merchant_id, merchant_name = get_and_valid_arguments(args,
                'chain_hotel_id', 'main_hotel_id', 'merchant_id', 'merchant_name')
        hotel = HotelModel.get_by_id(self.db, main_hotel_id)

        hotel_mapping = HotelMappingModel.get_by_provider_hotel(self.db, 6, chain_hotel_id,is_delete=-1)
        if hotel_mapping:
            Log.info(">>> modify exist ebooking hotel {}".format(hotel_mapping.todict()))
            hotel_mapping.merchant_id = merchant_id
            hotel_mapping.merchant_name = merchant_name
            hotel_mapping.info = 'update by ebooking'
            hotel_mapping.status = hotel_mapping.STATUS.valid_complete
            hotel_mapping.city_id = hotel.city_id
            hotel_mapping.provider_hotel_name = hotel.name
            hotel_mapping.provider_hotel_address = hotel.address
            hotel_mapping.main_hotel_id = hotel.id
            hotel_mapping.is_delete = 0
            self.db.commit()
        else:
            hotel_mapping = HotelMappingModel.new_hotel_mapping_from_ebooking(self.db,
                    chain_hotel_id, hotel.name, hotel.address, hotel.city_id, main_hotel_id, merchant_id, merchant_name)

        self.finish_json(result=dict(
            hotel_mapping=hotel_mapping.todict(),
            ))
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:26,代碼來源:hotel_mapping.py

示例8: query

    def query(cls, session, name=None, star=None, city_id=None, district_id=None, start=0, limit=10, filter_ids=None, within_ids=None, count_total=True):
        query = session.query(HotelModel)\
                .filter(HotelModel.is_valid == 1)
        if within_ids:
            query = query.filter(HotelModel.id.in_(within_ids))
        if filter_ids:
            query = query.filter(~HotelModel.id.in_(filter_ids))
        if name:
            query = query.filter(HotelModel.name.like(u'%{}%'.format(name)))
        if star:
            query = query.filter(HotelModel.star == star)
        if city_id:
            query = query.filter(HotelModel.city_id == city_id)
        if district_id:
            query = query.filter(HotelModel.district_id == district_id)

        Log.info("=" * 30)
        t0 = time.time()
        r = query.offset(start).limit(limit).all()
        t1 = time.time()
        if count_total:
            total = query.count()
            return r, total
            t2 = time.time()
            Log.info(">>HotelSearch query cost:{} query total cost:{}".format(t1 - t0, t2-t1))
        else:
            return r
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:27,代碼來源:hotel.py

示例9: push_hotel_by_id

 def push_hotel_by_id(self, hotel_id):
     Log.info("<<push hotel by id {}>>".format(hotel_id))
     hotel = CooperateHotelModel.get_by_id(self.db, hotel_id, with_delete=True)
     if not hotel:
         Log.info("<<push hotel {}>> error hotel not exist".format(hotel_id))
         raise gen.Return(False)
     r = yield self.push_hotel(hotel)
     raise gen.Return(r)
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:8,代碼來源:hotel.py

示例10: fetch_base_hotel_and_roomtypes

 def fetch_base_hotel_and_roomtypes(self, hotel_id):
     url = API['POI'] + "/api/hotel/" + str(hotel_id) + "/roomtype/"
     try:
         r = yield AsyncHTTPClient().fetch(url)
         result = json.loads(r.body)
     except Exception, e:
         Log.exception(e)
         raise gen.Return((None, None))
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:8,代碼來源:hotel.py

示例11: _handle_request_exception

 def _handle_request_exception(self, e):
     self.db.rollback()
     if isinstance(e, JsonException):
         Log.error(e.tojson)
         self.finish_json(errcode=e.errcode, errmsg=e.errmsg)
     else:
         Log.error(traceback.format_exc())
         super(BtwBaseHandler, self)._handle_request_exception(e)
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:8,代碼來源:base.py

示例12: push_inventory_by_merchant

    def push_inventory_by_merchant(self, merchant_id):
        Log.info(">> push inventories by merchant {}".format(merchant_id))
        roomtypes = CooperateRoomTypeModel.get_by_merchant_id(self.db, merchant_id)

        for roomtype in roomtypes:
            r = yield self.push_by_roomtype(roomtype)
            if not r:
                raise gen.Return(False)
        raise gen.Return(True)
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:9,代碼來源:inventory.py

示例13: notify_stock

    def notify_stock(self, chain_id, chain_hotel_id):
        if not IS_PUSH_TO_STOCK:
            raise gen.Return()

        url = '{}/stock2/internal/hotel/update_time?chainId={}&chainHotelId={}'.format(API['STOCK'], chain_id, chain_hotel_id)
        time.sleep(2)
        resp = yield AsyncHTTPClient().fetch(url)
        Log.info(resp.body)
        raise gen.Return()
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:9,代碼來源:stockmixin.py

示例14: create_order

    def create_order(self, order_entity):
        order = OrderModel.get_by_main_order_id(self.db, order_entity.id)
        if order:
            # callback 訂單已存在
            Log.info('order exist')
            return order

        order = OrderModel.new_order(self.db, order_entity)
        return order
開發者ID:icyCloud,項目名稱:test_e_b_k,代碼行數:9,代碼來源:submit_order.py

示例15: put

    def put(self):
        req = ObjectDict(json_decode(self.request.body))
        Log.info("RoomTypeMapping>> user:{}, req:{}".format(self.current_user, req))

        r = RoomTypeMappingModel.update_main_hotel_id(self.db, req.id, req.main_roomtype_id)

        self.finish_json(result=ObjectDict(
                roomtype_mapping=r.todict(),
            ))
開發者ID:icyCloud,項目名稱:test_p_o_i,代碼行數:9,代碼來源:room_type_mapping.py


注:本文中的tools.log.Log類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。