本文整理汇总了Python中utils.logger.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.logger.Logger
的用法示例。
在下文中一共展示了Logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_room_categories
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def resolve_room_categories(klass, building, floor_dict=None):
"""
Given a building, perform the mapping between it's dxf rooms and their
relative categories.
It does not save the building, which is responsibility of the caller.
Arguments:
- building: a Building object whose dxf rooms we want to process.
- floor_dict: an (optional) dxf floor to limit the rooms to process. If
None, all the current building floors will be used instead.
Returns value: an integer representing the amount of rooms matched. The
category name saved in place in each room dictionary, under the
key "cat_name"
"""
categorized_rooms = 0
target_floors = floor_dict and [floor_dict] or building.get("dxf") and building.get("dxf")["floors"] or []
cats = klass.get_room_categories_dict()
for floor_dict in target_floors:
categorized_rooms += klass._resolve_room_categories_for_floor(floor_dict, cats)
if categorized_rooms:
Logger.info(categorized_rooms, "rooms were categorized")
return categorized_rooms
示例2: RRApp
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
class RRApp(object):
"""
Abstract base class for all rr job renderer aplications.
"""
def __init__(self):
self.log = Logger(debug=True)
def version(self):
raise NotImplementedError()
def open_scene(self):
raise NotImplementedError()
def set_env(self, name, value):
if value is not None:
os.environ[name] = value
self.log.info('Environmental variable "%s" set to "%s"' % (name, value))
else:
self.log.info('Can not set environment "%s" to "%s"' % (name, value))
def start_kso_server(self):
"""
This function perform Keep Scene Open RR functionality.
Start TCP server and listen for commands from client.
"""
KSO_HOST = "localhost"
KSO_PORT = 7774
server = rrKSOServer((KSO_HOST, KSO_PORT), rrKSOTCPHandler)
server.handle_command()
def start_render(self):
raise NotImplementedError()
示例3: __val
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def __val(self):
"""
Validation function during the train phase.
"""
self.seg_net.eval()
start_time = time.time()
for j, data_tuple in enumerate(self.val_loader):
# Change the data type.
inputs = Variable(data_tuple[0].cuda(async=True), volatile=True)
targets = Variable(data_tuple[1].cuda(async=True), volatile=True)
# Forward pass.
outputs = self.seg_net(inputs)
# Compute the loss of the val batch.
loss_pixel = self.pixel_loss(outputs, targets)
loss = loss_pixel
self.val_losses.update(loss.data[0], inputs.size(0))
# Update the vars of the val phase.
self.batch_time.update(time.time() - start_time)
start_time = time.time()
self.module_utilizer.save_net(self.seg_net, self.iters)
# Print the log info & reset the states.
Log.info(
'Test Time {batch_time.sum:.3f}s, ({batch_time.avg:.3f})\t'
'Loss {loss.avg:.8f}\n'.format(
batch_time=self.batch_time, loss=self.val_losses))
self.batch_time.reset()
self.val_losses.reset()
self.seg_net.train()
示例4: _print_merge_analysis
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [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"
)
示例5: UtLogger
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
class UtLogger(unittest.TestCase):
def setUp(self):
self.logger = Logger().getLogger("test.utils.UtLogger")
def testLogger(self):
self.logger.debug("1")
self.logger.info("2")
self.logger.warn("3")
self.logger.error("4")
self.logger.critical("5")
示例6: __train
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def __train(self):
"""
Train function of every epoch during train phase.
"""
self.seg_net.train()
start_time = time.time()
# data_tuple: (inputs, heatmap, maskmap, tagmap, num_objects)
for i, data_tuple in enumerate(self.train_loader):
self.data_time.update(time.time() - start_time)
# Change the data type.
if len(data_tuple) < 2:
Log.error('Train Loader Error!')
exit(0)
inputs = Variable(data_tuple[0].cuda(async=True))
targets = Variable(data_tuple[1].cuda(async=True))
# Forward pass.
outputs = self.seg_net(inputs)
# Compute the loss of the train batch & backward.
loss_pixel = self.pixel_loss(outputs, targets)
loss = loss_pixel
self.train_losses.update(loss.data[0], inputs.size(0))
self.optimizer.zero_grad()
loss.backward()
self.optimizer.step()
# Update the vars of the train phase.
self.batch_time.update(time.time() - start_time)
start_time = time.time()
self.iters += 1
# Print the log info & reset the states.
if self.iters % self.configer.get('solver', 'display_iter') == 0:
Log.info('Train Iteration: {0}\t'
'Time {batch_time.sum:.3f}s / {1}iters, ({batch_time.avg:.3f})\t'
'Data load {data_time.sum:.3f}s / {1}iters, ({data_time.avg:3f})\n'
'Learning rate = {2}\n'
'Loss = {loss.val:.8f} (ave = {loss.avg:.8f})\n'.format(
self.iters, self.configer.get('solver', 'display_iter'),
self.lr, batch_time=self.batch_time,
data_time=self.data_time, loss=self.train_losses))
self.batch_time.reset()
self.data_time.reset()
self.train_losses.reset()
# Check to val the current model.
if self.val_loader is not None and \
self.iters % self.configer.get('solver', 'test_interval') == 0:
self.__val()
self.optimizer, self.lr = self.module_utilizer.update_optimizer(self.seg_net, self.iters)
示例7: TestLogger
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
class TestLogger(unittest.TestCase):
def setUp(self):
self.logger = Logger().getLogger(__name__)
def test_log(self):
self.logger.debug("debug")
self.logger.info("info")
self.logger.warn("warn")
self.logger.error("error")
self.logger.critical("critical")
示例8: Bar
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
class Bar():
def __init__(self):
print 'Bar init()'
self.logger = Logger().getLogger('utils.use_logger.Bar')
def test_log(self):
print 'Bar test_log()'
self.logger.debug("debug")
self.logger.info("info")
self.logger.warn("warn")
self.logger.error("error")
self.logger.critical("critical")
示例9: update_buildings
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def update_buildings(self, buildings):
"""
Perform an update of building data on Database.
Arguments:
- buildings: a list of dictionaries, where each dictionary represents
a building.
Does not return (None).
Example of a building retrived from an Edilizia csv file:
{
'b_id' : '11030',
'address' : 'Milano - Via Francesco Sforza 44',
'lon' : '9.193670',
'lat' : '45.458065',
'l_b_id' : '5471'
}
If a building with the same b_id exists on the database, hence it will
be updated, otherwise it will be replaced.
"""
self.batch_date = datetime.now()
for b in buildings:
if not self._validate_building_data(b):
continue
building = self.find_building_to_update(b)
self._mark_building_as_updated(building)
with Logger.info("Processing "+str(building)):
self._update_a_building(building, b)
self._clean_unmarked_buildings()
示例10: MoveAction
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
class MoveAction(Action):
DIRECTIONS = {"N": (0, -1),
"NE": (1, -1),
"E": (1, 0),
"SE": (1, 1),
"S": (0, 1),
"SW": (-1, 1),
"W": (-1, 0),
"NW": (-1, -1)}
def __init__(self):
self._world = World()
self._logger = Logger()
def do_action(self, robot, args):
'''Move the robot in the specified direction..
@param robot: Instance of `objects.robot.Robot'.
'''
# Validating arguments.
if len(args) != 2:
raise InvalidArgumentsError("Move action takes exactly two argument. {0} given.".format(len(args)))
direction = args[1]
if not isinstance(direction, str) or direction not in MoveAction.DIRECTIONS:
raise InvalidArgumentsError("Invalid direction passed to Move action.")
robot_location = robot.get_location()
direction_points = MoveAction.DIRECTIONS[direction]
destination = (robot_location[0] + direction_points[0],
robot_location[1] + direction_points[1])
try:
self._do_move(robot, destination)
except LockAlreadyAquiredError:
# Waiting for a moment, and trying one more time.
# Client shouldn't receive an error if, for example, someone updating a plant on these squares.
self._logger.info("Concurrency when trying to move a robot.")
time.sleep(0.02)
self._do_move(robot, destination)
def _do_move(self, robot, destination):
'''Actually moves the robot to the new location.'''
self._world.move_robot(robot, destination)
示例11: perform_maps_update
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def perform_maps_update(self, building):
"""
Call the perform_map_update on every floor in the dxf key of the building
dictionary.
Arguments:
- building: a dictionary representing a building we want to update/create the
svg maps.
Returns: None.
"""
with Logger.info("Generating floor maps for", str(building)):
for floor in building["merged"]["floors"]:
Logger.info("Generating map for floor: ", floor["f_id"])
svg = FloorDrawer.draw_floor(floor)
filename = self.prepare_path_and_filename(building["_id"], floor["f_id"])
svg.saveas(filename)
示例12: _print_dxf_analysis
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def _print_dxf_analysis(klass, building):
dxf_info = DXFAnalysis.analyse_dxf_info(building)
for f_id, count, which in dxf_info:
total_rooms = count["total_rooms"]
identified_rooms = data_and_percent(count["identified_rooms"], total_rooms)
categorized_rooms = data_and_percent(count["categorized_rooms"], total_rooms)
no_info_rooms = data_and_percent(count["no_info_rooms"], total_rooms)
message = "Floor {:5} | ".format(f_id)
message += "Rooms: {:<4} | ".format(total_rooms)
message += "With Id.: {:<12} | ".format(identified_rooms)
message += "With Cat: {:<12} | ".format(categorized_rooms)
message += "No info: {:<11} | ".format(no_info_rooms)
message += "Wall objs: {:<4} | ".format(count["walls"])
message += "Window objs: {:<4}".format(count["windows"])
Logger.info(message)
示例13: report_building
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def report_building(klass, building):
BuildingIdAnalysis.analyse_building_id(building)
with Logger.info("Analysing "+str(building)):
with Logger.info("DXF Data Analysis"):
klass._print_dxf_analysis(building)
no_data = set()
for source, target in klass.merge_tuples:
klass._print_merge_analysis(source, target, building)
if not building.get_path(source+".floors"):
no_data.add(source)
if not building.get_path(target+".floors"):
no_data.add(target)
if no_data:
Logger.info("Source doesn't exist or has no floor information:", ", ".join(no_data))
示例14: __val
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def __val(self):
"""
Validation function during the train phase.
"""
self.pose_net.eval()
start_time = time.time()
for j, data_tuple in enumerate(self.val_loader):
# Change the data type.
inputs = Variable(data_tuple[0].cuda(async=True), volatile=True)
heatmap = Variable(data_tuple[1].cuda(async=True), volatile=True)
maskmap = None
if len(data_tuple) > 2:
maskmap = Variable(data_tuple[2].cuda(async=True), volatile=True)
# Forward pass.
paf_out, heatmap_out = self.pose_net(inputs)
# Compute the loss of the val batch.
loss_heatmap = self.mse_loss(heatmap_out, heatmap, maskmap)
loss = loss_heatmap
if len(data_tuple) > 3:
vecmap = Variable(data_tuple[3].cuda(async=True), volatile=True)
loss_associate = self.mse_loss(paf_out, vecmap, maskmap)
loss = loss_heatmap + loss_associate
self.val_losses.update(loss.data[0], inputs.size(0))
# Update the vars of the val phase.
self.batch_time.update(time.time() - start_time)
start_time = time.time()
self.module_utilizer.save_net(self.pose_net, self.iters)
# Print the log info & reset the states.
Log.info(
'Test Time {batch_time.sum:.3f}s, ({batch_time.avg:.3f})\t'
'Loss {loss.avg:.8f}\n'.format(
batch_time=self.batch_time, loss=self.val_losses))
self.batch_time.reset()
self.val_losses.reset()
self.pose_net.train()
示例15: _clean_unmarked_buildings
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import info [as 别名]
def _clean_unmarked_buildings(self):
"""
After an update batch is completed, buildings not updated are to be
considered as "removed" by the supplied data source, and, hence, a logic
"delete" operation is performed, by adding a delete_<namespace> key
to the building object.
A building is completely removed from database if every source that once
stated it existed now has a deleted_<namespace> key set.
What this algorithm does is to look for Buildings with updated_at field
older than this last batch_date (i.e., untouched), and add the logic
delete key to those buildings. Finally, it looks for buildings that
had all data logically deleted and removes them physically from DB.
Return value: None
"""
# Make sure the current update is performed as a perfect snapshot,
# removing also "untouched" buildings
n_removed, b_removed = Building.remove_untouched_keys(
self.get_namespace(), self.batch_date
)
b_removed = [ b["b_id"] for b in b_removed ]
if b_removed:
Logger.info(
n_removed,
"previously existing buildings are not present",
"in this snapshot:",
", ".join(b_removed)
)
n_destroyed, b_destroyed = Building.remove_deleted_buildings()
b_destroyed = [ b["b_id"] for b in b_destroyed ]
if n_destroyed:
Logger.info(
n_destroyed,
"buildings were effectively removed from database",
"since no data source affirms its existence:",
", ".join(b_destroyed)
)