fix a few warnings

This commit is contained in:
Yann Leboulanger 2015-07-18 17:27:50 +02:00
parent a6c0a14e2f
commit 685c5730e1
6 changed files with 22 additions and 20 deletions

View file

@ -83,6 +83,7 @@ def load_cert_file(cert_path, cert_store=None):
OpenSSL.crypto.FILETYPE_PEM, cert) OpenSSL.crypto.FILETYPE_PEM, cert)
if cert_store: if cert_store:
cert_store.add_cert(x509cert) cert_store.add_cert(x509cert)
f.close()
return x509cert return x509cert
except OpenSSL.crypto.Error as exception_obj: except OpenSSL.crypto.Error as exception_obj:
log.warning('Unable to load a certificate from file %s: %s' %\ log.warning('Unable to load a certificate from file %s: %s' %\
@ -119,14 +120,14 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None):
dh_params_name = os.path.join(gajim.MY_CERT_DIR, DH_PARAMS) dh_params_name = os.path.join(gajim.MY_CERT_DIR, DH_PARAMS)
try: try:
with open(dh_params_name, "r") as dh_params_file: with open(dh_params_name, "r") as dh_params_file:
ctx.load_tmp_dh(str(dh_params_name).encode('utf-8')) ctx.load_tmp_dh(str(dh_params_name))
except IOError as err: except FileNotFoundError as err:
default_dh_params_name = os.path.join(common.gajim.DATA_DIR, default_dh_params_name = os.path.join(gajim.DATA_DIR,
'other', DEFAULT_DH_PARAMS) 'other', DEFAULT_DH_PARAMS)
try: try:
with open(default_dh_params_name, "r") as default_dh_params_file: with open(default_dh_params_name, "r") as default_dh_params_file:
ctx.load_tmp_dh(str(default_dh_params_name).encode('utf-8')) ctx.load_tmp_dh(str(default_dh_params_name))
except IOError as err: except FileNotFoundError as err:
log.error('Unable to load default DH parameter file: %s , %s' log.error('Unable to load default DH parameter file: %s , %s'
% (default_dh_params_name, err)) % (default_dh_params_name, err))
raise raise

View file

@ -384,7 +384,7 @@ class ChangeActivityDialog:
else: else:
rbtns[act] = group = Gtk.RadioButton() rbtns[act] = group = Gtk.RadioButton()
hbox = Gtk.HBox(False, 5) hbox = Gtk.HBox(homogeneous=False, spacing=5)
hbox.pack_start(gtkgui_helpers.load_activity_icon(category, hbox.pack_start(gtkgui_helpers.load_activity_icon(category,
activity), False, False, 0) activity), False, False, 0)
lbl = Gtk.Label(label='<b>' + pep.ACTIVITIES[category]['category'] \ lbl = Gtk.Label(label='<b>' + pep.ACTIVITIES[category]['category'] \
@ -412,7 +412,7 @@ class ChangeActivityDialog:
else: else:
rbtns[act] = group = Gtk.RadioButton() rbtns[act] = group = Gtk.RadioButton()
hbox = Gtk.HBox(False, 5) hbox = Gtk.HBox(homogeneous=False, spacing=5)
hbox.pack_start(gtkgui_helpers.load_activity_icon(category, hbox.pack_start(gtkgui_helpers.load_activity_icon(category,
activity), False, False, 0) activity), False, False, 0)
hbox.pack_start(Gtk.Label(pep.ACTIVITIES[category][activity]), hbox.pack_start(Gtk.Label(pep.ACTIVITIES[category][activity]),

View file

@ -325,8 +325,8 @@ class FileTransfersWindow:
dialog.add_action_widget(btn, Gtk.ResponseType.OK) dialog.add_action_widget(btn, Gtk.ResponseType.OK)
dialog.set_default_response(Gtk.ResponseType.OK) dialog.set_default_response(Gtk.ResponseType.OK)
desc_hbox = Gtk.HBox(False, 5) desc_hbox = Gtk.HBox(homogeneous=False, spacing=5)
desc_hbox.pack_start(Gtk.Label(_('Description: ')), False, False, 0) desc_hbox.pack_start(Gtk.Label.new(_('Description: ')), False, False, 0)
desc_hbox.pack_start(win, True, True, 0) desc_hbox.pack_start(win, True, True, 0)
dialog.vbox.pack_start(desc_hbox, False, False, 0) dialog.vbox.pack_start(desc_hbox, False, False, 0)
@ -474,8 +474,7 @@ class FileTransfersWindow:
def get_icon(self, ident): def get_icon(self, ident):
return self.images.setdefault(ident, return self.images.setdefault(ident,
self.window.render_icon_pixbuf(self.icons[ident], gtkgui_helpers.get_icon_pixmap(self.icons[ident], 24))
Gtk.IconSize.MENU))
def set_status(self,file_props, status): def set_status(self,file_props, status):
""" """

View file

@ -1523,8 +1523,8 @@ class GroupchatControl(ChatControlBase):
# escape markup entities and make them small italic and fg color # escape markup entities and make them small italic and fg color
color = gtkgui_helpers.get_fade_color(self.list_treeview, color = gtkgui_helpers.get_fade_color(self.list_treeview,
selected, focus) selected, focus)
colorstring = "#%04x%04x%04x" % (color.red, color.green, colorstring = "#%04x%04x%04x" % (int(color.red * 65535),
color.blue) int(color.green * 65535), int(color.blue * 65535))
name += ('\n<span size="small" style="italic" foreground="%s">' name += ('\n<span size="small" style="italic" foreground="%s">'
'%s</span>') % (colorstring, GLib.markup_escape_text( '%s</span>') % (colorstring, GLib.markup_escape_text(
status)) status))

View file

@ -261,9 +261,10 @@ class RosterWindow:
tls_pixbuf = None tls_pixbuf = None
if gajim.account_is_securely_connected(account): if gajim.account_is_securely_connected(account):
tls_pixbuf = gtkgui_helpers.get_icon_pixmap('gtk-dialog-authentication', 24)
# the only way to create a pixbuf from stock # the only way to create a pixbuf from stock
tls_pixbuf = self.window.render_icon_pixbuf( # tls_pixbuf = self.window.render_icon_pixbuf(
Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU) # Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU)
it = self.model.append(None, [ it = self.model.append(None, [
gajim.interface.jabber_state_images['16'][show], gajim.interface.jabber_state_images['16'][show],
@ -1041,9 +1042,10 @@ class RosterWindow:
if gajim.account_is_securely_connected(account) and not self.regroup or\ if gajim.account_is_securely_connected(account) and not self.regroup or\
self.regroup and num_of_secured and num_of_secured == num_of_accounts: self.regroup and num_of_secured and num_of_secured == num_of_accounts:
tls_pixbuf = gtkgui_helpers.get_icon_pixmap('gtk-dialog-authentication', 24)
# the only way to create a pixbuf from stock # the only way to create a pixbuf from stock
tls_pixbuf = self.window.render_icon_pixbuf( # tls_pixbuf = self.window.render_icon_pixbuf(
Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU) # Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU)
self.model[child_iter][C_PADLOCK_PIXBUF] = tls_pixbuf self.model[child_iter][C_PADLOCK_PIXBUF] = tls_pixbuf
else: else:
self.model[child_iter][C_PADLOCK_PIXBUF] = empty_pixbuf self.model[child_iter][C_PADLOCK_PIXBUF] = empty_pixbuf
@ -1226,8 +1228,8 @@ class RosterWindow:
# always readable # always readable
color = gtkgui_helpers.get_fade_color(self.tree, selected, color = gtkgui_helpers.get_fade_color(self.tree, selected,
focus) focus)
colorstring = '#%04x%04x%04x' % (color.red, color.green, colorstring = '#%04x%04x%04x' % (int(color.red * 65535),
color.blue) int(color.green * 65535), int(color.blue * 65535))
name += '\n<span size="small" style="italic" ' \ name += '\n<span size="small" style="italic" ' \
'foreground="%s">%s</span>' % (colorstring, 'foreground="%s">%s</span>' % (colorstring,
GLib.markup_escape_text(status)) GLib.markup_escape_text(status))

View file

@ -86,7 +86,7 @@ class BaseTooltip:
""" """
Create a popup window each time tooltip is requested Create a popup window each time tooltip is requested
""" """
self.win = Gtk.Window(Gtk.WindowType.POPUP) self.win = Gtk.Window.new(Gtk.WindowType.POPUP)
self.win.set_title('tooltip') self.win.set_title('tooltip')
self.win.set_border_width(3) self.win.set_border_width(3)
self.win.set_resizable(False) self.win.set_resizable(False)