[Sugar-devel] [PATCH sugar] Fix Traceback when connecting to a network for the first time

Sascha Silbe silbe at activitycentral.com
Mon Apr 2 12:36:07 EDT 2012


When connecting to a network that we don't have settings for yet, the following
Traceback was logged:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 586, in msg_reply_handler
    reply_handler(*message.get_args_list(**get_args_opts))
TypeError: _activate_reply_cb() takes exactly 1 argument (2 given)

This is because the same set of callbacks was used for both
ActivateConnection() and AddAndActivateConnection() even though they return
different sets of values.

Signed-off-by: Sascha Silbe <silbe at activitycentral.com>
---
 I already hit this once while reviewing the original NM 0.9 patch,
 but could never reproduce it. Now I know why: the call succeeded, so
 any further connect attempt re-used the existing connection,
 triggering the code path with the correct number of arguments.

 src/jarabe/model/network.py |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index af510e1..40eb6d0 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -728,14 +728,22 @@ def get_secret_agent():
     return _secret_agent
 
 
-def _activate_reply_cb(connection):
-    logging.debug('Activated connection: %s', connection)
+def _activate_reply_cb(connection_path):
+    logging.debug('Activated connection: %s', connection_path)
 
 
 def _activate_error_cb(err):
     logging.error('Failed to activate connection: %s', err)
 
 
+def _add_and_activate_reply_cb(settings_path, connection_path):
+    logging.debug('Added and activated connection: %s', connection_path)
+
+
+def _add_and_activate_error_cb(err):
+    logging.error('Failed to add and activate connection: %s', err)
+
+
 class Connection(gobject.GObject):
     __gsignals__ = {
         'removed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
@@ -900,10 +908,11 @@ def activate_connection_by_path(connection, device_o,
 
 
 def add_and_activate_connection(device_o, settings, specific_object):
-    get_manager().AddAndActivateConnection(settings.get_dict(), device_o,
-                                           specific_object,
-                                           reply_handler=_activate_reply_cb,
-                                           error_handler=_activate_error_cb)
+    manager = get_manager()
+    manager.AddAndActivateConnection(settings.get_dict(), device_o,
+                                     specific_object,
+                                     reply_handler=_add_and_activate_reply_cb,
+                                     error_handler=_add_and_activate_error_cb)
 
 
 def _migrate_old_wifi_connections():
-- 
1.7.9



More information about the Sugar-devel mailing list