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


Python Logger.debug方法代码示例

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


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

示例1: _Job

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
class _Job(object):
    def __init__(self):
        self.log = Logger(self.__class__.__name__, fh)
        self.log.debug("Job is created")

    def execute(self, **kwargs):
        try:
            self.log.debug("Start job with kwargs=%s" % kwargs)
            self._execute(**kwargs)
            self.log.debug("Finish job successful")
        except Exception as e:
            self.log.exception("Error during job execution")
            subject = 'Tasker Information. Произошла ошибка в скрипте %s' % self.__class__.__name__
            self.log.debug(subject)
            # send_email(subject, as_text(e.message),
            #            send_from=SMTP_SETTINGS['username'],
            #            server=SMTP_SETTINGS['server'],
            #            port=SMTP_SETTINGS['port'],
            #            user=SMTP_SETTINGS['username'],
            #            passwd=SMTP_SETTINGS['password'],
            #            dest_to=ERROR_EMAILS)

    def _execute(self, **kwargs):
        raise NotImplementedError("%s._execute" % self.__class__.__name__)

    @classmethod
    def run(cls, **kwargs):
        log.debug("in _Job.run!")
        return cls().execute(**kwargs)
开发者ID:alexxxmen,项目名称:tasker,代码行数:31,代码来源:__init__.py

示例2: handle_routing_packet

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
    def handle_routing_packet(self, packet, dynamic):
        """
        Updates the cost and routing tables using the given routing packet

        :param packet: Routing packet to update tables for
        :type packet: RoutingPacket
        :param dynamic: Whether we're handling a dynamic or static packet
        :type dynamic: bool
        :return: Nothing
        :rtype: None
        """
        # No routing table yet. Begin creation, then handle this packet
        if not self._get_intermediate_routing_table(dynamic):
            self.create_routing_table(dynamic)
        did_update = False
        cost_table = packet.costTable
        src_id = packet.src.id

        # Get the appropriate routing table
        routing_table = self._get_intermediate_routing_table(dynamic)
        # Update costs by adding the cost to travel to the source node
        src_cost = routing_table[src_id].cost
        for identifier in cost_table.keys():
            cost_table[identifier] = cost_table[identifier] + src_cost

        src_link = routing_table[src_id].link
        # Update our routing table based on the received table
        for identifier, cost in cost_table.items():
            # New entry to tables or smaller cost
            if identifier not in routing_table or \
                    cost < routing_table[identifier].cost:
                did_update = True
                routing_table[identifier] = LinkCostTuple(src_link, cost)

        # Store and broadcast the updated table if an update occurred
        if did_update:
            self.sameDataCounter = 0
            self.store_routing_table(dynamic, routing_table)
            new_cost_table = self.cost_table_from_routing_table(dynamic)
            self.broadcast_table(new_cost_table, dynamic)
        else:
            self.sameDataCounter += 1
            # Log the same data receipt
            Logger.debug(Network.get_time(), "%s received no new routing table "
                                             "data." % self)
            # Log finalized routing table
            Logger.trace(Network.get_time(), "%s final %s routing table:"
                         % (self, "dynamic" if dynamic else "static"))
            if dynamic:
                self.handle_same_dynamic_routing_table()
开发者ID:cs143-2015,项目名称:network-sim,代码行数:52,代码来源:router.py

示例3: SchedulerController

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
class SchedulerController(object):
    def __init__(self, request, scheduler):
        self.log = Logger(self.__class__.__name__, fh)
        self._request = request
        self._scheduler = scheduler

    def call(self, *args, **kwargs):
        try:
            request_info = get_request_info(self._request)
            self.log.debug("Start process request: %s, %s, %s" %
                           (request_info.url, request_info.data, request_info.method))
            data = self._call(*args, **kwargs)
            self.log.debug('Finished')
            return data
        except Exception, e:
            self.log.exception('Error during %s call' % self.__class__.__name__)
            return render_template('error.html', error=e.message)  # TODO шаблон
开发者ID:alexxxmen,项目名称:tasker,代码行数:19,代码来源:__init__.py

示例4: IndexController

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
class IndexController(object):
    def __init__(self, request, scheduler):
        self.request = request
        self.scheduler = scheduler
        self.log = Logger(self.__class__.__name__, fh)

    def call(self):
        try:
            self.log.debug("Start process request:" % self.request)
            sched_status = self.scheduler.state
            job_list = JobListController(self.request, self.scheduler).call()
            data = render_template('index.html', data=job_list, status=sched_status)
            self.log.debug("Finished")
            return data
        except Exception, e:
            self.log.exception('Error during %s call' % self.__class__.__name__)
            return render_template('error.html', errors=[e.message])
开发者ID:alexxxmen,项目名称:tasker,代码行数:19,代码来源:index.py

示例5: send

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
    def send(self, time, packet, origin, from_free=False):
        """
        Sends a packet to a destination.

        Args:
            time (int):                The time at which the packet was sent.
            packet (Packet):           The packet.
            origin (Host|Router):      The node origin of the packet.
        """
        origin_id = self.get_direction_by_node(origin)
        dst_id = 3 - origin_id
        destination = self.get_node_by_direction(dst_id)
        if self.in_use or self.packets_on_link[origin_id] != []:
            if self.current_dir is not None:
                Logger.debug(time, "Link %s in use, currently sending to node "
                                   "%d (trying to send %s)"
                             % (self.id, self.current_dir, packet))
            else:
                Logger.debug(time, "Link %s in use, currently sending to node "
                                   "%d (trying to send %s)"
                             % (self.id, origin_id, packet))
            if self.buffer.size() >= self.buffer_size:
                # Drop packet if buffer is full
                Logger.debug(time, "Buffer full; packet %s dropped." % packet)
                self.dispatch(DroppedPacketEvent(time, self.id))
                return
            self.buffer.add_to_buffer(packet, dst_id, time)
        else:
            if not from_free and self.buffer.buffers[dst_id] != []:
                # Since events are not necessarily executed in the order we
                # would expect, there may be a case where the link was free
                # (nothing on the other side and nothing currently being put
                # on) but the actual event had not yet fired.
                #
                # In such a case, the buffer will not have been popped from
                # yet, so put the packet we want to send on the buffer and
                # take the first packet instead.
                self.buffer.add_to_buffer(packet, dst_id, time)
                packet = self.buffer.pop_from_buffer(dst_id, time)
            Logger.debug(time, "Link %s free, sending packet %s to %s" % (self.id, packet, destination))
            self.in_use = True
            self.current_dir = dst_id
            transmission_delay = self.transmission_delay(packet)

            self.dispatch(PacketSentOverLinkEvent(time, packet, destination, self))

            # Link will be free to send to same spot once packet has passed
            # through fully, but not to send from the current destination until
            # the packet has completely passed.
            # Transmission delay is delay to put a packet onto the link
            self.dispatch(LinkFreeEvent(time + transmission_delay, self, dst_id, packet))
            self.dispatch(LinkFreeEvent(time + transmission_delay + self.delay, self, self.get_other_id(dst_id), packet))
            self.update_link_throughput(time, packet,
                                        time + transmission_delay + self.delay)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:56,代码来源:link.py

示例6: update_link_throughput

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
    def update_link_throughput(self, time, packet, time_received):
        """
        Update the link throughput

        :param time: Time when this update is occurring
        :type time: float
        :param packet: Packet we're updating the throughput with
        :type packet: Packet
        :param time_received: Time the packet was received at the other node
        :type time_received: float
        :return: Nothing
        :rtype: None
        """
        self.bytesSent += packet.size()
        self.sendTime = time_received
        assert self.sendTime != 0, "Packet should not be received at time 0."
        throughput = (8 * self.bytesSent) / (self.sendTime / 1000)  # bits/s
        Logger.debug(time, "%s throughput is %f" % (self, throughput))
        self.dispatch(LinkThroughputEvent(time, self.id, throughput))
开发者ID:cs143-2015,项目名称:network-sim,代码行数:21,代码来源:link.py

示例7: Scraper

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
class Scraper(object):

    def __init__(self, verbose=False):
        self.logger = Logger(verbose=verbose)
        self._targets = targets
        self._parser = None

    def urlinfo(self, url):
        """
        Initializes Parser Model.
        Returns URL target information if a match against known patterns is found.

        """
        if not self._parser:
            self._parser = BaseParser(self)
        try:
            info = self._parser.urlinfo(url, init=True)
        except TargetPatternNotFound:
            self.logger.debug(' >> Target Pattern Not Found')
            return {}
        else:
            if info.has_key('parser'):
                self._parser = info['parser']
                self.logger.debug('Using model "%s"' % self._parser.name)
            return info

    def parse(self, url, headers=None, proxy=None):
        """ Returns Tree object """
        if not self._parser:
            self._parser = BaseParser(self)
        return self._parser.parse(url, headers, proxy)
            
    def get_deals(self, url):
        if not url:
            return []
        self.urlinfo(url) # initialize parser model
        return self._parser.get_deals(url)

    def get_deal(self, url=''):
        if not url:
            return {}
        try:
            self.urlinfo(url) # initialize parser model
        except TargetPatternNotFound:
            self.logger.debug(' >> Target Pattern Not Found')
            return {}
        else:
            try:
                return self._parser.get_deal(url)
            except ElementMissing as e:
                self.logger.debug(' >> Element Missing - {:s}'.format(e))
                return {}
开发者ID:mgiuliano,项目名称:libscraper,代码行数:54,代码来源:scraper.py

示例8: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
    def execute(self):
        # If the packet that was sent to trigger this link free event is still
        # on the link, that's fine; this event is what means that it's off the
        # link, so we can remove it.
        if self.packet in self.link.packets_on_link[3 - self.direction]:
            self.link.packets_on_link[3 - self.direction].remove(self.packet)
        # Now, we check that there's nothing on the other side of the link.
        # If the link is currently sending data in the other direction, we
        # can't do anything here.
        if self.link.packets_on_link[3 - self.direction] != []:
            return

        destination = self.link.get_node_by_direction(self.direction)
        origin = self.link.get_node_by_direction(3 - self.direction)

        Logger.debug(self.time, "Link %s freed towards node %d (%s)" %
                     (self.link.id, self.direction, destination))
        self.link.in_use = False
        self.link.current_dir = None

        next_packet_in_dir = self.link.buffer.pop_from_buffer(self.direction, self.time)
        if next_packet_in_dir is not None:
            Logger.debug(self.time, "Buffer exists toward node %d" % (self.direction))
            self.link.send(self.time, next_packet_in_dir, origin, from_free=True)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:26,代码来源:link_free_event.py

示例9: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
 def execute(self):
     Logger.debug(self.time, "%s: Updating dynamic routing table." % self)
     # Fix dynamic cost of the link before starting routing table creation
     map(lambda l: l.fix_dynamic_cost(self.time), self.router.links)
     self.router.create_routing_table(dynamic=True)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:7,代码来源:update_dynamic_routing_table_event.py

示例10: execute

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
    def execute(self):
        msg = "ACK received from host %s, flow %s" % (self.host, self.flow)
        Logger.debug(self.time, msg)

        self.flow.ack_received(self.time)
开发者ID:cs143-2015,项目名称:network-sim,代码行数:7,代码来源:ack_received_event.py

示例11: Logger

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import debug [as 别名]
fh = logging.FileHandler(os.path.join(config.LOG_TO, config.LOGGER.get('file')))
fh.setLevel(config.LOGGER.get('level'))
fh.setFormatter(config.LOGGER.get('formatter'))

log = Logger("IBotManager", fh)


modules = get_all_modules()

threads = [Thread(target=InstaBot(**get_config_from_module(module_name[:-3])).new_auto_mod,
                  name=module_name[:-3]) for module_name in modules]


for t in threads:
    try:
        log.debug("Try start '%s' bot" % t.name)
        t.start()
        log.debug("Successfully start '%s' bot." % t.name)
    except Exception as ex:
        log.exception("Error during work bot")

[t.join() for t in threads if t.is_alive()]


def stop_all_process():
    signal.alarm(1)

atexit.register(stop_all_process)
time.sleep(5)
开发者ID:alexxxmen,项目名称:projects,代码行数:31,代码来源:ibotmanager.py


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