本文整理汇总了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()
示例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(),
))
示例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
示例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)
示例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
示例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(),
))
示例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(),
))
示例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
示例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)
示例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))
示例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)
示例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)
示例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()
示例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
示例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(),
))