From 69291b6ea410825bc288f4071e4a2bd200bdac2e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 12 Feb 2010 07:05:31 -0600 Subject: [PATCH] Fixing lots of minor bugs found by lint --- src/aliasing.py | 1 + src/autogv.py | 5 ++--- src/channel/debug_log.py | 2 +- src/connection.py | 6 +++--- src/connection_manager.py | 4 ++-- src/gvoice/session.py | 2 +- src/gvoice/state_machine.py | 2 -- src/handle.py | 4 ++-- src/theonering.py | 8 ++++---- src/util/tp_utils.py | 13 ++++++------- 10 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/aliasing.py b/src/aliasing.py index 22fa414..b62f7b1 100644 --- a/src/aliasing.py +++ b/src/aliasing.py @@ -136,6 +136,7 @@ class AliasingMixin(tp.ConnectionInterfaceAliasing): def SetAliases(self, aliases): _moduleLogger.debug("Called SetAliases") # first validate that no other handle types are included + handleId, alias = None, None for handleId, alias in aliases.iteritems(): h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, handleId) if isinstance(h, handle.ConnectionHandle): diff --git a/src/autogv.py b/src/autogv.py index 1955e8b..fcc1386 100644 --- a/src/autogv.py +++ b/src/autogv.py @@ -1,6 +1,5 @@ import logging -import gobject import telepathy try: @@ -181,7 +180,7 @@ class AutoDisconnect(object): @misc_utils.log_exception(_moduleLogger) def _on_delayed_disconnect(self): - if not self.session.is_logged_in(): + if not self._connRef().session.is_logged_in(): _moduleLogger.info("Received connection change event when not logged in") return try: @@ -228,6 +227,6 @@ class DisconnectOnShutdown(object): @note Hildon specific """ try: - self._connRef().disconnect(telepathy.CONNECTION_STATUS_REASON_REQUEST) + self._connRef().disconnect(telepathy.CONNECTION_STATUS_REASON_REQUESTED) except Exception: _moduleLogger.exception("Error durring disconnect") diff --git a/src/channel/debug_log.py b/src/channel/debug_log.py index 049754a..82b7130 100644 --- a/src/channel/debug_log.py +++ b/src/channel/debug_log.py @@ -95,7 +95,7 @@ class DebugLogChannel(tp.ChannelTypeFileTransfer): telepathy.constants.FILE_TRANSFER_STATE_CHANGE_REASON_NONE, ) - sockittome = socket.socket(socket.AF_UNIT, socket.SOCK_STREAM) + sockittome = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sockittome.connect(accessControlParam) try: sockittome.send(self._log) diff --git a/src/connection.py b/src/connection.py index 88a02e6..b097993 100644 --- a/src/connection.py +++ b/src/connection.py @@ -259,9 +259,9 @@ class TheOneRingConnection( _moduleLogger.info("RequestChannel Object Path (%s): %s" % (type.rsplit(".", 1)[-1], path)) return path - def generate_props(self, channelType, handle, suppressHandler, initiatorHandle=None): - targetHandle = 0 if handle is None else handle.get_id() - targetHandleType = telepathy.HANDLE_TYPE_NONE if handle is None else handle.get_type() + def generate_props(self, channelType, handleObj, suppressHandler, initiatorHandle=None): + targetHandle = 0 if handleObj is None else handleObj.get_id() + targetHandleType = telepathy.HANDLE_TYPE_NONE if handleObj is None else handleObj.get_type() props = { telepathy.CHANNEL_INTERFACE + '.ChannelType': channelType, telepathy.CHANNEL_INTERFACE + '.TargetHandle': targetHandle, diff --git a/src/connection_manager.py b/src/connection_manager.py index 64b6bf8..cddba2a 100644 --- a/src/connection_manager.py +++ b/src/connection_manager.py @@ -70,8 +70,8 @@ class TheOneRingConnectionManager(tp.ConnectionManager): """ Terminates all connections. Must be called upon quit """ - for connection in self._connections: - connection.Disconnect() + for conn in self._connections: + conn.Disconnect() _moduleLogger.info("Connection manager quitting") @misc_utils.log_exception(_moduleLogger) diff --git a/src/gvoice/session.py b/src/gvoice/session.py index 278ab2f..db97f95 100644 --- a/src/gvoice/session.py +++ b/src/gvoice/session.py @@ -186,7 +186,7 @@ class Session(object): # To throttle checking with the server, use a 30s cache newTime = time.time() if self._lastDndCheck + 30 < newTime: - self._lasDndCheck = newTime + self._lastDndCheck = newTime self._cachedIsDnd = self._backend.is_dnd() return self._cachedIsDnd diff --git a/src/gvoice/state_machine.py b/src/gvoice/state_machine.py index 514fb92..1d784ab 100644 --- a/src/gvoice/state_machine.py +++ b/src/gvoice/state_machine.py @@ -2,8 +2,6 @@ import logging -import gobject - import util.go_utils as gobject_utils import util.coroutines as coroutines import util.misc as misc_utils diff --git a/src/handle.py b/src/handle.py index 9baf35b..b800fa5 100644 --- a/src/handle.py +++ b/src/handle.py @@ -72,7 +72,7 @@ def create_handle_factory(): cache = weakref.WeakValueDictionary() - def create_handle(connection, type, *args): + def _create_handle(connection, type, *args): Handle = _HANDLE_TYPE_MAPPING[type] key = Handle, connection.username, args try: @@ -88,7 +88,7 @@ def create_handle_factory(): _moduleLogger.debug("Created Handle: %r (%s)" % (handle, handleStatus)) return handle - return create_handle + return _create_handle create_handle = create_handle_factory() diff --git a/src/theonering.py b/src/theonering.py index 1e06a1d..de0f8c0 100755 --- a/src/theonering.py +++ b/src/theonering.py @@ -47,23 +47,23 @@ def run_theonering(persist): raise @gobject_utils.async - def quit(): + def on_quit(): manager.quit() mainloop.quit() def timeout_cb(): if len(manager._connections) == 0: logging.info('No connection received - quitting') - quit() + on_quit() return False if persist: shutdown_callback = None else: gobject_utils.timeout_add_seconds(IDLE_TIMEOUT, timeout_cb) - shutdown_callback = quit + shutdown_callback = on_quit - signal.signal(signal.SIGTERM, lambda: quit) + signal.signal(signal.SIGTERM, lambda: on_quit) try: manager = connection_manager.TheOneRingConnectionManager(shutdown_func=shutdown_callback) diff --git a/src/util/tp_utils.py b/src/util/tp_utils.py index 9ae525b..ae9250a 100644 --- a/src/util/tp_utils.py +++ b/src/util/tp_utils.py @@ -2,7 +2,6 @@ import logging -import gobject import dbus import telepathy @@ -17,15 +16,15 @@ DBUS_PROPERTIES = 'org.freedesktop.DBus.Properties' class WasMissedCall(object): def __init__(self, bus, conn, chan, on_success, on_error): - self._on_success = on_success - self._on_error = on_error + self.__on_success = on_success + self.__on_error = on_error self._requested = None self._didMembersChange = False self._didClose = False self._didReport = False - self._onTimeout = misc.Timeout(self._on_timeout) + self._onTimeout = gobject_utils.Timeout(self._on_timeout) self._onTimeout.start(seconds=10) chan[telepathy.interfaces.CHANNEL_INTERFACE_GROUP].connect_to_signal( @@ -41,7 +40,7 @@ class WasMissedCall(object): chan[DBUS_PROPERTIES].GetAll( telepathy.interfaces.CHANNEL_INTERFACE, reply_handler = self._on_got_all, - error_handler = self._on_got_all, + error_handler = self._on_error, ) def cancel(self): @@ -65,13 +64,13 @@ class WasMissedCall(object): assert not self._didReport self._didReport = True self._onTimeout.cancel() - self._on_success(self) + self.__on_success(self) def _report_error(self, reason): assert not self._didReport self._didReport = True self._onTimeout.cancel() - self._on_error(self, reason) + self.__on_error(self, reason) @misc.log_exception(_moduleLogger) def _on_got_all(self, properties): -- 1.7.9.5