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


Python log.debug函数代码示例

本文整理汇总了Python中umit.pm.core.logger.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: bind_perspective

    def bind_perspective(self, ptype, callback):
        """
        Bind the perspective 'type'

        The callback should be of the type
          def perspective_cb(perspective, type, already_present, added)

        @param type the perspective's type (see also PerspectiveType)
        @param callback the callback to execute when a new
               perspective of type 'type' is created
        """

        log.debug(
            "Binding method %s for perspective of type %s" % \
            (callback, PerspectiveType.types[ptype])
        )

        self.perspective_binder[ptype].append(callback)

        for page in ServiceBus().call('pm.sessions', 'get_sessions'):
            if not isinstance(page, Session):
                continue

            for perspective in page.perspectives:
                idx = PerspectiveType.types[type(perspective)]

                callback(perspective, idx, True, True)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:27,代码来源:mainwindow.py

示例2: unbind_session

    def unbind_session(self, ptype, persp_klass):
        try:
            for i in range(len(self.session_binder[ptype])):
                (klass, show, resize) = self.session_binder[ptype][i]

                if klass is not persp_klass:
                    continue

                del self.session_binder[ptype][i]

                klass = SessionType.types[ptype]

                for page in ServiceBus().call('pm.sessions', 'get_sessions'):
                    if isinstance(page, klass):
                        page.remove_perspective(persp_klass)

                log.debug(
                    "Binding method %s for perspective of type %s removed" % \
                    (persp_klass, SessionType.types[ptype])
                )

                return True
        except:
            log.error(
                "Failed to remove binding method %s for session of type %s" % \
                (persp_klass, SessionType.type[ptype])
            )

        return False
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:29,代码来源:mainwindow.py

示例3: debind_perspective

    def debind_perspective(self, type, callback):
        """
        Remove the binding callback for perspective of type 'type'

        @param type the perspective type
        @param callback the callback to remove
        @return True if the callback is removed correctly
        """

        try:
            self.perspective_binder[type].remove(callback)

            for page in ServiceBus().call('pm.sessions', 'get_sessions'):
                if not isinstance(page, Session):
                    continue

                for perspective in page.perspectives:
                    idx = PerspectiveType.types[type(perspective)]

                    callback(perspective, idx, True, False)

            log.debug(
                "Binding method %s for perspective of type %s removed" % \
                (callback, PerspectiveType.types[type])
            )

            return True
        except:
            log.error(
                "Failed to remove binding method %s "
                "for perspective of type %s" % \
                (callback, PerspectiveType.types[type])
            )

        return False
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:35,代码来源:mainwindow.py

示例4: register_session

    def register_session(self, sessklass, ctxklass=None):
        """
        Register a custom session class and returns the new id
        of the SessionType

        @param sessklass the custom session class
        @param ctxklass the context class to use
        @return id
        """

        log.debug('Registering a new session')

        if sessklass.session_menu is not None:
            log.debug('Creating new menu entry named %s for the session' % \
                      sessklass.session_menu)

            item = self.ui_manager.get_widget('/menubar/File')
            menu = item.get_submenu()

            item = gtk.MenuItem(sessklass.session_menu)
            item.connect('activate', self.create_session, (sessklass, ctxklass))
            item.show()

            menu.insert(item, 2)

            sessklass.session_menu_object = item

        return SessionType.add_session(sessklass)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:28,代码来源:mainwindow.py

示例5: register_notify_for

    def register_notify_for(self, packet, callback):
        if packet in self.notify:
            self.notify[packet].append(callback)
        else:
            self.notify[packet] = [callback]

        log.debug("%d callbacks for %s" % (len(self.notify[packet]), packet))
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:7,代码来源:propertytab.py

示例6: __on_selection_changed

    def __on_selection_changed(self, sel):
        sel = self.tree.get_selection()

        if self.active_packets:
            self.active_packets = []

        if sel.get_mode() == gtk.SELECTION_MULTIPLE:
            model, lst = sel.get_selected_rows()

            for path in lst:
                # We are the list store
                packet = model.get_value(model.get_iter(path), 1)
                self.active_packets.append(packet)

            log.debug("Repopulating active_packets with selection %s" % \
                      self.active_packets)

            self.session.set_active_packet(None)

        elif sel.get_mode() == gtk.SELECTION_SINGLE:
            ret = sel.get_selected()

            if ret:
                model, iter = ret

                if iter:
                    self.session.set_active_packet(model.get_value(iter, 0))
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:27,代码来源:sequencepage.py

示例7: __on_idle

    def __on_idle(self, udata):
        if self.type == FileOperation.TYPE_LOAD:
            ctx, rctx = udata

            self.loading_view = True

            log.debug('Creating a new session after loading for %s' % str(ctx))

            if ctx is backend.SequenceContext:
                from umit.pm.gui.sessions.sequencesession import SequenceSession

                ServiceBus().call('pm.sessions', 'bind_session',
                                  SequenceSession, rctx)

            elif ctx is backend.SniffContext or \
                 ctx is backend.StaticContext:

                from umit.pm.gui.sessions.sniffsession import SniffSession

                ServiceBus().call('pm.sessions', 'bind_session',
                                  SniffSession, rctx)

        else:
            from umit.pm.gui.sessions.sniffsession import SniffSession

            if isinstance(self.session, SniffSession):
                self.session.sniff_page.statusbar.label = '<b>%s</b>' % \
                                                          self.ctx.summary
        self.loading_view = False
        self.percentage = 100.0
        self.state = self.NOT_RUNNING

        # Force update.
        self.notify_parent()
        return False
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:35,代码来源:operationstab.py

示例8: _thread_main

    def _thread_main(self, udata=None):
        if self.type == FileOperation.TYPE_LOAD:
            ctx = udata
            rctx = None

            log.debug('Loading file as %s' % str(ctx))

            if ctx is backend.SequenceContext:
                rctx = backend.SequenceContext(self.file)

            elif ctx is backend.SniffContext or \
                 ctx is backend.StaticContext:

                rctx = backend.StaticContext(self.file, self.file,
                                 Prefs()['backend.system.static.audits'].value)

            if rctx is not None:
                # Let's update our operation directly from load
                if rctx.load(operation=self) == True:
                    # Now let's add a callback to when
                    gobject.idle_add(self.__on_idle, (ctx, rctx))
                else:
                    log.error('Error while loading context on %s.' % self.file)
                    self.state = self.NOT_RUNNING
        else:
            log.debug('Saving %s to %s' % (self.ctx, self.ctx.cap_file))

            if self.ctx.save(operation=self) == True:
                gobject.idle_add(self.__on_idle, ())
            else:
                log.error('Error while saving context on %s.' % \
                          self.ctx.cap_file)
                self.state = self.NOT_RUNNING

        self.thread = None
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:35,代码来源:operationstab.py

示例9: __on_quit

    def __on_quit(self, *args):
        self.hide()

        # We need to stop the pending sniff threads
        lst = []

        for page in ServiceBus().call('pm.sessions', 'get_sessions'):
            if isinstance(page, Session) and \
               isinstance(page.context, backend.TimedContext):
                lst.append(page.context)

        for ctx in lst:
            ctx.stop()

        # Avoids joining all threads are daemon
        #for ctx in lst:
        #    ctx.join()

        errs = []

        try:
            log.debug('Saving options before exiting')
            Prefs().write_options()
        except IOError, err:
            errs.append(err)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:25,代码来源:mainwindow.py

示例10: reload_webpage

    def reload_webpage(self):
        if not self.session.packet:
            return

        page = self.session.packet.cfields.get('dissector.http.response', None)
        headers = self.session.packet.cfields.get('dissector.http.headers',
                                                  None)

        if not page:
            self.webview.load_html_string('<pre>No HTTP payload set.<pre>',
                                          'file:///')
            return

        log.debug('These are the available headers: %s' % headers)
        log.debug('Looking for content type ...')

        if headers and 'content-type' in headers:
            conttype = headers['content-type'][0]

            if not conttype.startswith('text/'):
                self.webview.load_html_string(g_js_text % conttype,
                                              'file:///')
                return
        try:
            self.webview.load_html_string(unicode(page), 'file:///')
        except:
            self.webview.load_html_string('<pre>Not plain text</pre>',
                                          'file:///')
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:28,代码来源:main.py

示例11: update

    def update(self, conn, mpkt):
        log.debug("Updating connection %s" % conn)

        conn.ts = time.time()

        if mpkt.l4_flags & TH_SYN:
            conn.status = CN_OPENING
        elif mpkt.l4_flags & TH_FIN:
            conn.status = CN_CLOSING
        elif mpkt.l4_flags & TH_ACK:
            if conn.status == CN_OPENING:
                conn.status = CN_OPEN
            elif conn.status == CN_CLOSING:
                conn.status = CN_CLOSED

        if mpkt.l4_flags & TH_PSH:
            conn.status = CN_ACTIVE

        if mpkt.l4_flags & TH_RST:
            conn.status = CN_KILLED

        conn.add_buf(mpkt)

        if mpkt.l4_proto == NL_TYPE_UDP:
            conn.status = CN_ACTIVE

        if mpkt.flags & MPKT_MODIFIED or mpkt.flags & MPKT_DROPPED:
            conn.flags |= CN_MODIFIED
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:28,代码来源:sessionmanager.py

示例12: __init__

    def __init__(self, value, \
                 name=None, def_value=None, desc=None, \
                 attrs=(), parent=None):
        """
        Create a variable

        @param value the value for variable
        @param name the name for variable (optional if are in list)
        @param def_val the default value for variable (optional if is user conf)
        @param desc the description of value (optional if in user conf)
        @param attrs a list of attributes
        @param sectiondict the section dict
        """
        self._value = self.__class__.convert(value)
        self._name = name
        self._def_val = self.__class__.convert(def_value)
        self._desc = desc
        self._parent = parent

        # Compatibility for child objects
        self.add_attribute(attrs, 'id', Integer, '_id')

        self.set_attributes(attrs)
        self.check_validity()

        if not Variable.setted(self._value):
            raise Exception("Value not setted")
        
        if not isinstance(self._value, self.__class__.element_type):
            raise Exception("Unable to set a valid type")
        
        log.debug(">>> Variable named '%s' allocate with value '%s'" % (self._name, self._value))
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:32,代码来源:parser.py

示例13: run

    def run(self):
        packet = self.metapacket.root

        # If is setted to 0 we need to do an infinite loop
        # so this variable should be negative

        if not self.count:
            log.debug("This is an infinite loop.")
            self.count = -1

        try:
            while self.count:
                self.socket.send(packet)

                if self.count > 0:
                    self.count -= 1

                if self.callback(self.metapacket, self.udata) == True:
                    log.debug("The send callback want to exit")
                    return

                time.sleep(self.inter)

        except socket.error, (errno, err):
            self.callback(Exception(err), self.udata)
            return
开发者ID:nopper,项目名称:packet-manipulator,代码行数:26,代码来源:utils.py

示例14: __send_thread

    def __send_thread(self):
        try:
            packet = self.metapacket.root

            if not self.scount:
                log.debug("This is an infinite loop")
                self.scount = -1

            while self.scount:
                self.send_sock.send(packet)

                if self.scount > 0:
                    self.scount -= 1

                if self.scallback(self.metapacket, self.count - self.scount, \
                                  self.sudata):

                    log.debug("send callback want to exit")
                    break

                time.sleep(self.inter)
        except SystemExit:
            pass
        except Exception, err:
            log.error("Error in _sndrecv_sthread(PID: %d EXC: %s)" % \
                      (os.getpid(), str(err)))
开发者ID:nopper,项目名称:packet-manipulator,代码行数:26,代码来源:utils.py

示例15: remove_session

    def remove_session(session):
        del SessionType.types[session.session_id]
        del SessionType.types[session]

        log.debug("Deregistering %s (%d, %s)" % (session,
                                                 session.session_id,
                                                 session.session_name))
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:7,代码来源:__init__.py


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