Commit 21d4d0cb authored by Philipp Hörist's avatar Philipp Hörist

Remove unused import / codestyle

Pass args to logging method instead of string formatting
parent e265514d
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>. ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
## ##
import sys
import logging import logging
import functools import functools
...@@ -25,6 +24,7 @@ from gi.repository import Gio, GLib ...@@ -25,6 +24,7 @@ from gi.repository import Gio, GLib
log = logging.getLogger('gajim.c.resolver') log = logging.getLogger('gajim.c.resolver')
def get_resolver(): def get_resolver():
return GioResolver() return GioResolver()
...@@ -38,7 +38,7 @@ class CommonResolver(): ...@@ -38,7 +38,7 @@ class CommonResolver():
def resolve(self, host, on_ready, type_='srv'): def resolve(self, host, on_ready, type_='srv'):
host = host.lower() host = host.lower()
log.debug('resolve %s type=%s' % (host, type_)) log.debug('resolve %s type=%s', host, type_)
assert(type_ in ['srv', 'txt']) assert(type_ in ['srv', 'txt'])
if not host: if not host:
# empty host, return empty list of srv records # empty host, return empty list of srv records
...@@ -46,25 +46,25 @@ class CommonResolver(): ...@@ -46,25 +46,25 @@ class CommonResolver():
return return
if host + type_ in self.resolved_hosts: if host + type_ in self.resolved_hosts:
# host is already resolved, return cached values # host is already resolved, return cached values
log.debug('%s already resolved: %s' % (host, log.debug('%s already resolved: %s',
self.resolved_hosts[host + type_])) host, self.resolved_hosts[host + type_])
on_ready(host, self.resolved_hosts[host + type_]) on_ready(host, self.resolved_hosts[host + type_])
return return
if host + type_ in self.handlers: if host + type_ in self.handlers:
# host is about to be resolved by another connection, # host is about to be resolved by another connection,
# attach our callback # attach our callback
log.debug('already resolving %s' % host) log.debug('already resolving %s', host)
self.handlers[host + type_].append(on_ready) self.handlers[host + type_].append(on_ready)
else: else:
# host has never been resolved, start now # host has never been resolved, start now
log.debug('Starting to resolve %s using %s' % (host, self)) log.debug('Starting to resolve %s using %s', host, self)
self.handlers[host + type_] = [on_ready] self.handlers[host + type_] = [on_ready]
self.start_resolve(host, type_) self.start_resolve(host, type_)
def _on_ready(self, host, type_, result_list): def _on_ready(self, host, type_, result_list):
# practically it is impossible to be the opposite, but who knows :) # practically it is impossible to be the opposite, but who knows :)
host = host.lower() host = host.lower()
log.debug('Resolving result for %s: %s' % (host, result_list)) log.debug('Resolving result for %s: %s', host, result_list)
if host + type_ not in self.resolved_hosts: if host + type_ not in self.resolved_hosts:
self.resolved_hosts[host + type_] = result_list self.resolved_hosts[host + type_] = result_list
if host + type_ in self.handlers: if host + type_ in self.handlers:
...@@ -94,7 +94,7 @@ class GioResolver(CommonResolver): ...@@ -94,7 +94,7 @@ class GioResolver(CommonResolver):
callback = functools.partial(self._on_ready_srv, host) callback = functools.partial(self._on_ready_srv, host)
type_ = Gio.ResolverRecordType.SRV type_ = Gio.ResolverRecordType.SRV
resq = self.gio_resolver.lookup_records_async(host, type_, None, callback) self.gio_resolver.lookup_records_async(host, type_, None, callback)
def _on_ready_srv(self, host, source_object, result): def _on_ready_srv(self, host, source_object, result):
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment