Merge lp://qastaging/~sil/desktopcouch/pick-or-listen-non-global-489925 into lp://qastaging/desktopcouch

Proposed by Stuart Langridge
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: not available
Merged at revision: not available
Proposed branch: lp://qastaging/~sil/desktopcouch/pick-or-listen-non-global-489925
Merge into: lp://qastaging/desktopcouch
Diff against target: 119 lines (+14/-14)
1 file modified
bin/desktopcouch-pair (+14/-14)
To merge this branch: bzr merge lp://qastaging/~sil/desktopcouch/pick-or-listen-non-global-489925
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Chad Miller (community) Approve
Review via email: mp+15419@code.qastaging.launchpad.net

Commit message

Improve pairing tool reliability. Make pick_or_listen not be a global, which fixes a race condition in signals and initialization.

To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) wrote :

A patch from thomasvs to make pick_or_listen not be a global. See bug 489925.

Revision history for this message
Chad Miller (cmiller) wrote :

Looks good to me. I approve.

review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

looks ok

review: Approve
Revision history for this message
Stuart Langridge (sil) wrote :

Please don't merge this yet, until we have the contributor agreement.

Revision history for this message
Stuart Langridge (sil) wrote :

Contributor agreement arrived. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/desktopcouch-pair'
2--- bin/desktopcouch-pair 2009-10-14 14:48:25 +0000
3+++ bin/desktopcouch-pair 2009-11-30 13:20:24 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/python
6+# vi:si:et:sw=4:sts=4:ts=4
7 # Copyright 2009 Canonical Ltd.
8 #
9 # This file is part of desktopcouch.
10@@ -138,18 +139,19 @@
11
12 def auth_completed(self, remote_host, remote_id, remote_oauth):
13 """The auth stage is finished. Now pair with the remote host."""
14- pair_with_host(remote_host, remote_id, remote_oauth)
15+ pair_with_host(remote_host, remote_id, remote_oauth, self.parent)
16 self.window.destroy()
17
18 def on_close(self):
19 """When a socket is closed, we should stop inviting. (?)"""
20 self.window.destroy()
21
22- def __init__(self, service, hostname, port):
23+ def __init__(self, service, hostname, port, parent):
24 self.logging = logging.getLogger(self.__class__.__name__)
25
26 self.hostname = hostname
27 self.port = port
28+ self.parent = parent
29
30 self.window = gtk.Window()
31 self.window.set_border_width(6)
32@@ -510,7 +512,7 @@
33
34 if service_name:
35 # Pairing with a cloud service, which doesn't do key exchange
36- pair_with_cloud_service(service_name)
37+ pair_with_cloud_service(service_name, self.window)
38 # remove from listening list
39 self.listening_hosts.remove(iter)
40 # add to already-paired list
41@@ -523,7 +525,7 @@
42 hostname, port)
43 if self.inviting != None:
44 self.inviting.window.destroy()
45- self.inviting = Inviting(service, hostname, port)
46+ self.inviting = Inviting(service, hostname, port, self)
47 self.inviting.window.connect("destroy",
48 lambda *args: setattr(self, "inviting_window", None))
49
50@@ -779,7 +781,7 @@
51 self.window.show()
52
53
54-def pair_with_host(hostname, hostid, oauth_data):
55+def pair_with_host(hostname, hostid, oauth_data, parent):
56 """We've verified all is correct and authorized, so now we pair
57 the databases."""
58 logging.info("verified host %s/%s. Done!", hostname, hostid)
59@@ -790,7 +792,7 @@
60 except Exception, e:
61 logging.exception("failure writing record for %s", hostname)
62 fail_note = gtk.MessageDialog(
63- parent=pick_or_listen.window,
64+ parent=parent,
65 flags=gtk.DIALOG_DESTROY_WITH_PARENT,
66 buttons=gtk.BUTTONS_OK,
67 type=gtk.MESSAGE_ERROR,
68@@ -800,7 +802,7 @@
69 return
70
71 success_note = gtk.Dialog(title=_("Paired with %(hostname)s") % locals(),
72- parent=pick_or_listen.window,
73+ parent=parent,
74 flags=gtk.DIALOG_DESTROY_WITH_PARENT,
75 buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,))
76 text = gtk.Label(
77@@ -809,13 +811,13 @@
78 content_box = success_note.get_content_area()
79 content_box.pack_start(text, True, True, 20)
80 success_note.connect("close",
81- lambda *args: pick_or_listen.window.destroy())
82+ lambda *args: parent.destroy())
83 success_note.connect("response",
84- lambda *args: pick_or_listen.window.destroy())
85+ lambda *args: parent.destroy())
86 success_note.show()
87
88
89-def pair_with_cloud_service(service_name):
90+def pair_with_cloud_service(service_name, parent):
91 """Write a paired server record for the selected cloud service."""
92 try:
93 import desktopcouch.replication_services as services
94@@ -826,7 +828,7 @@
95 except Exception, e:
96 logging.exception("failure in module for service %r", service_name)
97 fail_note = gtk.MessageDialog(
98- parent=pick_or_listen.window,
99+ parent=parent,
100 flags=gtk.DIALOG_DESTROY_WITH_PARENT,
101 buttons=gtk.BUTTONS_OK,
102 type=gtk.MESSAGE_ERROR,
103@@ -836,7 +838,7 @@
104 return
105
106 success_note = gtk.MessageDialog(
107- parent=pick_or_listen.window,
108+ parent=parent,
109 flags=gtk.DIALOG_DESTROY_WITH_PARENT,
110 buttons=gtk.BUTTONS_OK,
111 type=gtk.MESSAGE_INFO,
112@@ -885,8 +887,6 @@
113 import gobject
114 gobject.set_application_name("desktopcouch pairing tool")
115
116- global pick_or_listen # pylint: disable-msg=W0601
117-
118 logging.basicConfig(level=logging.DEBUG, format=
119 "%(asctime)s [%(process)d] %(name)s:%(levelname)s: %(message)s")
120

Subscribers

People subscribed via source and target branches