Fix logging-not-lazy pylint errors

This commit is contained in:
Philipp Hörist 2018-09-17 18:57:00 +02:00 committed by Philipp Hörist
parent 7674450cc6
commit 6305fc69b9
21 changed files with 156 additions and 153 deletions

View File

@ -1094,7 +1094,7 @@ class Connection(CommonConnection, ConnectionHandlers):
conn=self, title=pritxt, msg=sectxt))
def on_proxy_failure(self, reason):
log.error('Connection to proxy failed: %s' % reason)
log.error('Connection to proxy failed: %s', reason)
self.time_to_reconnect = None
self.on_connect_failure = None
self.disconnect(on_purpose = True)
@ -1108,8 +1108,8 @@ class Connection(CommonConnection, ConnectionHandlers):
log.info('Connect successfull')
_con_type = con_type
if _con_type != self._current_type:
log.info('Connecting to next host beacuse desired type is %s and returned is %s'
% (self._current_type, _con_type))
log.info('Connecting to next host beacuse desired type '
'is %s and returned is %s', self._current_type, _con_type)
self._connect_to_next_host()
return
con.RegisterDisconnectHandler(self._on_disconnected)
@ -1149,8 +1149,9 @@ class Connection(CommonConnection, ConnectionHandlers):
self.on_connect_failure = None
con.UnregisterDisconnectHandler(self._on_disconnected)
con.RegisterDisconnectHandler(self.disconnectedReconnCB)
log.debug('Connected to server %s:%s with %s' % (
self._current_host['host'], self._current_host['port'], con_type))
log.debug('Connected to server %s:%s with %s',
self._current_host['host'], self._current_host['port'],
con_type)
self.connection = con
@ -1222,7 +1223,7 @@ class Connection(CommonConnection, ConnectionHandlers):
file = urlopen(
url, cafile=cafile, timeout=2)
except (URLError, ssl.CertificateError) as exc:
log.info('Error while requesting POSH: %s' % exc)
log.info('Error while requesting POSH: %s', exc)
return
if file.getcode() != 200:
@ -1274,7 +1275,7 @@ class Connection(CommonConnection, ConnectionHandlers):
'accounts', self.name, 'authentication_mechanisms').split()
for mech in auth_mechs:
if mech not in nbxmpp.auth_nb.SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']):
log.warning("Unknown authentication mechanisms %s" % mech)
log.warning('Unknown authentication mechanisms %s', mech)
if not auth_mechs:
auth_mechs = None
else:
@ -1332,7 +1333,7 @@ class Connection(CommonConnection, ConnectionHandlers):
if not app.config.get_per('accounts', self.name, 'savepass'):
# Forget password, it's wrong
self.password = None
log.debug("Couldn't authenticate to %s" % self._hostname)
log.debug("Couldn't authenticate to %s", self._hostname)
self.disconnect(on_purpose = True)
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show='offline'))

View File

@ -505,8 +505,8 @@ class ConnectionHandlers(ConnectionSocks5Bytestream,
if obj.conn.name != self.name:
return
for jid in obj.jid_list:
log.debug('Removing contact %s due to unregistered transport %s' % \
(jid, obj.agent))
log.debug('Removing contact %s due to unregistered transport %s',
jid, obj.agent)
self.get_module('Presence').unsubscribe(jid)
# Transport contacts can't have 2 resources
if jid in app.to_be_removed[self.name]:

View File

@ -96,7 +96,7 @@ class HelperEvent:
tim = helpers.datetime_tuple(tag)
self.timestamp = timegm(tim)
except Exception:
log.error('wrong timestamp, ignoring it: ' + tag)
log.error('wrong timestamp, ignoring it: %s', tag)
self.timestamp = time_time()
def get_chatstate(self):
@ -253,7 +253,7 @@ PresenceHelperEvent):
try:
self.get_jid_resource()
except Exception:
log.warning('Invalid JID: %s, ignoring it' % self.stanza.getFrom())
log.warning('Invalid JID: %s, ignoring it', self.stanza.getFrom())
return
jid_list = app.contacts.get_jid_list(self.conn.name)
self.timestamp = None

View File

@ -77,12 +77,13 @@ class GlobalEventsDispatcher:
try:
self.handlers[event_name].remove((priority, handler))
except ValueError as error:
log.warning('''Function (%s) with priority "%s" never registered
as handler of event "%s". Couldn\'t remove. Error: %s'''
%(handler, priority, event_name, error))
log.warning(
'''Function (%s) with priority "%s" never
registered as handler of event "%s". Couldn\'t remove.
Error: %s''', handler, priority, event_name, error)
def raise_event(self, event_name, *args, **kwargs):
log.debug('%s Args: %s'%(event_name, str(args)))
log.debug('%s Args: %s', event_name, str(args))
if event_name in self.handlers:
node_processed = False
for priority, handler in self.handlers[event_name]:

View File

@ -1355,7 +1355,7 @@ def _get_img_direct(attrs):
req.add_header('User-Agent', 'Gajim ' + app.version)
f = urllib.request.urlopen(req)
except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
log.debug('Error loading image %s ', attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
else:
@ -1368,7 +1368,7 @@ def _get_img_direct(attrs):
deadline = time.time() + (10 * (max_size / 1048576))
while True:
if time.time() > deadline:
log.debug('Timeout loading image %s ' % attrs['src'])
log.debug('Timeout loading image %s ', attrs['src'])
mem = ''
alt = attrs.get('alt', '')
if alt:
@ -1378,7 +1378,7 @@ def _get_img_direct(attrs):
try:
temp = f.read(100)
except socket.timeout as ex:
log.debug('Timeout loading image %s ' % attrs['src'] + str(ex))
log.debug('Timeout loading image %s ', attrs['src'] + str(ex))
alt = attrs.get('alt', '')
if alt:
alt += '\n'
@ -1445,7 +1445,7 @@ def _get_img_proxy(attrs, proxy):
else:
alt += _('Error loading image')
except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
log.debug('Error loading image %s ', attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
return ('', alt)

View File

@ -350,7 +350,7 @@ class JingleFileTransfer(JingleContent):
self.__send_candidate(args)
def _on_connect_error(self, sid):
log.info('connect error, sid=' + sid)
log.info('connect error, sid=%s', sid)
args = {'candError' : True,
'sendCand' : True}
self.__send_candidate(args)

View File

@ -329,7 +329,7 @@ class JingleTransportSocks5(JingleTransport):
return content
def _on_proxy_auth_ok(self, proxy):
log.info('proxy auth ok for ' + str(proxy))
log.info('proxy auth ok for %s', str(proxy))
# send activate request to proxy, send activated confirmation to peer
if not self.connection:
return

View File

@ -34,7 +34,7 @@ class AbstractPEP:
def get_tag_as_PEP(cls, jid, account, event_tag):
items = event_tag.getTag('items', {'node': cls.namespace})
if items:
log.debug("Received PEP 'user %s' from %s" % (cls.type_, jid))
log.debug('Received PEP "user %s" from %s', cls.type_, jid)
return cls(jid, account, items)
else:
return None

View File

@ -778,7 +778,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
Handles streams state change. Used internally.
"""
typ = stanza.getType()
log.debug('IBBIqHandler called typ->%s' % typ)
log.debug('IBBIqHandler called typ->%s', typ)
if typ == 'set' and stanza.getTag('open'):
self.StreamOpenHandler(conn, stanza)
elif typ == 'set' and stanza.getTag('close'):
@ -808,8 +808,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
err = None
sid = stanza.getTagAttr('open', 'sid')
blocksize = stanza.getTagAttr('open', 'block-size')
log.debug('StreamOpenHandler called sid->%s blocksize->%s' % (sid,
blocksize))
log.debug('StreamOpenHandler called sid->%s blocksize->%s',
sid, blocksize)
file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
try:
blocksize = int(blocksize)
@ -822,7 +822,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
if err:
rep = nbxmpp.Error(stanza, err)
else:
log.debug("Opening stream: id %s, block-size %s" % (sid, blocksize))
log.debug("Opening stream: id %s, block-size %s",
sid, blocksize)
rep = nbxmpp.Protocol('iq', stanza.getFrom(), 'result',
stanza.getTo(), {'id': stanza.getID()})
file_props.block_size = blocksize
@ -934,7 +935,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
sid = stanza.getTagAttr('data', 'sid')
seq = stanza.getTagAttr('data', 'seq')
data = stanza.getTagData('data')
log.debug('ReceiveHandler called sid->%s seq->%s' % (sid, seq))
log.debug('ReceiveHandler called sid->%s seq->%s', sid, seq)
try:
seq = int(seq)
data = base64.b64decode(data.encode('utf-8'))
@ -951,8 +952,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
elif seq != file_props.seq:
err = nbxmpp.ERR_UNEXPECTED_REQUEST
else:
log.debug('Successfully received sid->%s %s+%s bytes' % (sid,
file_props.fp.tell(), len(data)))
log.debug('Successfully received sid->%s %s+%s bytes',
sid, file_props.fp.tell(), len(data))
file_props.seq += 1
file_props.started = True
file_props.fp.write(data)
@ -964,7 +965,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
if file_props.received_len >= file_props.size:
file_props.completed = True
if err:
log.debug('Error on receive: %s' % err)
log.debug('Error on receive: %s', err)
conn.send(nbxmpp.Error(nbxmpp.Iq(to=stanza.getFrom(),
frm=stanza.getTo(),
payload=[nbxmpp.Node(nbxmpp.NS_IBB + ' close')]), err, reply=0))
@ -977,7 +978,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
Raise xmpppy event specifying successful data receive.
"""
sid = stanza.getTagAttr('close', 'sid')
log.debug('StreamCloseHandler called sid->%s' % sid)
log.debug('StreamCloseHandler called sid->%s', sid)
# look in sending files
file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
if file_props:
@ -1002,7 +1003,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
is agreed upon.
"""
syn_id = stanza.getID()
log.debug('IBBAllIqHandler called syn_id->%s' % syn_id)
log.debug('IBBAllIqHandler called syn_id->%s', syn_id)
for file_props in FilesProp.getAllFileProp():
if not file_props.direction or not file_props.connected:
# It's socks5 bytestream

View File

@ -122,22 +122,22 @@ class ProxyResolver:
self.state = S_FINISHED
return
self.state = S_INITIAL
log.info('start resolving %s:%s' % (self.host, self.port))
log.info('start resolving %s:%s', self.host, self.port)
self.receiver_tester = ReceiverTester(self.host, self.port, self.jid,
self.sid, self.sender_jid, self._on_receiver_success,
self._on_connect_failure)
self.receiver_tester.connect()
def _on_receiver_success(self):
log.debug('Receiver successfully connected %s:%s' % (self.host,
self.port))
log.debug('Receiver successfully connected %s:%s',
self.host, self.port)
self.host_tester = HostTester(self.host, self.port, self.jid,
self.sid, self.sender_jid, self._on_connect_success,
self._on_connect_failure)
self.host_tester.connect()
def _on_connect_success(self):
log.debug('Host successfully connected %s:%s' % (self.host, self.port))
log.debug('Host successfully connected %s:%s', self.host, self.port)
iq = nbxmpp.Protocol(name='iq', to=self.jid, typ='set')
query = iq.setTag('query')
query.setNamespace(nbxmpp.NS_BYTESTREAM)
@ -147,7 +147,7 @@ class ProxyResolver:
activate.setData('test@gajim.org/test2')
if self.active_connection:
log.debug('Activating bytestream on %s:%s' % (self.host, self.port))
log.debug('Activating bytestream on %s:%s', self.host, self.port)
self.active_connection.SendAndCallForResponse(iq,
self._result_received)
self.state = S_ACTIVATED
@ -162,11 +162,11 @@ class ProxyResolver:
self._on_connect_failure()
def keep_conf(self):
log.debug('Bytestream activated %s:%s' % (self.host, self.port))
log.debug('Bytestream activated %s:%s', self.host, self.port)
self.state = S_FINISHED
def _on_connect_failure(self):
log.debug('Connection failed with %s:%s' % (self.host, self.port))
log.debug('Connection failed with %s:%s', self.host, self.port)
self.state = S_FINISHED
self.host = None
self.port = 0
@ -318,9 +318,9 @@ class HostTester(Socks5, IdleObject):
data = self._get_request_buff(self._get_sha1_auth())
self.send_raw(data)
self.state += 1
log.debug('Host authenticating to %s:%s' % (self.host, self.port))
log.debug('Host authenticating to %s:%s', self.host, self.port)
elif self.state == 3:
log.debug('Host authenticated to %s:%s' % (self.host, self.port))
log.debug('Host authenticated to %s:%s', self.host, self.port)
self.on_success()
self.disconnect()
self.state += 1
@ -331,7 +331,7 @@ class HostTester(Socks5, IdleObject):
try:
self._sock.connect((self.host, self.port))
self._sock.setblocking(False)
log.debug('Host Connecting to %s:%s' % (self.host, self.port))
log.debug('Host Connecting to %s:%s', self.host, self.port)
self._send = self._sock.send
self._recv = self._sock.recv
except Exception as ee:
@ -351,7 +351,7 @@ class HostTester(Socks5, IdleObject):
self._recv = self._sock.recv
self.buff = b''
self.state = 1 # connected
log.debug('Host connected to %s:%s' % (self.host, self.port))
log.debug('Host connected to %s:%s', self.host, self.port)
self.idlequeue.plug_idle(self, True, False)
return
@ -436,7 +436,7 @@ class ReceiverTester(Socks5, IdleObject):
if version != 0x05 or method == 0xff:
self.pollend()
return
log.debug('Receiver authenticating to %s:%s' % (self.host, self.port))
log.debug('Receiver authenticating to %s:%s', self.host, self.port)
data = self._get_request_buff(self._get_sha1_auth())
self.send_raw(data)
self.state += 1
@ -448,7 +448,7 @@ class ReceiverTester(Socks5, IdleObject):
if version != 0x05 or reply != 0x00:
self.pollend()
return
log.debug('Receiver authenticated to %s:%s' % (self.host, self.port))
log.debug('Receiver authenticated to %s:%s', self.host, self.port)
self.on_success()
self.disconnect()
self.state += 1
@ -459,7 +459,7 @@ class ReceiverTester(Socks5, IdleObject):
try:
self._sock.setblocking(False)
self._sock.connect((self.host, self.port))
log.debug('Receiver Connecting to %s:%s' % (self.host, self.port))
log.debug('Receiver Connecting to %s:%s', self.host, self.port)
self._send = self._sock.send
self._recv = self._sock.recv
except Exception as ee:
@ -479,5 +479,5 @@ class ReceiverTester(Socks5, IdleObject):
self._recv = self._sock.recv
self.buff = ''
self.state = 1 # connected
log.debug('Receiver connected to %s:%s' % (self.host, self.port))
log.debug('Receiver connected to %s:%s', self.host, self.port)
self.idlequeue.plug_idle(self, True, False)

View File

@ -132,22 +132,22 @@ class SocksQueue:
fp = fingerprint
if receiving:
if 'candidate_id' in streamhost:
log.debug('Trying to connect as receiver to cid ' + \
streamhost['candidate_id'])
log.debug('Trying to connect as receiver to cid %s',
streamhost['candidate_id'])
else:
log.debug('Trying to connect as receiver to jid ' + \
streamhost['jid'])
log.debug('Trying to connect as receiver to jid %s',
streamhost['jid'])
file_props.type_ = 'r'
socks5obj = Socks5ReceiverClient(self.idlequeue, streamhost,
transport_sid, file_props, fingerprint=fp)
self.add_sockobj(account, socks5obj)
else:
if 'candidate_id' in streamhost:
log.debug('Trying to connect as sender to cid ' + \
streamhost['candidate_id'])
log.debug('Trying to connect as sender to cid %s',
streamhost['candidate_id'])
else:
log.debug('Trying to connect as sender to jid ' + \
streamhost['jid'])
log.debug('Trying to connect as sender to jid %s',
streamhost['jid'])
if file_props.sha_str:
idx = file_props.sha_str
else:
@ -175,9 +175,9 @@ class SocksQueue:
streamhosts. Stop other attempts for connections
"""
if 'candidate_id' in streamhost:
log.debug('Connected to cid ' + streamhost['candidate_id'])
log.debug('Connected to cid %s', streamhost['candidate_id'])
else:
log.debug('Connected to jid ' + streamhost['jid'])
log.debug('Connected to jid %s', streamhost['jid'])
for host in file_props.streamhosts:
if host != streamhost and 'idx' in host:
if host['state'] == 1:
@ -240,9 +240,10 @@ class SocksQueue:
Called when we loose connection during transfer
"""
if 'candidate_id' in streamhost:
log.debug('Connection refused to cid ' + streamhost['candidate_id'])
log.debug('Connection refused to cid %s',
streamhost['candidate_id'])
else:
log.debug('Connection refused to jid ' + streamhost['jid'])
log.debug('Connection refused to jid %s', streamhost['jid'])
if file_props is None:
return
streamhost['state'] = -1
@ -641,7 +642,7 @@ class Socks5:
add = self._recv(64)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request : ' + repr(e))
log.info('SSL rehandshake request: %s', repr(e))
raise e
except Exception:
add = b''
@ -658,7 +659,7 @@ class Socks5:
self._send(raw_data)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
log.info('SSL rehandshake request: %s', repr(e))
raise e
except Exception:
self.disconnect()
@ -682,7 +683,7 @@ class Socks5:
lenn = self._send(buff)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
log.info('SSL rehandshake request: %s', repr(e))
raise e
except Exception as e:
if e.errno not in (EINTR, ENOBUFS, EWOULDBLOCK):
@ -756,7 +757,7 @@ class Socks5:
buff = self._recv(MAX_BUFF_LEN)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
log.info('SSL rehandshake request: %s', repr(e))
raise e
except Exception:
buff = b''
@ -896,7 +897,7 @@ class Socks5:
buff = self._recv().decode('utf-8')
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError) as e:
log.info("SSL rehandshake request : " + repr(e))
log.info("SSL rehandshake request: %s", repr(e))
raise e
try:
version, method = struct.unpack('!BB', buff)
@ -1269,8 +1270,9 @@ class Socks5Client(Socks5):
def send_file(self):
if self.ssl_errnum > 0:
log.error('remote certificate does not match the announced one.' + \
'\nSSL Error: %d\nCancelling file transfer' % self.ssl_errnum)
log.error('remote certificate does not match the announced one.'
'\nSSL Error: %d\nCancelling file transfer',
self.ssl_errnum)
self.file_props.error = -12
return -1
return super(Socks5Client, self).send_file()
@ -1435,7 +1437,7 @@ class Socks5Listener(IdleObject):
self.ai = None
continue
if not self.ai:
log.error('unable to bind to port ' + str(self.port))
log.error('unable to bind to port %s', str(self.port))
return None
self._serv.listen(socket.SOMAXCONN)
self._serv.setblocking(False)

View File

@ -114,7 +114,7 @@ class ZeroconfListener(IdleObject):
"""
Free all resources, we are not listening anymore
"""
log.info('Disconnecting ZeroconfListener: %s' % message)
log.info('Disconnecting ZeroconfListener: %s', message)
app.idlequeue.remove_timeout(self.fd)
app.idlequeue.unplug_idle(self.fd)
self.fd = -1
@ -252,8 +252,8 @@ class P2PClient(IdleObject):
def _check_stream_start(self, ns, tag, attrs):
if ns != NS_STREAMS or tag != 'stream':
log.error('Incorrect stream start: (%s,%s).Terminating!' % (tag,
ns), 'error')
log.error('Incorrect stream start: (%s,%s).Terminating!',
tag, ns)
self.Connection.disconnect()
if self.on_not_ok:
self.on_not_ok('Connection to host could not be established: '
@ -386,8 +386,8 @@ class P2PConnection(IdleObject, PlugIn):
self.disconnect()
return
ai = self.ais.pop(0)
log.info('Trying to connect to %s through %s:%s', str(self.host),
ai[4][0], ai[4][1], exc_info=True)
log.info('Trying to connect to %s through %s:%s',
str(self.host), ai[4][0], ai[4][1], exc_info=True)
try:
self._sock = socket.socket(*ai[:3])
self._sock.setblocking(False)
@ -543,7 +543,7 @@ class P2PConnection(IdleObject, PlugIn):
self.on_receive(received)
else:
# This should never happed, so we need the debug
log.error('Unhandled data received: %s' % received)
log.error('Unhandled data received: %s', received)
self.disconnect()
return True
@ -608,7 +608,7 @@ class P2PConnection(IdleObject, PlugIn):
def _on_send(self):
if self.sent_data and self.sent_data.strip():
log.debug('sent: %s' % self.sent_data)
log.debug('sent: %s', self.sent_data)
if hasattr(self._owner, 'Dispatcher'):
self._owner.Dispatcher.Event(
'', DATA_SENT, self.sent_data.decode('utf-8'))
@ -705,7 +705,7 @@ class ClientZeroconf:
self.roster = None
self.disconnecting = True
for i in reversed(self.disconnect_handlers):
log.debug('Calling disconnect handler %s' % i)
log.debug('Calling disconnect handler %s', i)
i()
self.disconnecting = False

View File

@ -60,7 +60,7 @@ class Zeroconf:
pass
def error_callback1(self, err):
log.debug('Error while resolving: ' + str(err))
log.debug('Error while resolving: %s', str(err))
def error_callback(self, err):
log.debug(str(err))
@ -71,8 +71,8 @@ class Zeroconf:
def new_service_callback(self, interface, protocol, name, stype, domain,
flags):
log.debug('Found service %s in domain %s on %i.%i.' % (name, domain,
interface, protocol))
log.debug('Found service %s in domain %s on %i.%i.',
name, domain, interface, protocol)
if not self.connected:
return
@ -84,8 +84,8 @@ class Zeroconf:
def remove_service_callback(self, interface, protocol, name, stype, domain,
flags):
log.debug('Service %s in domain %s on %i.%i disappeared.' % (name,
domain, interface, protocol))
log.debug('Service %s in domain %s on %i.%i disappeared.',
name, domain, interface, protocol)
if not self.connected:
return
if name != self.name:
@ -161,10 +161,10 @@ class Zeroconf:
def service_resolved_callback(self, interface, protocol, name, stype, domain,
host, aprotocol, address, port, txt, flags):
log.debug('Service data for service %s in domain %s on %i.%i:'
% (name, domain, interface, protocol))
log.debug('Host %s (%s), port %i, TXT data: %s' % (host, address,
port, self.txt_array_to_dict(txt)))
log.debug('Service data for service %s in domain %s on %i.%i:',
name, domain, interface, protocol)
log.debug('Host %s (%s), port %i, TXT data: %s',
host, address, port, self.txt_array_to_dict(txt))
if not self.connected:
return
bare_name = name
@ -186,11 +186,13 @@ class Zeroconf:
# IPv6 aprotocol responses via the same protocol,
# so this probably needs to be revised again.
if old_resolved_info[i][0:2] == (interface, protocol):
log.debug('Deleting resolved info for interface %i, protocol %i, host %s, aprotocol %i, address %s, port %i' % old_resolved_info[i])
log.debug('Deleting resolved info for interface %s',
old_resolved_info[i])
del old_resolved_info[i]
break
resolved_info = resolved_info + old_resolved_info
log.debug('Collected resolved info is now: %s' % (resolved_info,))
log.debug('Collected resolved info is now: %s',
resolved_info)
self.contacts[name] = (name, domain, resolved_info, bare_name, txt)
self.new_serviceCB(name)
else:
@ -225,7 +227,7 @@ class Zeroconf:
log.debug('Service successfully updated')
def service_add_fail_callback(self, err):
log.debug('Error while adding service. %s' % str(err))
log.debug('Error while adding service. %s', str(err))
if 'Local name collision' in str(err):
alternative_name = self.server.GetAlternativeServiceName(self.username)
self.name_conflictCB(alternative_name)
@ -234,7 +236,7 @@ class Zeroconf:
self.disconnect()
def server_state_changed_callback(self, state, error):
log.debug('server state changed to %s' % state)
log.debug('server state changed to %s', state)
if state == ServerState.RUNNING:
self.create_service()
elif state in (ServerState.COLLISION,
@ -292,8 +294,8 @@ class Zeroconf:
txt['status'] = 'avail'
self.txt = txt
log.debug('Publishing service %s of type %s' % (self.name,
self.stype))
log.debug('Publishing service %s of type %s',
self.name, self.stype)
self.entrygroup.AddService(Interface.UNSPEC,
Protocol.UNSPEC, dbus.UInt32(0), self.name, self.stype, '',
'', dbus.UInt16(self.port), self.avahi_txt(),
@ -360,7 +362,7 @@ class Zeroconf:
dbus.set_default_main_loop(main_loop)
except ImportError:
log.debug('Error: python-dbus needs to be installed. No '
'zeroconf support.')
'zeroconf support.')
return False
if self.bus:
return True

View File

@ -94,7 +94,7 @@ class Zeroconf:
resolve_sdRef.close()
def remove_service_callback(self, name):
log.info('Service %s disappeared.' % name)
log.info('Service %s disappeared.', name)
if not self.connected:
return
if name != self.name:

View File

@ -1380,9 +1380,9 @@ class ConversationTextview(GObject.GObject):
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
self.tv.display_html(xhtml, self.tv, self, iter_=iter_)
return
except Exception as e:
log.debug('Error processing xhtml: ' + str(e))
log.debug('with |' + xhtml + '|')
except Exception as error:
log.debug('Error processing xhtml: %s', error)
log.debug('with |%s|', xhtml)
# /me is replaced by name if name is given
if name and (text.startswith('/me ') or text.startswith('/me\n')):

View File

@ -351,12 +351,13 @@ class FileTransfersWindow:
if file_props is None:
return False
if contact.supports(NS_JINGLE_FILE_TRANSFER_5):
log.info("contact %s supports jingle file transfer"%(contact.get_full_jid()))
log.info('contact %s supports jingle file transfer',
contact.get_full_jid())
app.connections[account].start_file_transfer(contact.get_full_jid(),
file_props)
self.add_transfer(account, contact, file_props)
else:
log.info("contact does not support jingle file transfer")
log.info('contact does not support jingle file transfer')
file_props.transport_sid = file_props.sid
app.connections[account].send_file_request(file_props)
self.add_transfer(account, contact, file_props)

View File

@ -1953,8 +1953,8 @@ class GroupchatControl(ChatControlBase):
gc_c = app.contacts.get_gc_contact(self.account,
self.room_jid, obj.nick)
if not gc_c:
log.error('%s has an iter, but no gc_contact instance' % \
obj.nick)
log.error('%s has an iter, but no gc_contact instance',
obj.nick)
return
actual_affiliation = gc_c.affiliation

View File

@ -68,20 +68,20 @@ def get_icon_pixmap(icon_name, size=16, color=None, quiet=False):
pixbuf, was_symbolic = iconinfo.load_symbolic(*color)
return pixbuf
return iconinfo.load_icon()
except GLib.GError as e:
except GLib.GError as error:
if not quiet:
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
log.error('Unable to load icon %s: %s', icon_name, str(error))
def get_icon_path(icon_name, size=16):
try:
icon_info = gtk_icon_theme.lookup_icon(icon_name, size, 0)
if icon_info == None:
log.error('Icon not found: %s' % icon_name)
return ""
log.error('Icon not found: %s', icon_name)
return ''
else:
return icon_info.get_filename()
except GLib.GError as e:
log.error("Unable to find icon %s: %s" % (icon_name, str(e)))
except GLib.GError as error:
log.error('Unable to find icon %s: %s', icon_name, str(error))
HAS_PYWIN32 = True
@ -484,8 +484,8 @@ def on_avatar_save_as_menuitem_activate(widget, avatar, default_name=''):
# Save image
try:
pixbuf.savev(file_path, image_format, [], [])
except Exception as e:
log.error('Error saving avatar: %s' % str(e))
except Exception as error:
log.error('Error saving avatar: %s', error)
if os.path.exists(file_path):
os.remove(file_path)
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.png'

View File

@ -270,9 +270,12 @@ class GajimPluginConfig():
s.close()
self.save()
except Exception:
log.warning('%s plugin config file not readable. Saving it as '
'%s and creating a new one' % (self.plugin.short_name,
self.FILE_PATH.decode(locale.getpreferredencoding()) + '.bak'))
enc = locale.getpreferredencoding()
filename = self.FILE_PATH.decode(enc) + '.bak'
log.warning(
'%s plugin config file not readable. Saving it as '
'%s and creating a new one',
self.plugin.short_name, filename)
if os.path.exists(self.FILE_PATH + '.bak'):
os.remove(self.FILE_PATH + '.bak')
os.rename(self.FILE_PATH, self.FILE_PATH + '.bak')

View File

@ -99,11 +99,9 @@ class log_calls:
@functools.wraps(f)
def wrapper(*args, **kwargs):
log.debug('%(funcname)s() <entered>'%{
'funcname': self.full_func_name})
log.debug('%s() <entered>', self.full_func_name)
result = f(*args, **kwargs)
log.debug('%(funcname)s() <left>'%{
'funcname': self.full_func_name})
log.debug('%s() <left>', self.full_func_name)
return result
else:
@functools.wraps(f)

View File

@ -144,9 +144,10 @@ class PluginManager(metaclass=Singleton):
self.plugins.append(plugin)
plugin.active = False
else:
log.info('Not loading plugin %s v%s from module %s (identified by'
' short name: %s). Plugin already loaded.' % (plugin.name,
plugin.version, plugin.__module__, plugin.short_name))
log.info('Not loading plugin %s v%s from module %s '
'(identified by short name: %s). Plugin already loaded.',
plugin.name, plugin.version,
plugin.__module__, plugin.short_name)
@log_calls('PluginManager')
def remove_plugin(self, plugin):
@ -314,8 +315,8 @@ class PluginManager(metaclass=Singleton):
try:
handlers[0](*args)
except Exception as e:
log.warning('Error executing %s', handlers[0],
exc_info=True)
log.warning('Error executing %s',
handlers[0], exc_info=True)
def _register_events_handlers_in_ged(self, plugin):
for event_name, handler in plugin.events_handlers.items():
@ -426,9 +427,9 @@ class PluginManager(metaclass=Singleton):
if handler:
try:
handler(*gui_extension_point_args)
except Exception as e:
log.warning('Error executing %s', handler,
exc_info=True)
except Exception:
log.warning('Error executing %s',
handler, exc_info=True)
self._remove_events_handler_from_ged(plugin)
self._remove_network_events_from_nec(plugin)
@ -467,9 +468,9 @@ class PluginManager(metaclass=Singleton):
if handler:
try:
handler(*gui_extension_point_args)
except Exception as e:
log.warning('Error executing %s', handler,
exc_info=True)
except Exception:
log.warning('Error executing %s',
handler, exc_info=True)
@log_calls('PluginManager')
@ -579,9 +580,8 @@ class PluginManager(metaclass=Singleton):
try:
conf.read_file(conf_file)
except configparser.Error:
log.warning(("Plugin {plugin} not loaded, error loading"
" manifest").format(plugin=elem_name)
, exc_info=True)
log.warning('Plugin %s not loaded, error loading manifest',
elem_name, exc_info=True)
continue
min_v = conf.get('info', 'min_gajim_version', fallback=None)
@ -591,32 +591,24 @@ class PluginManager(metaclass=Singleton):
gajim_v_cmp = parse_version(gajim_v)
if min_v and gajim_v_cmp < parse_version(min_v):
log.warning(('Plugin {plugin} not loaded, newer version of'
'gajim required: {gajim_v} < {min_v}').format(
plugin=elem_name,
gajim_v=gajim_v,
min_v=min_v
))
log.warning('Plugin %s not loaded, newer version of'
'gajim required: %s < %s',
elem_name, gajim_v, min_v)
continue
if max_v and gajim_v_cmp > parse_version(max_v):
log.warning(('Plugin {plugin} not loaded, plugin incompatible '
'with current version of gajim: '
'{gajim_v} > {max_v}').format(
plugin=elem_name,
gajim_v=gajim_v,
max_v=max_v
))
log.warning('Plugin %s not loaded, plugin incompatible '
'with current version of gajim: '
'%s > %s', elem_name, gajim_v, max_v)
continue
module = None
try:
log.info('Loading %s', module_name)
module = __import__(module_name)
except Exception as error:
except Exception:
log.warning(
"While trying to load {plugin}, exception occurred".format(plugin=elem_name),
exc_info=sys.exc_info()
)
'While trying to load %s, exception occurred',
elem_name, exc_info=True)
continue
if module is None:
@ -626,7 +618,7 @@ class PluginManager(metaclass=Singleton):
for module_attr_name in [attr_name for attr_name in dir(module)
if not (attr_name.startswith('__') or attr_name.endswith('__'))]:
module_attr = getattr(module, module_attr_name)
log.debug('%s : %s' % (module_attr_name, module_attr))
log.debug('%s: %s', module_attr_name, module_attr)
try:
if not issubclass(module_attr, GajimPlugin) or \
@ -653,16 +645,18 @@ class PluginManager(metaclass=Singleton):
pass
except configparser.NoOptionError:
# all fields are required
log.debug('%s : %s' % (module_attr_name,
'wrong manifest file. all fields are required!'))
log.debug(
'%s: wrong manifest file. all fields are required!',
module_attr_name)
except configparser.NoSectionError:
# info section are required
log.debug('%s : %s' % (module_attr_name,
'wrong manifest file. info section are required!'))
log.debug(
'%s: wrong manifest file. info section are required!',
module_attr_name)
except configparser.MissingSectionHeaderError:
# info section are required
log.debug('%s : %s' % (module_attr_name,
'wrong manifest file. section are required!'))
log.debug('%s: wrong manifest file. section are required!',
module_attr_name)
sys.path.remove(path)
return plugins_found