From 7701f29beb6e0d1b01edb35b871710df1a729f09 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 2 Dec 2008 15:10:31 +0000 Subject: [PATCH] [thorstenp] fix undefined variables --- src/chat_control.py | 5 ++--- src/common/caps.py | 2 +- src/common/check_paths.py | 1 + src/common/socks5.py | 7 ++++--- src/common/stanza_session.py | 2 +- src/common/xmpp/auth_nb.py | 14 ++++++++------ src/common/xmpp/commands.py | 15 ++++++++------- src/common/xmpp/session.py | 2 ++ src/common/xmpp/transports_nb.py | 4 ++-- src/common/zeroconf/zeroconf.py | 6 +++--- src/common/zeroconf/zeroconf_bonjour.py | 2 +- src/config.py | 1 + src/gtkexcepthook.py | 2 +- src/osx/syncmenu/setup.py | 3 ++- src/remote_control.py | 4 ++-- src/secrets.py | 1 + 16 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 5c6989462..6c0976ea5 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -46,8 +46,7 @@ from message_control import MessageControl from conversation_textview import ConversationTextview from message_textview import MessageTextView from common.contacts import GC_Contact -from common.logger import Constants -constants = Constants() +from common.logger import constants from common.pep import MOODS, ACTIVITIES from common.xmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION @@ -2451,7 +2450,7 @@ class ChatControl(ChatControlBase): pending_how_many, timeout, self.account) except exceptions.DatabaseMalformed: dialogs.ErrorDialog(_('Database Error'), - _('The database file (%s) cannot be read. Try to repair it or remove it (all history will be lost).') % common.logger.LOG_DB_PATH) + _('The database file (%s) cannot be read. Try to repair it or remove it (all history will be lost).') % constants.LOG_DB_PATH) rows = [] local_old_kind = None for row in rows: # row[0] time, row[1] has kind, row[2] the message diff --git a/src/common/caps.py b/src/common/caps.py index 358645e76..d4ef634d0 100644 --- a/src/common/caps.py +++ b/src/common/caps.py @@ -144,7 +144,7 @@ class CapsCache(object): # prepopulate data which we are sure of; note: we do not log these info for account in gajim.connections: - gajimcaps = self[('sha-1', gajim.caps_hash[accout])] + gajimcaps = self[('sha-1', gajim.caps_hash[account])] gajimcaps.identities = [gajim.gajim_identity] gajimcaps.features = gajim.gajim_common_features + \ gajim.gajim_optional_features[account] diff --git a/src/common/check_paths.py b/src/common/check_paths.py index 4edca5d7f..7ddf6c735 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -27,6 +27,7 @@ import os import sys import stat +import exceptions from common import gajim import logger diff --git a/src/common/socks5.py b/src/common/socks5.py index 1523982e6..1680bf653 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -31,6 +31,7 @@ from errno import EWOULDBLOCK from errno import ENOBUFS from errno import EINTR from errno import EISCONN +from errno import EINPROGRESS from xmpp.idlequeue import IdleObject MAX_BUFF_LEN = 65536 @@ -900,10 +901,10 @@ class Socks5Receiver(Socks5, IdleObject): self._sock.setblocking(False) self._server = ai[4] break - except Exception: - if sys.exc_value[0] == errno.EINPROGRESS: + except socket.error, e: + if not isinstance(e, basestring) and e[0] == EINPROGRESS: break - #for all errors, we try other addresses + # for all other errors, we try other addresses continue self.fd = self._sock.fileno() self.state = 0 # about to be connected diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index cb1d7fb7f..dad5ac584 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -283,7 +283,7 @@ class EncryptedStanzaSession(StanzaSession): return stanza def is_xep_200_encrypted(self, msg): - msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO) + msg.getTag('c', namespace=xmpp.NS_STANZA_CRYPTO) def hmac(self, key, content): return HMAC.new(key, content, self.hash_alg).digest() diff --git a/src/common/xmpp/auth_nb.py b/src/common/xmpp/auth_nb.py index 672c6b82d..f53858a1a 100644 --- a/src/common/xmpp/auth_nb.py +++ b/src/common/xmpp/auth_nb.py @@ -349,7 +349,7 @@ class NonBlockingNonSASL(PlugIn): self.DEBUG('waiting on handshake', 'notify') return self._owner.onreceive(None) - owner._registered_name=self.user + self._owner._registered_name=self.user if self.handshake+1: return self.on_auth('ok') self.on_auth(None) @@ -448,12 +448,14 @@ class NBComponentBind(ComponentBind): def Bind(self, domain = None, on_bind = None): ''' Perform binding. Use provided domain name (if not provided). ''' - self._owner.onreceive(self._on_bound) + def wrapper(resp): + self._on_bound(resp, domain) + self._owner.onreceive(wrapper) self.on_bind = on_bind - def _on_bound(self, resp): - if data: - self.Dispatcher.ProcessNonBlocking(data) + def _on_bound(self, resp, domain=None): + if resp: + self.Dispatcher.ProcessNonBlocking(resp) if self.bound is None: return self._owner.onreceive(None) @@ -461,7 +463,7 @@ class NBComponentBind(ComponentBind): Protocol('bind', attrs={'name':domain}, xmlns=NS_COMPONENT_1), func=self._on_bind_reponse) - def _on_bind_reponse(self, res): + def _on_bind_reponse(self, resp): if resp and resp.getAttr('error'): self.DEBUG('Binding failed: %s.' % resp.getAttr('error'), 'error') elif resp: diff --git a/src/common/xmpp/commands.py b/src/common/xmpp/commands.py index 6e6d3e92e..ed4785e65 100644 --- a/src/common/xmpp/commands.py +++ b/src/common/xmpp/commands.py @@ -31,6 +31,7 @@ What it supplies: A means of handling requests, by redirection though the command manager. """ +import math from protocol import * from client import PlugIn @@ -62,7 +63,7 @@ class Commands(PlugIn): def plugout(self): """Removes handlers from the session""" # unPlug from the session and the disco manager - self._owner.UnregisterHandler('iq',self_CommandHandler,ns=NS_COMMANDS) + self._owner.UnregisterHandler('iq',self._CommandHandler,ns=NS_COMMANDS) for jid in self._handlers: self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS) @@ -281,10 +282,10 @@ class TestCommand(Command_Handler_Prototype): session = None if session is None: session = self.getSessionID() - sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}} + self.sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}} # As this is the first stage we only send a form reply = request.buildReply('result') - form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)]) + form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=self.sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)]) replypayload = [Node('actions',attrs={'execute':'next'},payload=[Node('next')]),form] reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload) self._owner.send(reply) @@ -312,9 +313,9 @@ class TestCommand(Command_Handler_Prototype): except Exception: self.cmdSecondStageReply(conn,request) if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea': - result = num*(pi**2) + result = num*(math.pi**2) else: - result = num*2*pi + result = num*2*math.pi reply = result.buildReply(request) form = DataForm(typ='result',data=[DataField(label='result',name='result',value=result)]) reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=form) @@ -325,8 +326,8 @@ class TestCommand(Command_Handler_Prototype): reply = request.buildReply('result') reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'}) self._owner.send(reply) - del sessions[request.getTagAttr('command','sessionid')] + del self.sessions[request.getTagAttr('command','sessionid')] -# vim: se ts=3: \ No newline at end of file +# vim: se ts=3: diff --git a/src/common/xmpp/session.py b/src/common/xmpp/session.py index dc7b5f677..256de1795 100644 --- a/src/common/xmpp/session.py +++ b/src/common/xmpp/session.py @@ -24,6 +24,8 @@ writing the server. __version__="$Id" +import random +import simplexml from protocol import * # Transport-level flags diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index aac93eeff..48166a4d6 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -139,10 +139,10 @@ class SSLWrapper: can indicate that the socket has been closed, so to be sure, we avoid this by returning None. """ - raise NotImplementedException() + raise NotImplementedError() def send(self, data, flags=None, now = False): - raise NotImplementedException() + raise NotImplementedError() class PyOpenSSLWrapper(SSLWrapper): '''Wrapper class for PyOpenSSL's recv() and send() methods''' diff --git a/src/common/zeroconf/zeroconf.py b/src/common/zeroconf/zeroconf.py index 6b7c08783..a99f0390d 100644 --- a/src/common/zeroconf/zeroconf.py +++ b/src/common/zeroconf/zeroconf.py @@ -31,8 +31,8 @@ def test_bonjour(): try: import pybonjour except ImportError: - return False - except WindowsError: + return False + except WindowsError: return False return True @@ -46,4 +46,4 @@ elif test_bonjour(): from common.zeroconf import zeroconf_bonjour Zeroconf = zeroconf_bonjour.Zeroconf -# vim: se ts=3: \ No newline at end of file +# vim: se ts=3: diff --git a/src/common/zeroconf/zeroconf_bonjour.py b/src/common/zeroconf/zeroconf_bonjour.py index fb8eba701..80c985215 100644 --- a/src/common/zeroconf/zeroconf_bonjour.py +++ b/src/common/zeroconf/zeroconf_bonjour.py @@ -251,7 +251,7 @@ class Zeroconf: self.announced = False return True except pybonjour.BonjourError, e: - geajim.log.debug(e) + gajim.log.debug(e) return False diff --git a/src/config.py b/src/config.py index 50bbdbaab..68baa884e 100644 --- a/src/config.py +++ b/src/config.py @@ -57,6 +57,7 @@ from common import connection from common import passwords from common import zeroconf from common import dataforms +from common import GnuPG from common.exceptions import GajimGeneralException diff --git a/src/gtkexcepthook.py b/src/gtkexcepthook.py index 4719f520d..e75793251 100644 --- a/src/gtkexcepthook.py +++ b/src/gtkexcepthook.py @@ -104,6 +104,6 @@ if os.name == 'nt' or not sys.stderr.isatty(): if __name__ == '__main__': _excepthook_save = sys.excepthook sys.excepthook = _info - print x # this always tracebacks + raise Exception() # vim: se ts=3: diff --git a/src/osx/syncmenu/setup.py b/src/osx/syncmenu/setup.py index 3e0fc6561..bac7572f0 100644 --- a/src/osx/syncmenu/setup.py +++ b/src/osx/syncmenu/setup.py @@ -1,3 +1,4 @@ +import sys from distutils.core import setup, Extension import commands @@ -26,4 +27,4 @@ setup(name='syncmenu', version='0.2', extra_compile_args=['-Wall'] + cflags) ]) -# vim: se ts=3: \ No newline at end of file +# vim: se ts=3: diff --git a/src/remote_control.py b/src/remote_control.py index ec7054a93..1af7b7615 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -327,7 +327,7 @@ class SignalObject(dbus.service.Object): '''Shows the tabbed window for new message to 'jid', using account (optional) 'account' ''' if not jid: - raise MissingArgument + raise dbus_support.MissingArgument() jid = self._get_real_jid(jid, account) try: jid = helpers.parse_jid(jid) @@ -407,7 +407,7 @@ class SignalObject(dbus.service.Object): if not isinstance(jid, unicode): jid = unicode(jid) if not jid: - raise MissingArgument + raise dbus_support.MissingArgument() jid = self._get_real_jid(jid) cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid) diff --git a/src/secrets.py b/src/secrets.py index 28a9fb916..d258bc660 100644 --- a/src/secrets.py +++ b/src/secrets.py @@ -21,6 +21,7 @@ from common.configpaths import gajimpaths +import Crypto from common import crypto from common import exceptions