当前位置: 首页>>代码示例>>Python>>正文


Python Logger.info方法代码示例

本文整理汇总了Python中utils.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Logger的用法示例。


在下文中一共展示了Logger.info方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: receive

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
    def receive(self, packet, time):
        """
        Handles receipt of a packet.

        Args:
            packet (Packet):                The packet.
            time (float):                   Time the packet was received
        """
        Logger.info(time, "%s received packet %s" % (self, packet))
        # Get the appropriate routing table
        routing_table = self.get_routing_table()
        # Update the current routing table with the routing packet
        if isinstance(packet, StaticRoutingPacket):
            self.handle_routing_packet(packet, dynamic=False)
        elif isinstance(packet, DynamicRoutingPacket):
            self.handle_routing_packet(packet, dynamic=True)
        # Route the packet
        elif isinstance(packet, AckPacket) or isinstance(packet, Packet):
            if not routing_table:
                Logger.warning(time, "%s dropped packet %s, no routing table. "
                                     "Creating one now." % (self, packet))
                self.create_routing_table(self.dynamicEnabled)
                return
            elif packet.dest.id not in routing_table:
                # TODO: should we keep a packet queue for packets w/o dest.?
                Logger.warning(time, "%s dropped packet %s, dest. not in "
                                     "routing table." % (self, packet))
                return
            dest_link = routing_table[packet.dest.id].link
            self.send(packet, dest_link, time)
        else:
            raise UnhandledPacketType
开发者ID:cs143-2015,项目名称:network-sim,代码行数:34,代码来源:router.py

示例2: handle_receive

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
    def handle_receive(self, packet, time):
        if isinstance(packet, AckPacket):
            Rn = packet.request_number

            self.last_n_req_nums.append(Rn)
            if len(self.last_n_req_nums) > TCPReno.MAX_DUPLICATES:
                self.last_n_req_nums.pop(0)

            Sn, Sb, Sm = self.host.sequence_nums
            cwnd = self.host.cwnd
            if self.last_drop is None or \
               time - self.last_drop > TCPReno.TIMEOUT_TOLERANCE:
                if len(self.last_n_req_nums) == TCPReno.MAX_DUPLICATES and \
                   all(num == Rn for num in self.last_n_req_nums):
                    # If we've had duplicate ACKs, then enter fast retransmit.
                    self.ssthresh = max(self.host.cwnd / 2, TCPReno.INITIAL_CWND)
                    self.set_window_size(time, self.ssthresh)
                    Logger.warning(time, "Duplicate ACKs received for flow %s." % self.host.flow[0])

                    self.last_drop = time
            if self.ss:
                self.set_window_size(time, cwnd + 1)
                if self.host.cwnd >= self.ssthresh:
                    self.ss = False
                    Logger.info(time, "SS phase over for Flow %s. CA started." % (self.host.flow[0]))
            elif Rn > Sb:
                # If we are in Congestion Avoidance mode, we wait for an RTT to
                # increase the window size, rather than doing it on ACK.
                self.set_window_size(time, cwnd + 1. / cwnd)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:31,代码来源:tcp_reno.py

示例3: timeout

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
    def timeout(self, time, packet):
        """
        A timeout occurred at the given time on the given packet. Resend if
        necessary.

        :param time: Time to resend the packet
        :type time: int
        :param packet: Packet which timed out
        :type packet: Packet
        """
        # We already received an Ack for it
        if packet.id not in self.awaiting_ack:
            return
        else:
            # Otherwise, remove it so that it will be added again
            del self.awaiting_ack[packet.id]

        if not isinstance(packet, FlowPacket):
            # If an ACK packet is dropped, don't worry about it, it'll be sent
            # again later
            return
        flow_id = packet.flow_id
        if self.current_request_num is not None and \
              packet.sequence_number < self.current_request_num:
            # Packet was already received
            return

        self.congestion_control.handle_timeout(packet, time)

        # Resend
        Logger.info(time, "Packet %s was dropped, resending" % (packet.id))
        self.queue.add(packet)
        self.send_packets(time, flow_id)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:35,代码来源:host.py

示例4: handle_receive

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
 def handle_receive(self, packet, time):
     if isinstance(packet, AckPacket):
         Rn = packet.request_number
         Sn, Sb, Sm = self.host.sequence_nums
         cwnd = self.host.cwnd
         if self.ss:
             self.set_window_size(time, cwnd + 1)
             if self.host.cwnd >= self.ssthresh:
                 self.ss = False
                 Logger.info(time, "SS phase over for Flow %s. CA started." % (self.host.flow[0]))
         elif Rn > Sb:
             # If we are in Congestion Avoidance mode, we wait for an RTT to
             # increase the window size, rather than doing it on ACK.
             self.set_window_size(time, cwnd + 1. / cwnd)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:16,代码来源:tcp_tahoe.py

示例5: send

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
    def send(self, packet, link, time):
        """
        Sends the given packet along the link at the specified time

        :param packet: Packet to send
        :type packet: Packet
        :param link: Link to send the packet through
        :type link: Link
        :param time: Time to send the packet
        :type time: float
        :return: Nothing
        :rtype: None
        """
        assert len(self.links) > 0, "Can't send if links aren't connected"
        Logger.info(time, "%s sent packet %s over link %s."
                    % (self, packet, link.id))
        # Send the packet
        self.dispatch(PacketSentToLinkEvent(time, self, packet, link))
开发者ID:cs143-2015,项目名称:network-sim,代码行数:20,代码来源:router.py

示例6: DataGatherer

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]

#.........这里部分代码省略.........
                    i -= 1
                pairs.add(pair)
            except IndexError:
                raise AssertionError('line {} is incorrect!'.format(line))
        return pairs

    def exclude_untracked_videos(self, pairs):
        ids = set(self.db_handler.get_all_video_ids())
        pairs_set = set(pairs)
        for pair in pairs:
            for youtube_id in pair:
                if youtube_id not in ids:
                    pairs_set.remove(pair)
                    break
        return pairs_set

    def rewrite_pairs(self, pairs):
        pairs_fixed = self.exclude_untracked_videos(pairs)
        f = open(self.cfg['train_fixed_path'], 'wb')
        for pair in pairs_fixed:
            f.write(','.join(pair) + '\n')
        f.close()

    def fill_video_catalog(self, pairs, force=False):
        lefts_and_rights = zip(*pairs)
        ids = set(lefts_and_rights[0] + lefts_and_rights[1])

        if not force:
            ids_cache = set(self.db_handler.get_all_video_ids())
            ids.difference_update(ids_cache)

        for i, youtube_id in enumerate(ids):
            if i % 100 == 0:
                self.logger.info('scanned {} lines.'.format(i))
            self.add_video_by_id(youtube_id)

    def update_video_catalog(self, limit=None):
        ids_cache = set(self.db_handler.get_all_video_ids())
        for i, youtube_id in enumerate(ids_cache):
            if limit and i > limit:
                break
            self.update_video_by_id(youtube_id)

    def add_video_by_id(self, youtube_id):
        html = self.downloader.get_html(youtube_id)
        if not self.parser._check_video_availability(html):
            return

        video_item = Video(youtube_id)
        video_item.update(title=self.parser.get_video_title(html))
        self.db_handler.add_entry(video_item)

    def update_video_by_id(self, youtube_id):
        html = self.downloader.get_html(youtube_id)
        if not self.parser._check_video_availability(html):
            return

        video_item = self.db_handler.get_video_by_youtube_id(youtube_id)
        try:
            video_item.update(
                title=self.parser.get_video_title(html),
                views=self.parser.get_view_count(html),
                likes=self.parser.get_likes_count(html),
                dislikes=self.parser.get_dislikes_count(html),
            )
        except ParseError:
开发者ID:RugnarLodbrok,项目名称:mchs-video-analyser,代码行数:70,代码来源:data_gatherer.py

示例7: Flask

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
from config import JOBSTORES, EXECUTORS, JOB_DEFAULTS, LOGGER, LOG_TO
from utils import Logger

app = Flask(__name__)
app.config.from_object('config')

if not os.path.exists(LOG_TO):
    os.makedirs(LOG_TO)

fh = logging.FileHandler(os.path.join(LOG_TO, LOGGER.get('file')))
fh.setLevel(LOGGER.get('level'))
fh.setFormatter(LOGGER.get('formatter'))

log = Logger("Roller", fh)

log.info("Service started!")

sched_log = Logger("apscheduler.executors.default", fh)
sched_log_jobstore = Logger("apscheduler.jobstores.default", fh)

scheduler = BackgroundScheduler(jobstores=JOBSTORES, executors=EXECUTORS, job_defaults=JOB_DEFAULTS, timezone=utc)
scheduler.start()

log.info("Scheduler started!")


def onstop():
    # Shut down the scheduler when exiting the app
    scheduler.shutdown()
    log.info("Scheduler shutdown")
    log.info("Service stopped!")
开发者ID:alexxxmen,项目名称:tasker,代码行数:33,代码来源:tasker.py

示例8: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
 def execute(self):
     Logger.info(self.time, "Packet %s sent over link %s to %s" % (self.packet, self.link.id, self.destination))
     transmission_delay = self.link.transmission_delay(self.packet)
     recv_time = self.time + transmission_delay + self.link.delay
     self.link.packets_on_link[self.link.get_direction_by_node(self.destination)].append(self.packet)
     self.link.dispatch(PacketReceivedEvent(recv_time, self.packet, self.destination, self.link))
开发者ID:cs143-2015,项目名称:network-sim,代码行数:8,代码来源:packet_sent_over_link_event.py

示例9: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
 def execute(self):
     Logger.info(self.time, "Packet %s sent to link %s from %s" % (self.packet, self.link.id, self.origin))
     self.link.send(self.time, self.packet, self.origin)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:5,代码来源:packet_sent_to_link_event.py

示例10: RTC

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
class RTC(object):
	def __init__(self, dev=None, enable_ems=False):
		self.dev = dev
		self.logger = Logger('RTC')

		self.can_id = None  # todo need to be further confirm
		self.task = None

		self.ui_queue = None
		self.db = None

		self.enable_ems = enable_ems
		self.ems_data = Data() if self.enable_ems else None

		self.scheduler = BackgroundScheduler(daemon=True)
		self.set_scheduler()

	def api(self, cmd, parameters):
		self.logger.info('Real-Time Controller api() ' + ' ' + cmd + ' ' + json.dumps(parameters))

		if cmd == 'TURN_OFF':
			self.turn_off()
		elif cmd == 'TURN_ON':
			self.turn_on()

	def contingency_analysis_classifier(self, can_message):
		pass

	def turn_off(self):
		self.logger.info('TURNING OFF module')

	def turn_on(self):
		self.logger.info('TURNING ON module')
		if self.task is None:
			self.task = TurnOn(self, timeout=15)
		else:
			return False

	def hi(self):
		print(ctime(time()), end='\r', flush=True)
		if self.task is not None:
			self.task.state.spent_t += 0.5
			self.task.spent_t += 0.5
			self.task.run()

			if self.task.spent_t > self.task.TIMEOUT:
				self.logger.error('Task ' + self.task.name + ' fail...')
				self.task = None

	def get_ems_data(self):

		results_dispatch = self.db.query(DispatchDBData).limit(2)
		results_unit = self.db.query(UnitsDBData).limit(2)
		results_forecast = self.db.query(ForecastDBData).limit(2)

		# todo process every line of result and send to GUI

		for d in results_dispatch:
			res = d.__dict__
			res.pop('_sa_instance_state')
			res['datetime1'] = mktime(d.datetime1.timetuple()) + d.datetime1.microsecond / 1000000.0

			self.ems_data.update(res)
			self.ui_queue.put(self.ems_data)

	def set_scheduler(self):
		self.scheduler.add_job(self.hi, 'interval', seconds=0.5)
		if self.enable_ems:
			if self.db is None:
				self.db = db_session()
			self.scheduler.add_job(self.get_ems_data, 'interval', seconds=1)

		self.scheduler.start()

	def is_bic_online(self):
		for dev in self.dev['bic']:
			if not dev.is_connected():
				self.logger.error((dev.name, ' is not online'))
				return False
		return True

	def minimum_system_online(self):

		for dev in self.dev['battery']:
			if not dev.is_connected():
				self.logger.error((dev.name, ' is not online'))
				return False

		for dev in self.dev['rm']:
			if not dev.is_connected():
				self.logger.error((dev.name, ' is not online'))
				return False

		return True
开发者ID:zhanglongqi,项目名称:Hybrid-Grid-EIRP-04,代码行数:96,代码来源:rtc.py

示例11: MyHandler

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
from utils import Logger

VERSION="1.0.0"

class MyHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        def __callback(response):
            data = { 'body': response.body[:20] + '...', 'length' : len(response.body) }
            self.set_header('Content-Type', 'application/json; charset="utf-8"')
            self.write(json.dumps(data))
            self.finish()

        async_client = tornado.httpclient.AsyncHTTPClient()
        request = tornado.httpclient.HTTPRequest("http://www.uol.com.br/")
        async_client.fetch(request, __callback) 

application = tornado.web.Application([
    (r"/", MyHandler),
])

global logger
global http_server    

if __name__ == "__main__":
    tornado.options.parse_command_line()
    logger = Logger('info', False)    
    logger.info('starting webasync v%s' % VERSION)    
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:dnslj,项目名称:python-labs,代码行数:32,代码来源:webasync.py

示例12: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
 def execute(self):
     Logger.info(self.time, "Packet %s received at %s" % (self.packet, self.destination))
     self.destination.receive(self.packet, self.time)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:5,代码来源:packet_received_event.py

示例13: set_window_size

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
 def set_window_size(self, time, value):
     flow_id = self.flow[0]
     Logger.info(time, "Window size changed from %0.2f -> %0.2f for flow %s" % (self.cwnd, value, flow_id))
     self.cwnd = value
     self.dispatch(WindowSizeEvent(time, flow_id, self.cwnd))
开发者ID:cs143-2015,项目名称:network-sim,代码行数:7,代码来源:host.py

示例14: receive

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import info [as 别名]
    def receive(self, packet, time):
        """
        Handles receipt of a packet.

        :param packet: Packet received
        :type packet: Packet | AckPacket
        :param time: Time the packet was received
        :type time: int
        :return: Nothing
        :rtype: None
        """
        Logger.info(time, "%s received packet %s." % (self, packet))
        # Ack packet, drop stored data that might need retransmission
        if isinstance(packet, AckPacket):
            flow_id = packet.flow_id
            Rn = packet.request_number

            if self.current_request_num is None:
                self.current_request_num = Rn
            else:
                self.current_request_num = max(Rn, self.current_request_num)

            # Receiving request number Rn means every packet with sequence
            # number <= Rn - 1 was received, so those have been acked. No need
            # to wait for their ack or to resend.
            acked_packets = []
            for packet_id, packet_data in self.awaiting_ack.items():
                acked_packet, _ = packet_data
                if acked_packet.sequence_number < Rn:
                    acked_packets.append(packet_id)
            for acked_packet_id in acked_packets:
                acked_packet, sent_time = self.awaiting_ack[acked_packet_id]
                if acked_packet in self.queue:
                    self.queue.remove(acked_packet)
                del self.awaiting_ack[acked_packet_id]
                self.dispatch(RTTEvent(flow_id, time, time - sent_time))

            self.congestion_control.handle_receive(packet, time)

            Sn, Sb, Sm = self.sequence_nums
            if Rn > Sb:
                Sm = Sm + (Rn - Sb)
                Sb = Rn
                Sn = Sb
                self.send_packets(time, flow_id)
            self.sequence_nums = (Sn, Sb, Sm)

        elif isinstance(packet, RoutingPacket):
            return
        # Regular packet, send acknowledgment of receipt
        elif isinstance(packet, FlowPacket):
            if packet.flow_id not in self.request_nums:
                self.request_nums[packet.flow_id] = 0
            if packet.sequence_number == self.request_nums[packet.flow_id]:
                Logger.warning(time, "Packet %d accepted from %s" % (packet.sequence_number, packet.src))
                self.request_nums[packet.flow_id] += 1
            else:
                Logger.info(time, "Incorrect packet received from %s. Expected %d, got %d." % (packet.src, self.request_nums[packet.flow_id], packet.sequence_number))
            ack_packet = AckPacket(packet.flow_id, self, packet.src, self.request_nums[packet.flow_id], packet)
            self.send(ack_packet, time)
        # Ignore routing packets
        else:
            raise UnhandledPacketType
开发者ID:cs143-2015,项目名称:network-sim,代码行数:65,代码来源:host.py


注:本文中的utils.Logger.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。