[thorstenp] fix undefined variables

This commit is contained in:
Yann Leboulanger 2008-12-02 15:10:31 +00:00
parent e2118de64c
commit 7701f29beb
16 changed files with 40 additions and 31 deletions

View File

@ -46,8 +46,7 @@ from message_control import MessageControl
from conversation_textview import ConversationTextview from conversation_textview import ConversationTextview
from message_textview import MessageTextView from message_textview import MessageTextView
from common.contacts import GC_Contact from common.contacts import GC_Contact
from common.logger import Constants from common.logger import constants
constants = Constants()
from common.pep import MOODS, ACTIVITIES 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_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION
@ -2451,7 +2450,7 @@ class ChatControl(ChatControlBase):
pending_how_many, timeout, self.account) pending_how_many, timeout, self.account)
except exceptions.DatabaseMalformed: except exceptions.DatabaseMalformed:
dialogs.ErrorDialog(_('Database Error'), 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 = [] rows = []
local_old_kind = None local_old_kind = None
for row in rows: # row[0] time, row[1] has kind, row[2] the message for row in rows: # row[0] time, row[1] has kind, row[2] the message

View File

@ -144,7 +144,7 @@ class CapsCache(object):
# prepopulate data which we are sure of; note: we do not log these info # prepopulate data which we are sure of; note: we do not log these info
for account in gajim.connections: 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.identities = [gajim.gajim_identity]
gajimcaps.features = gajim.gajim_common_features + \ gajimcaps.features = gajim.gajim_common_features + \
gajim.gajim_optional_features[account] gajim.gajim_optional_features[account]

View File

@ -27,6 +27,7 @@ import os
import sys import sys
import stat import stat
import exceptions
from common import gajim from common import gajim
import logger import logger

View File

@ -31,6 +31,7 @@ from errno import EWOULDBLOCK
from errno import ENOBUFS from errno import ENOBUFS
from errno import EINTR from errno import EINTR
from errno import EISCONN from errno import EISCONN
from errno import EINPROGRESS
from xmpp.idlequeue import IdleObject from xmpp.idlequeue import IdleObject
MAX_BUFF_LEN = 65536 MAX_BUFF_LEN = 65536
@ -900,10 +901,10 @@ class Socks5Receiver(Socks5, IdleObject):
self._sock.setblocking(False) self._sock.setblocking(False)
self._server = ai[4] self._server = ai[4]
break break
except Exception: except socket.error, e:
if sys.exc_value[0] == errno.EINPROGRESS: if not isinstance(e, basestring) and e[0] == EINPROGRESS:
break break
#for all errors, we try other addresses # for all other errors, we try other addresses
continue continue
self.fd = self._sock.fileno() self.fd = self._sock.fileno()
self.state = 0 # about to be connected self.state = 0 # about to be connected

View File

@ -283,7 +283,7 @@ class EncryptedStanzaSession(StanzaSession):
return stanza return stanza
def is_xep_200_encrypted(self, msg): 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): def hmac(self, key, content):
return HMAC.new(key, content, self.hash_alg).digest() return HMAC.new(key, content, self.hash_alg).digest()

View File

@ -349,7 +349,7 @@ class NonBlockingNonSASL(PlugIn):
self.DEBUG('waiting on handshake', 'notify') self.DEBUG('waiting on handshake', 'notify')
return return
self._owner.onreceive(None) self._owner.onreceive(None)
owner._registered_name=self.user self._owner._registered_name=self.user
if self.handshake+1: if self.handshake+1:
return self.on_auth('ok') return self.on_auth('ok')
self.on_auth(None) self.on_auth(None)
@ -448,12 +448,14 @@ class NBComponentBind(ComponentBind):
def Bind(self, domain = None, on_bind = None): def Bind(self, domain = None, on_bind = None):
''' Perform binding. Use provided domain name (if not provided). ''' ''' 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 self.on_bind = on_bind
def _on_bound(self, resp): def _on_bound(self, resp, domain=None):
if data: if resp:
self.Dispatcher.ProcessNonBlocking(data) self.Dispatcher.ProcessNonBlocking(resp)
if self.bound is None: if self.bound is None:
return return
self._owner.onreceive(None) self._owner.onreceive(None)
@ -461,7 +463,7 @@ class NBComponentBind(ComponentBind):
Protocol('bind', attrs={'name':domain}, xmlns=NS_COMPONENT_1), Protocol('bind', attrs={'name':domain}, xmlns=NS_COMPONENT_1),
func=self._on_bind_reponse) func=self._on_bind_reponse)
def _on_bind_reponse(self, res): def _on_bind_reponse(self, resp):
if resp and resp.getAttr('error'): if resp and resp.getAttr('error'):
self.DEBUG('Binding failed: %s.' % resp.getAttr('error'), 'error') self.DEBUG('Binding failed: %s.' % resp.getAttr('error'), 'error')
elif resp: elif resp:

View File

@ -31,6 +31,7 @@ What it supplies:
A means of handling requests, by redirection though the command manager. A means of handling requests, by redirection though the command manager.
""" """
import math
from protocol import * from protocol import *
from client import PlugIn from client import PlugIn
@ -62,7 +63,7 @@ class Commands(PlugIn):
def plugout(self): def plugout(self):
"""Removes handlers from the session""" """Removes handlers from the session"""
# unPlug from the session and the disco manager # 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: for jid in self._handlers:
self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS) self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS)
@ -281,10 +282,10 @@ class TestCommand(Command_Handler_Prototype):
session = None session = None
if session is None: if session is None:
session = self.getSessionID() 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 # As this is the first stage we only send a form
reply = request.buildReply('result') 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] 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) reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload)
self._owner.send(reply) self._owner.send(reply)
@ -312,9 +313,9 @@ class TestCommand(Command_Handler_Prototype):
except Exception: except Exception:
self.cmdSecondStageReply(conn,request) self.cmdSecondStageReply(conn,request)
if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea': if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea':
result = num*(pi**2) result = num*(math.pi**2)
else: else:
result = num*2*pi result = num*2*math.pi
reply = result.buildReply(request) reply = result.buildReply(request)
form = DataForm(typ='result',data=[DataField(label='result',name='result',value=result)]) 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) reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=form)
@ -325,7 +326,7 @@ class TestCommand(Command_Handler_Prototype):
reply = request.buildReply('result') reply = request.buildReply('result')
reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'}) reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'})
self._owner.send(reply) self._owner.send(reply)
del sessions[request.getTagAttr('command','sessionid')] del self.sessions[request.getTagAttr('command','sessionid')]

View File

@ -24,6 +24,8 @@ writing the server.
__version__="$Id" __version__="$Id"
import random
import simplexml
from protocol import * from protocol import *
# Transport-level flags # Transport-level flags

View File

@ -139,10 +139,10 @@ class SSLWrapper:
can indicate that the socket has been closed, so to be sure, we avoid can indicate that the socket has been closed, so to be sure, we avoid
this by returning None. """ this by returning None. """
raise NotImplementedException() raise NotImplementedError()
def send(self, data, flags=None, now = False): def send(self, data, flags=None, now = False):
raise NotImplementedException() raise NotImplementedError()
class PyOpenSSLWrapper(SSLWrapper): class PyOpenSSLWrapper(SSLWrapper):
'''Wrapper class for PyOpenSSL's recv() and send() methods''' '''Wrapper class for PyOpenSSL's recv() and send() methods'''

View File

@ -251,7 +251,7 @@ class Zeroconf:
self.announced = False self.announced = False
return True return True
except pybonjour.BonjourError, e: except pybonjour.BonjourError, e:
geajim.log.debug(e) gajim.log.debug(e)
return False return False

View File

@ -57,6 +57,7 @@ from common import connection
from common import passwords from common import passwords
from common import zeroconf from common import zeroconf
from common import dataforms from common import dataforms
from common import GnuPG
from common.exceptions import GajimGeneralException from common.exceptions import GajimGeneralException

View File

@ -104,6 +104,6 @@ if os.name == 'nt' or not sys.stderr.isatty():
if __name__ == '__main__': if __name__ == '__main__':
_excepthook_save = sys.excepthook _excepthook_save = sys.excepthook
sys.excepthook = _info sys.excepthook = _info
print x # this always tracebacks raise Exception()
# vim: se ts=3: # vim: se ts=3:

View File

@ -1,3 +1,4 @@
import sys
from distutils.core import setup, Extension from distutils.core import setup, Extension
import commands import commands

View File

@ -327,7 +327,7 @@ class SignalObject(dbus.service.Object):
'''Shows the tabbed window for new message to 'jid', using account '''Shows the tabbed window for new message to 'jid', using account
(optional) 'account' ''' (optional) 'account' '''
if not jid: if not jid:
raise MissingArgument raise dbus_support.MissingArgument()
jid = self._get_real_jid(jid, account) jid = self._get_real_jid(jid, account)
try: try:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
@ -407,7 +407,7 @@ class SignalObject(dbus.service.Object):
if not isinstance(jid, unicode): if not isinstance(jid, unicode):
jid = unicode(jid) jid = unicode(jid)
if not jid: if not jid:
raise MissingArgument raise dbus_support.MissingArgument()
jid = self._get_real_jid(jid) jid = self._get_real_jid(jid)
cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid) cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid)

View File

@ -21,6 +21,7 @@
from common.configpaths import gajimpaths from common.configpaths import gajimpaths
import Crypto
from common import crypto from common import crypto
from common import exceptions from common import exceptions