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


Python i18n._函数代码示例

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


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

示例1: __send_callback

        def __send_callback(self, packet, udata):
            if packet and isinstance(packet, Exception):
                self.internal = False
                self.summary = str(packet)
            elif self.tot_count:
                if packet:
                    self.count += 1
                else:
                    self.state = self.NOT_RUNNING

                if self.count == self.tot_count:
                    self.summary = _("%d packet(s) sent.") % self.tot_count
                else:
                    self.summary = _("Sending packet %d of %d") % (self.count, self.tot_count)

                self.percentage = float(self.count) / float(self.tot_count) * 100.0
            else:
                # If we are here we need to pulse the value
                self.summary = _("Sending packet %s") % packet.summary()
                self.percentage = (self.percentage + 536870911) % 2147483647

            if self.callback:
                self.callback(packet, udata)

            if not self.internal:
                self.state = self.NOT_RUNNING

            return self.state == self.NOT_RUNNING or self.state == self.PAUSED
开发者ID:nopper,项目名称:packet-manipulator,代码行数:28,代码来源:send.py

示例2: send_redirect

    def send_redirect(self, sip, dip):
        key = sip + ':' + dip

        delay = self.connections.get(key, None)

        if delay and (time.time() - delay) <= self.delay:
            return

        self.connections[key] = time.time()

        pkt = MetaPacket.new('ip') / MetaPacket.new('icmp')

        pkt.set_field('ip.src', self.gateway)
        pkt.set_field('ip.dst', dip)

        pkt.set_field('icmp.type', 5) # Redirect
        pkt.set_field('icmp.code', 0) # Redirect for network
        pkt.set_field('icmp.gw', self.source)

        self.packets += 1
        self.session.context.si_l3(pkt)

        self.session.output_page.user_msg(
            _('%s to %s matches - redirect to %s') % (sip, dip, self.source),
            STATUS_INFO, AUDIT_NAME)

        self.summary = AUDIT_MSG % (_('%d redirects sent') % self.packets)
        self.percentage = (self.percentage + 536870911) % \
                          gobject.G_MAXINT
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:29,代码来源:main.py

示例3: __recv_callback

        def __recv_callback(self, packet, is_reply, udata):
            if not packet:
                self.internal = False
                self.summary = _('%d of %d replie(s) received') % \
                                (self.answers, self.received)
            else:
                self.received += 1
                self.summary = _('Received/Answered/Remaining %d/%d/%d') % \
                                (self.received, self.answers, self.remaining)

                if is_reply:
                    self.answers += 1
                    self.remaining -= 1

                if is_reply or self.report_recv:
                    self.data.append(packet)

            self.percentage = (self.percentage + 536870911) % 2147483647

            if self.rcallback:
                self.rcallback(packet, is_reply, udata)

            if not self.internal:
                self.state = self.NOT_RUNNING

            return self.state == self.NOT_RUNNING or \
                   self.state == self.PAUSED
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:27,代码来源:sendreceive.py

示例4: __init__

    def __init__(self):
        gtk.VBox.__init__(self, False, 2)

        self.entry = FilterEntry()
        self.tree = AuditOutputTree()

        self.toolbar = gtk.Toolbar()
        self.toolbar.set_style(gtk.TOOLBAR_ICONS)

        action = gtk.Action('save', _('Save log'),
                            _('Save log to file'), gtk.STOCK_SAVE)
        action.connect('activate', self.tree.on_save_log)

        item = action.create_tool_item()
        self.toolbar.insert(item, -1)

        item = gtk.ToolItem()
        item.add(self.entry)
        item.set_expand(True)

        self.toolbar.insert(item, -1)

        self.pack_start(self.toolbar, False, False)
        self.pack_end(self.tree)

        self.entry.get_entry().connect('changed', self.__on_filter)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:26,代码来源:auditoutputpage.py

示例5: on_resolved

    def on_resolved(self, send, mpkt, reply, udata):
        if self.report:
            diff = None
            now = time.time()

            while self.times:
                tm = self.times.pop(0)
                diff = now - tm
                diff *= 100.0

                if diff > 0 and diff < self.delay:
                    break
                else:
                    diff = None # Too fast :)

            if diff is not None:
                self.session.output_page.user_msg(
                    _('Reply from %s [%s] %.2fms') % \
                    (reply.get_field('arp.pdst'),
                     reply.get_field('arp.hwsrc'),
                     diff), STATUS_INFO, AUDIT_NAME
                )

        self.packets += 1

        if self.probes > 0:
            self.percentage = (self.packets / float(self.probes)) * 100.0
            self.summary = AUDIT_MSG % _('%d of %d sent') % (self.packets, self.probes)
        else:
            self.summary = AUDIT_MSG % _('%d sent' % self.packets)
            self.percentage = (self.percentage + 536870911) % \
                              gobject.G_MAXINT
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:32,代码来源:main.py

示例6: __create_columns

    def __create_columns(self):
        col = gtk.TreeViewColumn(_("Audits"))

        col.set_expand(True)
        col.set_resizable(True)
        col.set_resizable(True)

        col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)

        rend = gtk.CellRendererPixbuf()
        col.pack_start(rend, False)
        col.set_cell_data_func(rend, self.__pix_data_func)

        rend = gtk.CellRendererText()
        col.pack_start(rend)
        col.set_cell_data_func(rend, self.__text_data_func)

        self.tree.append_column(col)

        rend = gtk.CellRendererProgress()
        col = gtk.TreeViewColumn(_("Status"), rend)

        col.set_expand(False)
        col.set_resizable(True)
        col.set_fixed_width(150)
        col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)

        col.set_cell_data_func(rend, self.__progress_data_func)

        self.tree.append_column(col)

        self.tree.set_rules_hint(True)
        self.icon_operation = get_pixbuf("operation_small")
开发者ID:nopper,项目名称:packet-manipulator,代码行数:33,代码来源:auditpage.py

示例7: __on_button_press

    def __on_button_press(self, widget, evt, typo):
        if evt.button != 3:
            return

        menu = gtk.Menu()

        # OK show a popup to copy and paste
        # cut/copy/paste/delete

        txts = (_("Cu_t"), _("_Copy"), _("_Paste"), _("Copy from _both"))
        icons = (gtk.STOCK_CUT, gtk.STOCK_COPY, gtk.STOCK_PASTE, gtk.STOCK_COPY)
        cbcs = (self.__on_cut, self.__on_copy, self.__on_paste, self.__on_bcopy)

        clipboard_sel = gtk.clipboard_get().wait_for_text() and True or False

        idx = 0

        for txt, icon, cbc in zip(txts, icons, cbcs):
            action = gtk.Action(None, txt, None, icon)
            action.connect("activate", cbc, typo)

            item = action.create_menu_item()

            if not clipboard_sel and idx == 2:
                item.set_sensitive(False)

            menu.append(item)

            idx += 1

        menu.popup(None, None, None, evt.button, evt.time, None)
        menu.show_all()
开发者ID:nopper,项目名称:packet-manipulator,代码行数:32,代码来源:pygtkhexview.py

示例8: create_ui

    def create_ui(self):
        self.output = AuditOutput()
        self.user_msg(_('<tt>New audit session started.</tt>'),
                      STATUS_INFO, 'AuditManager')

        iface1 = self.session.context.get_iface1()
        mac1   = self.session.context.get_mac1()
        ip1    = self.session.context.get_ip1()

        if iface1 and mac1 and ip1:
            self.user_msg('%s -> %s (%s)' % (iface1, ip1, mac1),
                          STATUS_INFO, 'AuditManager')
        elif iface1:
            self.user_msg(_('Error listening on %s') % iface1,
                          STATUS_ERR, 'AuditManager')

        iface2 = self.session.context.get_iface2()
        mac2   = self.session.context.get_mac2()
        ip2    = self.session.context.get_ip2()

        if iface2 and mac2 and ip2:
            self.user_msg('%s -> %s (%s)' % (iface2, ip2, mac2),
                          STATUS_INFO, 'AuditManager')
        elif iface2:
            self.user_msg(_('Error listening on %s') % iface2,
                          STATUS_ERR, 'AuditManager')

        self.pack_start(self.output)
        self.show_all()
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:29,代码来源:auditoutputpage.py

示例9: __on_skip_updates

    def __on_skip_updates(self, widget):
        "Called when the user click on the skip button"

        # We need to repopulate the tree
        self.richlist.clear()
        self.populate()

        self.p_window.toolbar.unset_status()

        if self.restart_btn.flags() & gtk.VISIBLE:
            # That callback is called from a self.___on_install_updates

            self.restart_btn.hide()
            self.p_window.animated_bar.label = \
                _('Rembember to restart PacketManipulator to use new version '
                  'of plugins.')

        else:
            self.p_window.animated_bar.label = \
                    _('Update skipped')

        self.p_window.animated_bar.start_animation(True)

        self.skip_install_btn.hide()
        self.install_updates_btn.hide()
        self.find_updates_btn.show()

        self.menu_enabled = True
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:28,代码来源:pluginpage.py

示例10: __init__

    def __init__(self, obj, type):
        """
        @param obj if type is TYPE_LOAD the path of the file to load or a
                   Session to save.
        @param type TYPE_LOAD or TYPE_SAVE
        """
        Operation.__init__(self)

        self.file = file
        self.type = type

        if type == FileOperation.TYPE_LOAD:
            self.file = obj
        else:
            self.session = obj
            self.ctx = self.session.context

        self.percentage = 0
        self.thread = None
        self.state = self.NOT_RUNNING
        self.loading_view = False

        if type == FileOperation.TYPE_LOAD:
            self.summary = _('Loading of %s pending.') % self.file
        else:
            self.summary = _('Saving to %s pending.') % self.ctx.cap_file
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:26,代码来源:operationstab.py

示例11: set_enabled

    def set_enabled(self, val):
        self._enabled = val

        # We need more testing on color/saturate on enabled

        if self._enabled:
            self.action_btn.set_label(_("Disable"))
            self.action_btn.set_image(self.img_stop)

            #
            color = self.style.text[gtk.STATE_NORMAL]
            self.saturate = False
        else:
            self.action_btn.set_label(_("Enable"))
            self.action_btn.set_image(self.img_play)

            #
            color = self.style.text[gtk.STATE_INSENSITIVE]
            self.saturate = True

        self.label.set_text( \
            "<span color=\"%s\">"
            "<span size=\"x-large\" weight=\"bold\">%s</span>" \
            "    %s" \
            "\n<tt>%s</tt>" \
            "</span>" % \
            ( \
                color.to_string(), \
                self._reader.name, \
                self._reader.version, \
                self._message \
            ) \
        )
        self.label.set_use_markup(True)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:34,代码来源:higrichlists.py

示例12: __send_callback

        def __send_callback(self, packet, udata):
            if packet and isinstance(packet, Exception):
                self.internal = False
                self.summary = str(packet)
            else:
                if packet:
                    self.count += 1
                else:
                    self.state = self.NOT_RUNNING

                if self.count == self.tot_count:
                    self.summary = _("%d packet(s) sent.") % self.tot_count
                else:
                    self.summary = _("Sending packet %d of %d") % (self.count, self.tot_count)

                self.percentage = float(self.count) / float(self.tot_count) * 100.0

            if self.callback:
                self.callback(packet, udata)

            if not self.internal:
                self.state = self.NOT_RUNNING

            return self.state == self.NOT_RUNNING or \
                   self.state == self.PAUSED
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:25,代码来源:send.py

示例13: __on_sort_layer

    def __on_sort_layer(self, item):
        lst = self.populate(False)

        dct = defaultdict(list)

        for proto in lst:
            dct[backend.get_proto_layer(proto)].append(proto)

        for i in xrange(1, 8, 1):
            if not i in dct:
                continue

            it = self.store.append(None, [self.layer_icon, _('Layer %d') % i,
                                          None])

            for proto in dct[i]:
                self.store.append(it, [self.proto_icon,
                                       backend.get_proto_class_name(proto),
                                       proto])

        if None in dct:
            it = self.store.append(None, [self.layer_icon, _('Unknown layer'),
                                          None])

            for proto in dct[None]:
                self.store.append(it, [self.proto_icon,
                                       backend.get_proto_class_name(proto),
                                       proto])

        self.tree.set_rules_hint(False)
        self.tree.set_model(self.store)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:31,代码来源:protocolselectortab.py

示例14: __property_cell_func

    def __property_cell_func(self, col, cell, model, iter):
        cell.editor, cell.field = None, None
        cell.set_property('editable', False)
        cell.set_property('text', '')

        obj = model.get_value(iter, 0)

        if isinstance(obj, TField) and backend.is_flags(obj.ref):
            # Flag container

            cell.set_property('cell-background-gdk',
                              self.style.mid[gtk.STATE_NORMAL])

            value = backend.get_field_value_repr(obj.proto, obj.ref)

            try:
                if value:
                    cell.set_property('markup', '<tt>%s</tt>' % \
                                  gobject.markup_escape_text(unicode(value)))
            except UnicodeDecodeError:
                cell.set_property('markup', _('<tt>N/A</tt>'))


        # If we are a field or a string (a sub field of flags)
        elif isinstance(obj, (TField, TFlag)):

            cell.field = None
            cell.set_property('editable', True)
            cell.set_property('cell-background-gdk', None)

            # We have a standard field

            if isinstance(obj, TField):
                value = backend.get_field_value(obj.proto, obj.ref)

                if value is not None:
                    try:
                        value = gobject.markup_escape_text(unicode(value))
                    except UnicodeDecodeError:
                        value = None

                if not value:
                    value = _("N/A")

                cell.set_property('markup', '<tt>%s</tt>' % value)
                cell.editor = get_editor(obj.ref)

                if cell.editor:
                    cell.field = (obj.proto, obj.ref)

            elif isinstance(obj, TFlag):
                # We have a subkey of Flags

                cell.editor = BitEditor
                cell.field = (obj.proto, obj.field.ref, obj.ref)
        else:
            cell.set_property('cell-background-gdk',
                              self.style.mid[gtk.STATE_NORMAL])
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:58,代码来源:propertygrid.py

示例15: load

        def load(self, operation=None):
            log.debug("Loading sequence from %s" % self.cap_file)

            if self.cap_file:
                self.seq = None

                try:
                    plen = 0
                    fsize = None

                    loader = load_sequence(self.cap_file)

                    for tree, tlen, perc, size in loader.parse_async():
                        if operation and tlen % 10 == 0 :

                            if not fsize:
                                if size >= 1024 ** 3:
                                    fsize = "%.1f GB" % (size / (1024.0 ** 3))
                                elif size >= 1024 ** 2:
                                    fsize = "%.1f MB" % (size / (1024.0 ** 2))
                                else:
                                    fsize = "%.1f KB" % (size / 1024.0)

                            operation.summary = \
                                _('Loading sequence %s - %d packets (%s)') % \
                                 (self.cap_file, tlen, fsize)
                            operation.percentage = perc

                        self.seq = tree
                        plen = tlen

                    self.tot_loop_count = loader.attr_loopcnt
                    self.inter = loader.attr_inter

                    self.strict = loader.attr_strict
                    self.report_sent = loader.attr_sent
                    self.report_recv = loader.attr_recv

                    self.title = self.cap_file
                    self.summary = \
                        _('Sequence %s loaded - %d packets (%s)') % \
                         (self.cap_file, plen, fsize)

                    if operation:
                        operation.summary = self.summary
                        operation.percentage = 100.0

                except Exception, err:
                    self.seq = None
                    self.summary = str(err)

                    if operation:
                        operation.summary = str(err)
                        operation.percentage = 100.0

                if self.seq is not None:
                    self.status = self.SAVED
                    return True
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:58,代码来源:sequence.py


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