Merge lp:~diegosarmentero/ubuntuone-client/refactor-ipc into lp:ubuntuone-client

Proposed by Diego Sarmentero on 2012-04-30
Status: Merged
Approved by: Diego Sarmentero on 2012-05-01
Approved revision: 1232
Merged at revision: 1232
Proposed branch: lp:~diegosarmentero/ubuntuone-client/refactor-ipc
Merge into: lp:ubuntuone-client
Diff against target: 277 lines (+90/-25)
13 files modified
tests/platform/__init__.py (+3/-4)
tests/platform/ipc/__init__.py (+27/-0)
tests/platform/ipc/test_linux.py (+3/-2)
tests/platform/ipc/test_windows.py (+3/-3)
tests/platform/linux/eventlog/test_zglog.py (+3/-2)
tests/platform/linux/test_credentials.py (+1/-0)
ubuntuone/platform/__init__.py (+4/-2)
ubuntuone/platform/ipc/__init__.py (+42/-0)
ubuntuone/platform/ipc/ipc_client.py (+1/-1)
ubuntuone/platform/linux/__init__.py (+0/-4)
ubuntuone/platform/tools/linux.py (+1/-1)
ubuntuone/platform/tools/windows.py (+2/-2)
ubuntuone/platform/windows/__init__.py (+0/-4)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-client/refactor-ipc
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-05-01
dobey (community) 2012-04-30 Approve on 2012-04-30
Review via email: mp+104121@code.launchpad.net

Commit Message

- Refactor platform/ipc (LP: #989127).

To post a comment you must log in.
dobey (dobey) :
review: Approve
1231. By Diego Sarmentero on 2012-05-01

improve __init__ imports

review: Approve
1232. By Diego Sarmentero on 2012-05-01

improve tests imports

Mike McCracken (mikemc) wrote :

FYI, the last commit in this branch introduced a syntax error (see line 11 of the unified diff below) that I am fixing over in https://code.launchpad.net/~mikemc/ubuntuone-client/test-platform-init-typo-bugfix/+merge/104297

This was discussed on IRC between dobey and I but I'm noting it here for the benefit of the others.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/__init__.py'
2--- tests/platform/__init__.py 2012-04-09 20:07:05 +0000
3+++ tests/platform/__init__.py 2012-05-01 14:37:18 +0000
4@@ -28,11 +28,10 @@
5 import sys
6
7 if sys.platform.startswith('linux'):
8- from tests.platform.linux import test_dbus
9- ipc_source = test_dbus
10+ from tests.platform.ipc import test_linux as ipc_source
11+ = test_linux
12 else:
13- from tests.platform.windows import test_ipc
14- ipc_source = test_ipc
15+ from tests.platform.ipc import test_windows as ipc_source
16
17 IPCTestCase = ipc_source.IPCTestCase
18 StatusTestCase = ipc_source.StatusTestCase
19
20=== added directory 'tests/platform/ipc'
21=== added file 'tests/platform/ipc/__init__.py'
22--- tests/platform/ipc/__init__.py 1970-01-01 00:00:00 +0000
23+++ tests/platform/ipc/__init__.py 2012-05-01 14:37:18 +0000
24@@ -0,0 +1,27 @@
25+# Copyright 2012 Canonical Ltd.
26+#
27+# This program is free software: you can redistribute it and/or modify it
28+# under the terms of the GNU General Public License version 3, as published
29+# by the Free Software Foundation.
30+#
31+# This program is distributed in the hope that it will be useful, but
32+# WITHOUT ANY WARRANTY; without even the implied warranties of
33+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
34+# PURPOSE. See the GNU General Public License for more details.
35+#
36+# You should have received a copy of the GNU General Public License along
37+# with this program. If not, see <http://www.gnu.org/licenses/>.
38+#
39+# In addition, as a special exception, the copyright holders give
40+# permission to link the code of portions of this program with the
41+# OpenSSL library under certain conditions as described in each
42+# individual source file, and distribute linked combinations
43+# including the two.
44+# You must obey the GNU General Public License in all respects
45+# for all of the code used other than OpenSSL. If you modify
46+# file(s) with this exception, you may extend this exception to your
47+# version of the file(s), but you are not obligated to do so. If you
48+# do not wish to do so, delete this exception statement from your
49+# version. If you delete this exception statement from all source
50+# files in the program, then also delete it here.
51+"""Platform/IPC test code."""
52
53=== renamed file 'tests/platform/test_external_interface.py' => 'tests/platform/ipc/test_external_interface.py'
54=== renamed file 'tests/platform/linux/test_dbus.py' => 'tests/platform/ipc/test_linux.py'
55--- tests/platform/linux/test_dbus.py 2012-04-09 20:07:05 +0000
56+++ tests/platform/ipc/test_linux.py 2012-05-01 14:37:18 +0000
57@@ -40,8 +40,8 @@
58 FakedService,
59 FakedObject,
60 )
61-from ubuntuone.platform.linux import dbus_interface
62-from ubuntuone.platform.linux.dbus_interface import (
63+from ubuntuone.platform.ipc import linux as dbus_interface
64+from ubuntuone.platform.ipc.linux import (
65 DBusExposedObject,
66 DBUS_IFACE_STATUS_NAME,
67 DBUS_IFACE_EVENTS_NAME,
68@@ -307,6 +307,7 @@
69 def test_restart(self):
70 """Start things up, then fire a restart, check it tries to restart."""
71 d = defer.Deferred()
72+
73 def _handler(*a):
74 """Async helper."""
75 d.callback(True)
76
77=== renamed file 'tests/platform/windows/test_ipc.py' => 'tests/platform/ipc/test_windows.py'
78--- tests/platform/windows/test_ipc.py 2012-04-09 20:07:05 +0000
79+++ tests/platform/ipc/test_windows.py 2012-05-01 14:37:18 +0000
80@@ -45,8 +45,8 @@
81 FakedService,
82 FakeMainTestCase,
83 )
84-from ubuntuone.platform.windows import ipc
85-from ubuntuone.platform.windows.ipc import (
86+from ubuntuone.platform.ipc import windows as ipc
87+from ubuntuone.platform.ipc.windows import (
88 Config,
89 Events,
90 Folders,
91@@ -59,7 +59,7 @@
92 SyncDaemon,
93 ipc_client_connect,
94 )
95-from ubuntuone.platform.windows.ipc_client import (
96+from ubuntuone.platform.ipc.ipc_client import (
97 signal,
98 ConfigClient,
99 EventsClient,
100
101=== modified file 'tests/platform/linux/eventlog/test_zglog.py'
102--- tests/platform/linux/eventlog/test_zglog.py 2012-04-09 20:07:05 +0000
103+++ tests/platform/linux/eventlog/test_zglog.py 2012-05-01 14:37:18 +0000
104@@ -42,7 +42,7 @@
105 from zeitgeist.client import ZeitgeistClient
106 from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
107
108-from tests.platform.linux.test_dbus import DBusTwistedTestCase
109+from tests.platform.ipc.test_linux import DBusTwistedTestCase
110 from ubuntuone.eventlog.zglog import ZeitgeistLogger
111
112 SRCDIR = os.environ.get('SRCDIR', os.getcwd())
113@@ -97,7 +97,7 @@
114 client = ZeitgeistClient()
115 break
116 except RuntimeError:
117- if count > seconds*10:
118+ if count > seconds * 10:
119 raise
120 time.sleep(0.1)
121
122@@ -118,6 +118,7 @@
123 os.environ["ZEITGEIST_DATA_PATH"] = tempfolder
124 p = subprocess.Popen([zgdaemon], bufsize=4096, stdout=tempstdout,
125 stderr=tempstderr)
126+
127 def cleanup():
128 """Wait for the process to finish."""
129 p.terminate()
130
131=== modified file 'tests/platform/linux/test_credentials.py'
132--- tests/platform/linux/test_credentials.py 2012-04-09 20:07:05 +0000
133+++ tests/platform/linux/test_credentials.py 2012-05-01 14:37:18 +0000
134@@ -796,6 +796,7 @@
135 d = Deferred()
136
137 self.ref_count = 0
138+
139 def parallel_counter(*args):
140 """Make the check."""
141 self.ref_count += 1
142
143=== modified file 'ubuntuone/platform/__init__.py'
144--- ubuntuone/platform/__init__.py 2012-04-27 20:38:13 +0000
145+++ ubuntuone/platform/__init__.py 2012-05-01 14:37:18 +0000
146@@ -43,6 +43,8 @@
147 from ubuntuone.platform import linux
148 source = linux
149
150+from ubuntuone.platform import ipc
151+
152 # This imports needs to be here in order to be included in this namespace
153 from ubuntuone.platform import credentials
154 from ubuntuone.platform import tools
155@@ -109,5 +111,5 @@
156 _GeneralINotifyProcessor = source._GeneralINotifyProcessor
157
158 # IPC
159-ExternalInterface = source.ExternalInterface
160-is_already_running = source.is_already_running
161+ExternalInterface = ipc.ExternalInterface
162+is_already_running = ipc.is_already_running
163
164=== added directory 'ubuntuone/platform/ipc'
165=== added file 'ubuntuone/platform/ipc/__init__.py'
166--- ubuntuone/platform/ipc/__init__.py 1970-01-01 00:00:00 +0000
167+++ ubuntuone/platform/ipc/__init__.py 2012-05-01 14:37:18 +0000
168@@ -0,0 +1,42 @@
169+# -*- coding: utf-8 *-*
170+#
171+# Copyright 2012 Canonical Ltd.
172+#
173+# This program is free software: you can redistribute it and/or modify it
174+# under the terms of the GNU General Public License version 3, as published
175+# by the Free Software Foundation.
176+#
177+# This program is distributed in the hope that it will be useful, but
178+# WITHOUT ANY WARRANTY; without even the implied warranties of
179+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
180+# PURPOSE. See the GNU General Public License for more details.
181+#
182+# You should have received a copy of the GNU General Public License along
183+# with this program. If not, see <http://www.gnu.org/licenses/>.
184+#
185+# In addition, as a special exception, the copyright holders give
186+# permission to link the code of portions of this program with the
187+# OpenSSL library under certain conditions as described in each
188+# individual source file, and distribute linked combinations
189+# including the two.
190+# You must obey the GNU General Public License in all respects
191+# for all of the code used other than OpenSSL. If you modify
192+# file(s) with this exception, you may extend this exception to your
193+# version of the file(s), but you are not obligated to do so. If you
194+# do not wish to do so, delete this exception statement from your
195+# version. If you delete this exception statement from all source
196+# files in the program, then also delete it here.
197+"""IPC module."""
198+
199+import sys
200+
201+
202+if sys.platform == "win32":
203+ from ubuntuone.platform.ipc import windows as source
204+ ExternalInterface = source.IPCInterface
205+else:
206+ from ubuntuone.platform.ipc import linux as source
207+ ExternalInterface = source.DBusInterface
208+
209+
210+is_already_running = source.is_already_running
211
212=== renamed file 'ubuntuone/platform/windows/ipc_client.py' => 'ubuntuone/platform/ipc/ipc_client.py'
213--- ubuntuone/platform/windows/ipc_client.py 2012-04-10 18:11:54 +0000
214+++ ubuntuone/platform/ipc/ipc_client.py 2012-05-01 14:37:18 +0000
215@@ -34,7 +34,7 @@
216 from twisted.internet import defer
217 from twisted.spread.pb import Referenceable, PBClientFactory
218
219-from ubuntuone.platform.windows.ipc import RemoteMeta, ipc_client_connect
220+from ubuntuone.platform.ipc.windows import RemoteMeta, ipc_client_connect
221
222 logger = logging.getLogger("ubuntuone.SyncDaemon.Client")
223
224
225=== renamed file 'ubuntuone/platform/linux/dbus_interface.py' => 'ubuntuone/platform/ipc/linux.py'
226=== renamed file 'ubuntuone/platform/windows/ipc.py' => 'ubuntuone/platform/ipc/windows.py'
227=== modified file 'ubuntuone/platform/linux/__init__.py'
228--- ubuntuone/platform/linux/__init__.py 2012-04-27 20:38:13 +0000
229+++ ubuntuone/platform/linux/__init__.py 2012-05-01 14:37:18 +0000
230@@ -75,7 +75,3 @@
231 _GeneralINotifyProcessor,
232 )
233 from ubuntuone.platform.linux import notification
234-from ubuntuone.platform.linux.dbus_interface import (
235- DBusInterface as ExternalInterface,
236- is_already_running,
237-)
238
239=== modified file 'ubuntuone/platform/tools/linux.py'
240--- ubuntuone/platform/tools/linux.py 2012-04-09 20:07:05 +0000
241+++ ubuntuone/platform/tools/linux.py 2012-05-01 14:37:18 +0000
242@@ -34,7 +34,7 @@
243 from dbus.exceptions import DBusException
244 from twisted.internet import defer
245
246-from ubuntuone.platform.linux.dbus_interface import (
247+from ubuntuone.platform.ipc.linux import (
248 is_already_running,
249 DBUS_IFACE_NAME,
250 DBUS_IFACE_STATUS_NAME,
251
252=== modified file 'ubuntuone/platform/tools/windows.py'
253--- ubuntuone/platform/tools/windows.py 2012-04-11 13:12:26 +0000
254+++ ubuntuone/platform/tools/windows.py 2012-05-01 14:37:18 +0000
255@@ -36,8 +36,8 @@
256 from twisted.internet import defer
257 from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
258
259-from ubuntuone.platform.windows.ipc import is_already_running
260-from ubuntuone.platform.windows.ipc_client import UbuntuOneClient
261+from ubuntuone.platform.ipc.windows import is_already_running
262+from ubuntuone.platform.ipc.ipc_client import UbuntuOneClient
263
264
265 # make pyflakes happy since we can't disable the warning
266
267=== modified file 'ubuntuone/platform/windows/__init__.py'
268--- ubuntuone/platform/windows/__init__.py 2012-04-27 20:39:54 +0000
269+++ ubuntuone/platform/windows/__init__.py 2012-05-01 14:37:18 +0000
270@@ -85,7 +85,3 @@
271 NotifyProcessor as _GeneralINotifyProcessor,
272 )
273 from ubuntuone.platform.windows import notification
274-from ubuntuone.platform.windows.ipc import (
275- IPCInterface as ExternalInterface,
276- is_already_running,
277-)

Subscribers

People subscribed via source and target branches