introduce GajimGeneralException and use that instead of RunTimeError when raising so instances are not created. This is better because python can also raise RunTimeError, which we will catch by accident and we do not want that to happen
This commit is contained in:
parent
8dfb1a5a66
commit
01e3fc1199
6 changed files with 30 additions and 19 deletions
|
@ -1,11 +1,7 @@
|
|||
## exceptions.py
|
||||
##
|
||||
## Contributors for this file:
|
||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
||||
## -
|
||||
##
|
||||
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
|
@ -48,3 +44,12 @@ class SessionBusNotPresent(Exception):
|
|||
|
||||
def __str__(self):
|
||||
return _('Session bus is not available.\nTry reading http://trac.gajim.org/wiki/GajimDBus')
|
||||
|
||||
class GajimGeneralException(Exception):
|
||||
'''This exception ir our general exception'''
|
||||
def __init__(self, text=''):
|
||||
Exception.__init__(self)
|
||||
self.text
|
||||
|
||||
def __str__(self):
|
||||
return self.text
|
||||
|
|
|
@ -39,6 +39,8 @@ from common import gajim
|
|||
from common import connection
|
||||
from common import passwords
|
||||
|
||||
from common.exceptions import GajimGeneralException as GajimGeneralException
|
||||
|
||||
#---------- PreferencesWindow class -------------#
|
||||
class PreferencesWindow:
|
||||
'''Class for Preferences window'''
|
||||
|
@ -1506,7 +1508,7 @@ class AccountModificationWindow:
|
|||
def on_change_password_button_clicked(self, widget):
|
||||
try:
|
||||
dialog = dialogs.ChangePasswordDialog(self.account)
|
||||
except RuntimeError:
|
||||
except GajimGeneralException:
|
||||
#if we showed ErrorDialog, there will not be dialog instance
|
||||
return
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ from advanced import AdvancedConfigurationWindow
|
|||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common.exceptions import GajimGeneralException as GajimGeneralException
|
||||
|
||||
class EditGroupsDialog:
|
||||
'''Class for the edit group dialog window'''
|
||||
|
@ -1089,7 +1090,7 @@ class JoinGroupchatWindow:
|
|||
if room_jid in gajim.gc_connected[account] and\
|
||||
gajim.gc_connected[account][room_jid]:
|
||||
ErrorDialog(_('You are already in room %s') % room_jid)
|
||||
raise RuntimeError, 'You are already in this room'
|
||||
raise GajimGeneralException, 'You are already in this room'
|
||||
self.account = account
|
||||
self.automatic = automatic
|
||||
if nick == '':
|
||||
|
@ -1097,7 +1098,7 @@ class JoinGroupchatWindow:
|
|||
if gajim.connections[account].connected < 2:
|
||||
ErrorDialog(_('You are not connected to the server'),
|
||||
_('You can not join a group chat unless you are connected.'))
|
||||
raise RuntimeError, 'You must be connected to join a groupchat'
|
||||
raise GajimGeneralException, 'You must be connected to join a groupchat'
|
||||
|
||||
self._empty_required_widgets = []
|
||||
|
||||
|
@ -1255,7 +1256,7 @@ class ChangePasswordDialog:
|
|||
if not account or gajim.connections[account].connected < 2:
|
||||
ErrorDialog(_('You are not connected to the server'),
|
||||
_('Without a connection, you can not change your password.'))
|
||||
raise RuntimeError, 'You are not connected to the server'
|
||||
raise GajimGeneralException, 'You are not connected to the server'
|
||||
self.account = account
|
||||
self.xml = gtkgui_helpers.get_glade('change_password_dialog.glade')
|
||||
self.dialog = self.xml.get_widget('change_password_dialog')
|
||||
|
|
|
@ -49,6 +49,7 @@ import gtkgui_helpers
|
|||
|
||||
from common import gajim
|
||||
from common import xmpp
|
||||
from common.exceptions import GajimGeneralException as GajimGeneralException
|
||||
|
||||
# Dictionary mapping category, type pairs to browser class, image pairs.
|
||||
# This is a function, so we can call it after the classes are declared.
|
||||
|
@ -1194,7 +1195,7 @@ class ToplevelAgentBrowser(AgentBrowser):
|
|||
if not gajim.interface.instances[self.account].has_key('join_gc'):
|
||||
try:
|
||||
dialogs.JoinGroupchatWindow(self.account, service)
|
||||
except RuntimeError:
|
||||
except GajimGeneralException:
|
||||
pass
|
||||
else:
|
||||
gajim.interface.instances[self.account]['join_gc'].window.present()
|
||||
|
|
|
@ -43,9 +43,9 @@ from conversation_textview import ConversationTextview
|
|||
#(status_image, type, nick, shown_nick)
|
||||
(
|
||||
C_IMG, # image to show state (online, new message etc)
|
||||
C_TEXT, # type of the row ('contact' or 'group')
|
||||
C_TYPE, # text shown in the cellrenderer
|
||||
C_NICK, # contact nickame or group name
|
||||
C_NICK, # contact nickame or ROLE name
|
||||
C_TYPE, # type of the row ('contact' or 'role')
|
||||
C_TEXT, # text shown in the cellrenderer
|
||||
C_AVATAR, # avatar of the contact
|
||||
) = range(5)
|
||||
|
||||
|
@ -913,9 +913,9 @@ class GroupchatControl(ChatControlBase):
|
|||
role_iter = self.get_role_iter(role)
|
||||
if not role_iter:
|
||||
role_iter = model.append(None,
|
||||
(gajim.interface.roster.jabber_state_images['16']['closed'], 'role',
|
||||
role, '<b>%s</b>' % role_name, None))
|
||||
iter = model.append(role_iter, (None, 'contact', nick, name, None))
|
||||
(gajim.interface.roster.jabber_state_images['16']['closed'], role,
|
||||
'role', '<b>%s</b>' % role_name, None))
|
||||
iter = model.append(role_iter, (None, nick, 'contact', name, None))
|
||||
if not nick in gajim.contacts.get_nick_list(self.account, self.room_jid):
|
||||
gc_contact = gajim.contacts.create_gc_contact(room_jid = self.room_jid,
|
||||
name = nick, show = show, status = status, role = role,
|
||||
|
|
|
@ -36,6 +36,8 @@ import notify
|
|||
from common import gajim
|
||||
from common import helpers
|
||||
from common import passwords
|
||||
from common.exceptions import GajimGeneralException as GajimGeneralException
|
||||
|
||||
from message_window import MessageWindowMgr
|
||||
from chat_control import ChatControl
|
||||
from groupchat_control import GroupchatControl
|
||||
|
@ -1574,7 +1576,7 @@ class RosterWindow:
|
|||
dialogs.JoinGroupchatWindow(account,
|
||||
gajim.connections[account].muc_jid[type_],
|
||||
automatic = {'invities': jid_list})
|
||||
except RuntimeError:
|
||||
except GajimGeneralException:
|
||||
continue
|
||||
break
|
||||
|
||||
|
@ -2669,7 +2671,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
|||
try:
|
||||
gajim.interface.instances[account]['join_gc'] = \
|
||||
dialogs.JoinGroupchatWindow(account)
|
||||
except RuntimeError:
|
||||
except GajimGeneralException:
|
||||
pass
|
||||
|
||||
def on_new_message_menuitem_activate(self, widget, account):
|
||||
|
@ -3108,7 +3110,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
|||
try:
|
||||
# Object will add itself to the window dict
|
||||
disco.ServiceDiscoveryWindow(account, address_entry = True)
|
||||
except RuntimeError:
|
||||
except GajimGeneralException:
|
||||
pass
|
||||
|
||||
def load_iconset(self, path, pixbuf2 = None, transport = False):
|
||||
|
|
Loading…
Add table
Reference in a new issue