Skip to content

Commit 9ad6e11

Browse files
ui,popups: fixed crash when using some languages
Closes: #1353.
1 parent c82dadd commit 9ad6e11

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

ui/opensnitch/dialogs/prompt/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ def _render_connection(self, con):
459459

460460
if self._local:
461461
try:
462-
uid = "%d (%s)" % (con.user_id, pwd.getpwuid(con.user_id).pw_name)
462+
uid = "{0} ({1})".format(con.user_id, pwd.getpwuid(con.user_id).pw_name)
463463
except:
464464
uid = ""
465465
else:
466-
uid = "%d" % con.user_id
466+
uid = "{0}".format(con.user_id)
467467

468468
self.uidLabel.setText(uid)
469469

ui/opensnitch/dialogs/prompt/_utils.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,42 @@ def get_popup_message(is_local, node, app_name, con):
3333
"""
3434
app_name = truncate_text(app_name)
3535

36-
message = "<b>%s</b>" % app_name
36+
message = "<b>{0}</b>".format(app_name)
3737
if not is_local:
38-
message = QC.translate("popups", "<b>Remote</b> process %s running on <b>%s</b>") % ( \
38+
message = QC.translate("popups", "<b>Remote</b> process {0} running on <b>{1}</b>".format(
3939
message,
4040
node.split(':')[1])
41+
)
4142

42-
msg_action = QC.translate("popups", "is connecting to <b>%s</b> on %s port %d") % ( \
43+
msg_action = QC.translate("popups", "is connecting to <b>{0}</b> on {1} port {2}".format(
4344
con.dst_host or con.dst_ip,
4445
con.protocol.upper(),
4546
con.dst_port )
47+
)
4648

4749
# icmp port is 0 (i.e.: no port)
4850
if con.dst_port == 0:
49-
msg_action = QC.translate("popups", "is connecting to <b>%s</b>, %s") % ( \
51+
msg_action = QC.translate("popups", "is connecting to <b>{0}</b>, {1}".format(
5052
con.dst_host or con.dst_ip,
5153
con.protocol.upper() )
54+
)
5255

5356
if con.dst_port == 53 and con.dst_ip != con.dst_host and con.dst_host != "":
54-
msg_action = QC.translate("popups", "is attempting to resolve <b>%s</b> via %s, %s port %d") % ( \
57+
msg_action = QC.translate("popups", "is attempting to resolve <b>{0}</b> via {1}, {2} port {3}".format(
5558
con.dst_host,
5659
con.dst_ip,
5760
con.protocol.upper(),
5861
con.dst_port)
62+
)
5963

60-
return "%s %s" % (message, msg_action)
64+
return "{0} {1}".format(message, msg_action)
6165

6266
def set_app_path(appPathLabel, app_name, app_args, con):
6367
# show the binary path if it's not part of the cmdline args:
6468
# cmdline: telnet 1.1.1.1 (path: /usr/bin/telnet.netkit)
6569
# cmdline: /usr/bin/telnet.netkit 1.1.1.1 (the binary path is part of the cmdline args, no need to display it)
6670
if con.process_path != "" and len(con.process_args) >= 1 and con.process_path not in con.process_args:
67-
appPathLabel.setToolTip("Process path: %s" % con.process_path)
71+
appPathLabel.setToolTip("Process path: {0}".format(con.process_path))
6872
if app_name.lower() == app_args:
6973
set_elide_text(appPathLabel, "%s" % con.process_path)
7074
else:
@@ -172,10 +176,10 @@ def get_combo_operator(data, comboText, con):
172176
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_PROCESS_ID, "{0}".format(con.process_id)
173177

174178
elif data == _constants.FIELD_USER_ID:
175-
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_USER_ID, "%s" % con.user_id
179+
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_USER_ID, "{0}".format(con.user_id)
176180

177181
elif data == _constants.FIELD_DST_PORT:
178-
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_DEST_PORT, "%s" % con.dst_port
182+
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_DEST_PORT, "{0}".format(con.dst_port)
179183

180184
elif data == _constants.FIELD_DST_IP:
181185
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_DEST_IP, con.dst_ip

0 commit comments

Comments
 (0)