本文整理汇总了Python中utils.logger.Logger.warning方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.warning方法的具体用法?Python Logger.warning怎么用?Python Logger.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.logger.Logger
的用法示例。
在下文中一共展示了Logger.warning方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_rooms
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def prepare_rooms(self, floor_id, rooms):
"""
Transform a list of rooms in a dictionary indexed by room id.
Arguments:
- floor_id: a string representing the floor identifier,
- rooms: a list of rooms.
Returns: a dictionary of rooms.
Validate the r_id using Building.is_valid_rid function and discard rooms
with invalid id. Create and return a dictionary of validated rooms.
"""
result = {}
discarded_rooms = set()
for r in map(self.sanitize_room, rooms):
if not Building.is_valid_rid(r["r_id"]):
discarded_rooms.add(r["r_id"])
continue
if "cat_id" in r:
r["cat_id"] = RoomCategory.get_cat_id_by_name(r.get("cat_name", ""))
del r["cat_name"]
r_id = r["r_id"]
del r["r_id"]
result[r_id] = r
if discarded_rooms:
Logger.warning(
"Rooms discarded from floor", floor_id,
"for having an invalid room id:",
", ".join(discarded_rooms)
)
return result
示例2: _validate_building_data
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _validate_building_data(self, b_dict):
"""
Ensure a dictionary containing building information is actually valid
for updating purposes. The main goal is to validate the presence and
format of b_id and/or l_b_id.
If no b_id is present but a l_b_id is valid, it is set as current b_id,
which ensures the building does not get discarded.
Arguments:
- b_dict: a dictionary representing a building
Return value: True if data is valid, False otherwise
"""
b_id = b_dict.get("b_id", "")
l_b_id = b_dict.get("l_b_id", "")
if not Building.is_valid_bid(b_id):
if Building.is_valid_bid(l_b_id):
Logger.warning(
"Invalid building id: \"{}\"".format(b_id),
"- legacy id", l_b_id, "will be used instead."
)
b_dict["b_id"] = l_b_id
else:
Logger.error(
"Building discarded:",
"Invalid building id", b_id,
"and no valid legacy id is present"
)
return False
return True
示例3: _print_merge_analysis
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _print_merge_analysis(klass, source, target, building):
method_name = "analyse_"+source+"_to_"+target
merge_info = getattr(FloorMergeAnalysis, method_name)(building)
if not building.get_path(source+".floors"):
return
if not building.get_path(target+".floors"):
return
with Logger.info("{} -> {} Merge Analysis".format(source.upper(), target.upper())):
for f_id, count, which in merge_info:
total_rooms = count["total_rooms"]
identified_rooms = data_and_percent(count["identified_rooms"], total_rooms)
non_identified_rooms = data_and_percent(count["non_identified_rooms"], total_rooms)
message = "Floor {:5} | ".format(f_id)
message += "Rooms: {:<4} | ".format(total_rooms)
message += "With Id.: {:<12} | ".format(identified_rooms)
message += "No Id: {:<12}".format(non_identified_rooms)
with Logger.info(message):
if count["non_identified_rooms"]:
Logger.warning(
source,
"knows about room(s)",
", ".join(which["non_identified_rooms"]),
"but", target, "does not"
)
示例4: _match_and_merge_floors
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _match_and_merge_floors(klass, base_floors, unmatched_floors):
"""
Given a list of base floors, and a list of unmatched floors,
analyze each unmatched floor trying to associate its rooms
to base floors rooms.
TODO: decide what to do in the end if there are still unmatched floors
with rooms
Arguments:
- base_floors: a list of dictionaries representing floors
- unmatched_floors: a list of dictionaries representing floors
which will be merged onto base_floors.
Return value: a new list of new floors, representing the result
of the merge operation.
"""
# Ensure we work on a COPY of base floors.
base_floors = [ klass._floor_copy(f) for f in base_floors ]
for floor in chain(base_floors, unmatched_floors):
floor["room_ids"] = set(floor["rooms"].keys())
for unmatched in unmatched_floors:
mapping = klass._match_and_merge_a_floor(base_floors, unmatched)
if unmatched["room_ids"]:
with Logger.warning(
"Some rooms were not directly mapped between two floors:",
", ".join(unmatched["room_ids"])
):
if mapping:
rooms, base = mapping[0]
klass._merge_rooms_into_floor(base, unmatched, unmatched["room_ids"])
Logger.warning(
"Conflict solved, rooms merged into floor",
base["f_id"],
"together with",
", ".join(rooms)
)
else:
Logger.error("Cannot resolve, no mapping is possible for those rooms.")
for floor in chain(base_floors, unmatched_floors):
del floor["room_ids"]
#e adesso? esistono ancora unmatched floors con stanze?
return base_floors
示例5: _sanitize_building
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _sanitize_building(self, building):
"""
Sanitize a building address, obtaining uniform address information if
possible. If no recognizable address is present, a warning is issued.
Only the "edilizia" namespace is considered
Arguments:
- building: a Building object to sanitize
Returs None
"""
address = building.get_path("edilizia.address", "")
# Extract and remove building number (not street number)
r_building_number = re.compile("(.+)(_ed|ed[^a-z0-9])\s*(\d+)(.*)", flags=re.I)
building_result = re.match(r_building_number, address)
if building_result:
building["edilizia"]["building_number"] = building_result.group(3)
address = building_result.group(1)+building_result.group(4)
# Now extract an address in a format like "Milano - Via Celoria 27"
address_regex = [
"(([a-z]+\s*)+)-\s*", # città
"(via|viale|piazza|v.le|p.zza)\s+", # tipo di via
"(([a-z]+\.?\s*)+),?\s*", # nome della via
"(\d*)" # numero civico
]
r_address = re.compile("".join(address_regex), flags=re.I)
address_result = re.match(r_address, address)
if address_result:
city_name = address_result.group(1).strip()
street_type = address_result.group(3).strip()
street_name = address_result.group(4).strip()
civic_number = address_result.group(6).strip()
final_address = street_type+" "+street_name
if civic_number:
final_address += ", "+civic_number
final_address += ", "+city_name
else:
Logger.warning(
"Discarded invalid address, try using a standard address format:",
building["edilizia"]["address"]
)
final_address = ""
building["edilizia"]["address"] = final_address
示例6: _extract_entities
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _extract_entities(self):
self._rooms = []
self._texts = []
self._wall_lines = []
self._window_lines = []
for ent in self._grabber.entities:
if self._is_valid_room(ent):
points = [(p[0], -p[1]) for p in ent.points]
polygon = Polygon.from_absolute_coordinates(points)
polygon.ensure_is_closed(tollerance = 0.8)
polygon.simplify_close_points(tollerance = 0.8)
if polygon.is_self_crossing():
Logger.warning("Self crossing room is not valid: "+str(polygon))
continue
self._rooms.append(
Room(
polygon
)
)
elif self._is_valid_text(ent):
self._texts.append(
Text(
ent.plain_text().strip(), Point(ent.insert[0], -ent.insert[1])
)
)
elif self._is_valid_wall_line(ent):
start = Point(ent.start[0], -ent.start[1])
end = Point(ent.end[0], -ent.end[1])
line = Segment(start, end)
self._wall_lines.append( line )
elif self._is_valid_wall_polyline(ent):
points = [(p[0], -p[1]) for p in ent.points]
polygon = Polygon.from_relative_coordinates((0,0), points)
polygon.ensure_is_closed(tollerance = 1)
polygon.simplify_close_points(tollerance = 1)
self._wall_lines.extend( polygon.as_segment_list() )
elif self._is_valid_window_line(ent):
start = Point(ent.start[0], -ent.start[1])
end = Point(ent.end[0], -ent.end[1])
line = Segment(start, end)
self._window_lines.append( line )
示例7: _merge_building_coordinates
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def _merge_building_coordinates(self, edilizia=None, easyroom=None):
"""Coordinates merge strategy: return lat and lng if are present and valid
in the edilizia data, otherwhise make a reverse geocoding request"""
if self.coordinates_are_valid(edilizia) :
lat = round(float(edilizia["lat"]), 6)
lng = round(float(edilizia["lon"]), 6)
return { "lat" : lat, "lng" : lng }
elif easyroom and not self.skip_geocoding:
address = easyroom.get("address", None) or edilizia.get("address", None)
try :
(lat,lng) = (Geocoder.geocode(address)).coordinates
lat = round(lat,6)
lng = round(lng,6)
return { "lat" : lat, "lng" : lng }
except GeocoderError:
Logger.warning("Coordinates parsing error")
return { "lat" : None , "lng" : None }
示例8: get_identifier
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def get_identifier(self, filename, grabber):
"""
Given two potential floor identifiers and choose the best one.
Arguments:
- filename: name of the dxf floor file;
- grabber: dxfgrabber istance result of the dxf parsing.
Returns:
- a string representing the best id fouded for the floor;
- False in case of conflict.
Take an id from the filename and a group of ids from the "cartiglio"
layers. Returns the best id and in case of conflicts prints messages with
the logger.
"""
filename_id = self.from_filename(filename)
possible_ids = self.from_cartiglio(grabber)
if(len(possible_ids) > 1):
with Logger.warning(
"Multiple floor identifiers inferred from layer \"CARTIGLIO\" (",
str(", ".join(s for s in possible_ids)),
"):"
):
if(filename_id in possible_ids):
Logger.warning(
"[SOLVED] One of them equals the id obtained from the filename: "+filename_id
)
return filename_id
else:
Logger.warning(
"[UNDECIDABLE] Multiple cartiglios in file?"
)
return False
cartiglio_id = len(possible_ids) and possible_ids.pop()
if filename_id and cartiglio_id and (filename_id != cartiglio_id):
with Logger.warning(
"The floor identification issues a conflict:", filename_id,
"from filename suffix but", cartiglio_id,
"from layer \"CARTIGLIO\""
):
Logger.warning("[SOLVED]", cartiglio_id, "will be used")
return cartiglio_id or filename_id
示例9: draw_floor
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def draw_floor(klass, floor):
"""
Create and save a map (in svg format) representing a floor.
Arguments:
- floor: a dictionary representing a merged floor.
Returns: None
"""
klass.max_x = 0
klass.max_y = 0
klass.svg = svgwrite.Drawing()
klass._add_style_to_svg()
window_lines = floor.get("windows", [])
windows_group = klass._create_lines_group(window_lines, group_id="windows")
wall_lines = floor.get("walls", [])
walls_group = klass._create_lines_group(wall_lines, group_id="walls")
rooms_group = klass._create_rooms_group(floor)
rooms_labels_g = klass._create_rooms_labels_group(floor)
legend = klass._create_legend_group(floor)
klass.svg.add(windows_group)
klass.svg.add(rooms_group)
klass.svg.add(walls_group)
klass.svg.add(rooms_labels_g)
#klass.svg.add(legend)
if len(klass.svg.elements) <= 1:
Logger.warning("Impossible generate csv: no room polylines founded")
# set viewBox for a correct rendering
klass.svg.viewbox(0,0,klass.max_x,klass.max_y)
return klass.svg
示例10: sanitize_and_validate_floor
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
def sanitize_and_validate_floor(self, floor_id, floor_rooms):
"""
Intended to clean up and validating floor_ids before insertion on database.
It must also Log in case the floor is invalid.
Arguments:
- floor_id: the original floor_id string to be sanitized.
- floor_rooms: a list of dictionaries representing the floor rooms.
Returns a string representing the sanitized version of the floor_id.
It is a good practice for subclasses to call this parent superclass.
"""
valid = Building.is_valid_fid(floor_id)
if not valid:
rooms = [ r["r_id"] for r in floor_rooms ]
Logger.warning(
"Empty floor id in building.",
len(rooms), "rooms discarded:",
", ".join(rooms)
)
return valid
示例11: RRMayaJob
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import warning [as 别名]
class RRMayaJob(object):
"""
This class contains set of parameters describing a RoyalRender job
and function that set/get or do operation on this parameters.
"""
def __init__(self, args_string):
self.arg = ArgumentParser("RRMaya", args_string)
self.log = Logger()
self.workspace = self.arg.get("Database")
self.image_dir = self.arg.get("FDir")
self.python_path = self.arg.get("PyModPath")
self.maya_scene = self.arg.get("SName")
self.override_render_cmd = self.arg.get("OverwriteRenderCmd")
self.kso_mode = self.arg.get("KSOMode")
self.file_name = self.arg.get("FName")
self.file_ext = self.arg.get("FExt")
self.file_name_no_var = self.arg.get("FNameNoVar")
self.file_dir = self.arg.get("FDir")
self.single_output = self.arg.get("FSingleOutput")
self.frame_padding = self.arg.default("FPadding", 4)
self.frame_start = self.arg.get("FrStart")
self.frame_end = self.arg.get("FrEnd")
self.frame_step = self.arg.get("FrStep")
self.frame_offset = self.arg.get("FrOffset")
self.camera = self.arg.get("Camera")
self.layer_name = self.arg.get("Layer")
self.threads = self.arg.get("Threads")
self.resx = self.arg.get("ResX")
self.resy = self.arg.get("ResY")
self.image_format = self.arg.get("FOverrideFormat")
self.threads = self.arg.get("Threads")
self.edge_aa = self.arg.get("AA1")
self.samples = self.arg.get("AA2")
self.max_samples = self.arg.get("AA3")
self.treshold = self.arg.get("AA4")
self.rx1 = self.arg.get("RegionX1")
self.rx2 = self.arg.get("RegionX2")
self.ry1 = self.arg.get("RegionY1")
self.ry2 = self.arg.get("RegionY2")
self.motion_blur = self.arg.get("RenderMotionBlur")
self.render_demo = self.arg.get("RenderDemo")
self.render_displace = self.arg.get("RenderDisplace")
self.ext_override = self.arg.get("FExtOverride")
self.verbose = self.arg.get("Verbose")
self.kso_mode = self.arg.get("KSOMode")
@property
def render_name(self):
"""
returns: Name of the current renderer provided
by rrSubmiter or specified in Maya settings.
"""
render_globals = pm.PyNode("defaultRenderGlobals")
render_name = self.arg.get("Renderer")
if render_name is None:
return render_globals.getAttr("currentRenderer")
else:
return render_name
@property
def render_layer(self):
"""
Setup the Maya renderer to render only the specified layers.
In case when arg layer is None will set masterLayer as rendarable.
param layer: Layer name string.
"""
user_layer = self.arg.get("Layer")
lm = pm.PyNode("renderLayerManager")
render_layers = lm.listConnections()
rendarable_layer = None
for l in render_layers:
if l.name() == user_layer:
l.setAttr("renderable", True)
rendarable_layer = l.name()
else:
l.setAttr("renderable", False)
if rendarable_layer is None:
# This is the case when render specified by user does not exist or None.
default_layer = pm.nodetypes.RenderLayer(u"defaultRenderLayer")
default_layer.setAttr("renderable", True)
self.log.warning(
"Failed to set layer %s as renderable. "
"Does not exists. Set to %s." % (user_layer, default_layer.name())
)
rendarable_layer = default_layer.name()
self.log.info("Current render layer: %s" % rendarable_layer)
return rendarable_layer