Fixing lots of minor bugs found by lint
authorEd Page <eopage@byu.net>
Fri, 12 Feb 2010 13:05:31 +0000 (07:05 -0600)
committerEd Page <eopage@byu.net>
Fri, 12 Feb 2010 13:05:31 +0000 (07:05 -0600)
src/aliasing.py
src/autogv.py
src/channel/debug_log.py
src/connection.py
src/connection_manager.py
src/gvoice/session.py
src/gvoice/state_machine.py
src/handle.py
src/theonering.py
src/util/tp_utils.py

index 22fa414..b62f7b1 100644 (file)
@@ -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):
index 1955e8b..fcc1386 100644 (file)
@@ -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")
index 049754a..82b7130 100644 (file)
@@ -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)
index 88a02e6..b097993 100644 (file)
@@ -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,
index 64b6bf8..cddba2a 100644 (file)
@@ -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)
index 278ab2f..db97f95 100644 (file)
@@ -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
 
index 514fb92..1d784ab 100644 (file)
@@ -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
index 9baf35b..b800fa5 100644 (file)
@@ -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()
index 1e06a1d..de0f8c0 100755 (executable)
@@ -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)
index 9ae525b..ae9250a 100644 (file)
@@ -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):