本文整理汇总了Python中utils.logger.Logger.error_context方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error_context方法的具体用法?Python Logger.error_context怎么用?Python Logger.error_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.logger.Logger
的用法示例。
在下文中一共展示了Logger.error_context方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge_floors
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import error_context [as 别名]
def merge_floors(klass, edilizia, easyroom, dxf):
"""
Merge floors information from the three supplied sources.
Merging happens giving priority for dxf, edilizia and lastly easyroom.
Arguments:
- edilizia: a dictionary representing a building information from edilizia;
- easyroom: a dictionary representing a building information from easyroom;
- dxf: a dictionary representing a building information from dxf.
Return Value:
- a new list of floors containing the merge of all sources of information.
"""
floors = [
("dxf", dxf and dxf["floors"]),
("edilizia", edilizia and edilizia.get("floors")),
("easyroom", easyroom and easyroom.get("floors"))
]
floors = [ f for f in floors if f[1] ]
while len(floors) >= 2:
source1, floor1 = floors[0]
source2, floor2 = floors[1]
with Logger.error_context("Merging floors from {} <- {}".format(source1, source2)):
result = klass._match_and_merge_floors(floor1, floor2)
floors[0:2] = [ (source1+"/"+source2, result) ]
return floors and floors[0][1] or []
示例2: replace_building_rooms
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import error_context [as 别名]
def replace_building_rooms(self, building, rooms):
"""
Replace the current building floors/rooms with those rooms (and
consequently floors) contained in rooms.
Arguments
- building: a Building object to be updated
- rooms : a list of dictionaries, each one representing a room. The format
is the same of the rooms supplied to RoomDataUpdater.update_rooms.
Return Value
- None, changes are performed directly on the building object.
"""
with Logger.info("Processing", str(building)):
namespaced_attr = building.attributes_for_source(self.get_namespace())
namespaced_attr["floors"] = []
# salviamo le date di aggiornamento
building["updated_at"] = self.batch_date
namespaced_attr["updated_at"] = self.batch_date
# cicliamo su un floor alla volta
for (f_id, floor_rooms) in groupby(rooms, key = lambda s:s["l_floor"]):
# Controlliamo di avere almeno un floor id valido
f_id = self.sanitize_and_validate_floor(f_id, floor_rooms)
if not f_id:
continue
# possiamo fare a meno di questo error_context, facendo si che
# la prepare_rooms, in seguito a un errore, stampi anche
# il floor id?
with Logger.error_context("Processing floor {}".format(f_id)):
namespaced_attr["floors"].append( {
"f_id" : f_id,
"rooms" : self.prepare_rooms(f_id, floor_rooms)
} )