本文整理汇总了Python中umit.pm.core.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: create_ui
def create_ui(self):
self.hbox = gtk.HBox(False, 2)
# Create the toolbar for sending selected packet
self.toolbar = gtk.Toolbar()
self.toolbar.set_style(gtk.TOOLBAR_ICONS)
self.toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
stocks = (
gtk.STOCK_EDIT,
gtk.STOCK_DELETE,
gtk.STOCK_CLEAR,
gtk.STOCK_SELECT_COLOR
)
tooltips = (
_('Complete layers'),
_('Remove selected layer'),
_('Reset layer to default'),
_('Graph packet')
)
callbacks = (
self.__on_complete,
self.__on_remove,
self.__on_reset,
self.__on_graph
)
for tooltip, stock, callback in zip(tooltips, stocks, callbacks):
action = gtk.Action(None, None, tooltip, stock)
action.connect('activate', callback)
self.toolbar.insert(action.create_tool_item(), -1)
self.proto_hierarchy = ProtocolHierarchy(self.session)
self.hexview = HexView()
try:
# Only the read write hexview provide this
self.hexview.set_insert_mode(True)
self.hexview.set_read_only_mode(False)
self.hexview.changed_callback = self.__on_hexview_changed
self.hexview.connect('focus-out-event', self.__on_hexview_focus_out)
self._packet_changed = False
except:
pass
self.hbox.pack_start(self.proto_hierarchy, False, False, 0)
self.hbox.pack_start(self.toolbar, False, False)
self.hbox.pack_start(self.hexview)#, False, False)
Prefs()['gui.maintab.hexview.font'].connect(self.hexview.modify_font)
Prefs()['gui.maintab.hexview.bpl'].connect(self.hexview.set_bpl)
self.pack_start(self.hbox)
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:57,代码来源:packetpage.py
示例17: __on_open_session
def __on_open_session(self, action):
types = {}
sessions = (backend.StaticContext,
backend.SequenceContext,
backend.SniffContext)
for ctx in sessions:
for name, pattern in ctx.file_types:
types[pattern] = (name, ctx)
dialog = gtk.FileChooserDialog(_("Select a session"), self,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
dialog.set_transient_for(self)
filterall = gtk.FileFilter()
filterall.set_name(_('All supported files'))
[filterall.add_pattern(k) for k in types]
dialog.add_filter(filterall)
for pattern, (name, ctx) in types.items():
filter = gtk.FileFilter()
filter.set_name(name)
filter.add_pattern(pattern)
dialog.add_filter(filter)
if dialog.run() == gtk.RESPONSE_ACCEPT:
ctx = None
fname = dialog.get_filename()
try:
find = fname.split('.')[-1]
for pattern in types:
if pattern.split('.')[-1] == find:
ctx = types[pattern][1]
except:
pass
if ctx is not backend.SequenceContext and \
ctx is not backend.SniffContext and \
ctx is not backend.StaticContext:
d = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
message_format=_("Unable to open selected session"),
secondary_text=_("PacketManipulator is unable to guess the "
"file type. Try to modify the extension "
"and to reopen the file."))
d.set_transient_for(self)
d.run()
d.destroy()
else:
self.open_generic_file_async(fname)
dialog.hide()
dialog.destroy()
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:56,代码来源:mainwindow.py
示例18: __thread_main
def __thread_main(self):
try:
log.debug('Entered in __thread_main')
packets = 0
probes = self.probes
while probes != 0 and self.internal:
pkt = MetaPacket.new('ip') / MetaPacket.new('tcp')
if self.sip is True:
sip = random_ip()
elif self.sip != '0.0.0.0':
sip = self.sip
if self.sport is True:
sport = randint(1, 65535)
else:
sport = self.sport
pkt.set_fields('ip', {
'dst' : self.dip,
'src' : sip})
pkt.set_fields('tcp', {
'sport' : sport,
'dport' : self.dport,
'flags' : TH_SYN,
'seq' : randint(0, 2L**32-1)})
self.context.si_l3(pkt)
sleep(self.delay)
probes -= 1
packets += 1
if self.probes > 0:
self.summary = AUDIT_MSG % _('%d of %d sent' \
% (packets, self.probes))
self.percentage = (packets / float(self.probes)) * 100.0
else:
self.summary = AUDIT_MSG % _('%d sent' % packets)
self.percentage = (self.percentage + 536870911) % \
gobject.G_MAXINT
if self.internal:
self.summary = AUDIT_MSG % _('Finished with %d sent' % packets)
self.internal = False
else:
self.summary = AUDIT_MSG % _('stopped')
self.percentage = 100.0
self.state = self.NOT_RUNNING
except Exception, err:
log.error(generate_traceback())
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:56,代码来源:main.py
示例19: __init__
def __init__(self, args):
"""
PacketManipulator Application class
@param args pass sys.argv
"""
gobject.threads_init()
self._args = args
root = False
try:
# FIXME: add maemo
if sys.platform == 'win32':
import ctypes
root = bool(ctypes.windll.shell32.IsUserAnAdmin())
elif os.getuid() == 0:
root = True
except: pass
if Prefs()['system.check_pyver'].value == True and \
sys.version_info[1] < 6:
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_WARNING,
gtk.BUTTONS_YES_NO,
_('Packet Manipulator requires at least '
'2.6 version of Python but you\'ve %s '
'installed. We not guarantee that all '
'functionalities works properly.\n\n'
'Do you want to continue?') % ".".join(
map(str, sys.version_info[:3])))
ret = dialog.run()
dialog.hide()
dialog.destroy()
if ret == gtk.RESPONSE_NO:
sys.exit(-1)
if Prefs()['system.check_root'].value == True and not root:
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_WARNING,
gtk.BUTTONS_YES_NO,
_('You are running Packet Manipulator as'
' non-root user!\nSome functionalities'
' need root privileges to work\n\nDo '
'you want to continue?'))
ret = dialog.run()
dialog.hide()
dialog.destroy()
if ret == gtk.RESPONSE_NO:
sys.exit(-1)
self.phase = 0
self.splash = SplashScreen()
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:55,代码来源:app.py
示例20: start
def start(self):
if self.state == self.RUNNING:
return
self.state = self.RUNNING
if self.type == FileOperation.TYPE_LOAD:
self.summary = _('Loading %s') % self.file
self._read_file()
else:
self.summary = _('Saving to %s') % self.ctx.cap_file
self._save_file()
开发者ID:Paulxia,项目名称:PacketManipulator,代码行数:12,代码来源:operationstab.py
注:本文中的umit.pm.core.i18n._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论