Merge lp:~alecu/ubuntuone-client/use-standard-reactor into lp:ubuntuone-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1042
Merged at revision: 1038
Proposed branch: lp:~alecu/ubuntuone-client/use-standard-reactor
Merge into: lp:ubuntuone-client
Diff against target: 207 lines (+25/-38)
9 files modified
bin/ubuntuone-syncdaemon (+2/-2)
run-tests.bat (+1/-1)
tests/platform/windows/run_sdtool.py (+2/-3)
tests/platform/windows/test_ipc.py (+3/-3)
tests/platform/windows/test_tools.py (+2/-2)
ubuntuone/platform/windows/__init__.py (+3/-7)
ubuntuone/platform/windows/ipc.py (+8/-8)
ubuntuone/platform/windows/ipc_client.py (+1/-1)
ubuntuone/platform/windows/tools.py (+3/-11)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/use-standard-reactor
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
John Lenton (community) Approve
Review via email: mp+66521@code.launchpad.net

Commit message

Use the standard reactor on windows. (LP: #803640)

Description of the change

Use the standard reactor on windows. (LP: #803640)

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-syncdaemon'
2--- bin/ubuntuone-syncdaemon 2011-06-21 17:01:47 +0000
3+++ bin/ubuntuone-syncdaemon 2011-06-30 21:21:22 +0000
4@@ -21,8 +21,8 @@
5 import sys
6
7 if sys.platform == 'win32':
8- from txnamedpipes.reactor import install
9- install()
10+ # use the standard reactor on windows
11+ pass
12 else:
13 from twisted.internet import glib2reactor
14 glib2reactor.install()
15
16=== modified file 'run-tests.bat'
17--- run-tests.bat 2011-06-22 03:49:08 +0000
18+++ run-tests.bat 2011-06-30 21:21:22 +0000
19@@ -52,7 +52,7 @@
20 ECHO Python found, executing the tests...
21 COPY windows\clientdefs.py ubuntuone\clientdefs.py
22 :: execute the tests with a number of ignored linux only modules
23-"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1trial" --reactor=txnp -c tests -p tests\platform\linux %1
24+"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1trial" --reactor=twisted -c tests -p tests\platform\linux %1
25 "%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1lint"
26 :: test for style if we can, if pep8 is not present, move to the end
27 IF EXIST "%PYTHONPATH%Scripts\pep8.exe"
28
29=== modified file 'tests/platform/windows/run_sdtool.py'
30--- tests/platform/windows/run_sdtool.py 2011-06-27 14:58:10 +0000
31+++ tests/platform/windows/run_sdtool.py 2011-06-30 21:21:22 +0000
32@@ -17,8 +17,7 @@
33 # with this program. If not, see <http://www.gnu.org/licenses/>.
34 """Small example of how to use the sdtools on windows."""
35
36-from txnamedpipes.reactor import install
37-install()
38+# we use the standard reactor on windows
39 from twisted.internet import reactor, defer
40 from ubuntuone.platform.windows import tools
41
42@@ -55,4 +54,4 @@
43
44 if __name__ == '__main__':
45 reactor.callLater(0, print_test)
46- reactor.run()
47\ No newline at end of file
48+ reactor.run()
49
50=== modified file 'tests/platform/windows/test_ipc.py'
51--- tests/platform/windows/test_ipc.py 2011-06-30 19:05:16 +0000
52+++ tests/platform/windows/test_ipc.py 2011-06-30 21:21:22 +0000
53@@ -58,15 +58,15 @@
54 SharesClient
55 )
56
57-TEST_PIPE_URL = "\\\\.\\pipe\\ubuntuone_sso\\tests_%s"
58+TEST_HOST_PORT = "127.0.0.1", 40404
59
60
61 class BaseIPCTestCase(TestCase):
62- """Set the ipc to a random port/pipe for this instance."""
63+ """Set the ipc to a random port for this instance."""
64
65 def setUp(self):
66 """Initialize this test instance."""
67- self.patch(ipc, "NAMED_PIPE_URL", TEST_PIPE_URL)
68+ self.patch(ipc, "HOST_PORT", TEST_HOST_PORT)
69
70
71 class SaveProtocolServerFactory(PBServerFactory):
72
73=== modified file 'tests/platform/windows/test_tools.py'
74--- tests/platform/windows/test_tools.py 2011-06-30 20:00:25 +0000
75+++ tests/platform/windows/test_tools.py 2011-06-30 21:21:22 +0000
76@@ -42,7 +42,7 @@
77 SyncDaemonTool,
78 )
79
80-TEST_TOOLS_PIPE_URL = "\\\\.\\pipe\\ubuntuone_sso\\test_tools_%s"
81+TEST_TOOLS_HOST_PORT = "127.0.0.1", 40405
82
83
84 class SaveProtocolServerFactory(PBServerFactory):
85@@ -135,7 +135,7 @@
86 self.folders, self.files)
87 self.server_factory = SaveProtocolServerFactory(self.syncdaemon_root)
88 # pylint: disable=E1101
89- self.patch(ipc, "NAMED_PIPE_URL", TEST_TOOLS_PIPE_URL)
90+ self.patch(ipc, "HOST_PORT", TEST_TOOLS_HOST_PORT)
91 self.listener = ipc_server_listen(self.server_factory)
92 self.sdtool = SyncDaemonTool()
93
94
95=== modified file 'ubuntuone/platform/windows/__init__.py'
96--- ubuntuone/platform/windows/__init__.py 2011-06-30 19:05:16 +0000
97+++ ubuntuone/platform/windows/__init__.py 2011-06-30 21:21:22 +0000
98@@ -106,10 +106,6 @@
99
100 def is_already_running():
101 """Return if the sd is running by asking the named pipe."""
102- from win32pipe import CallNamedPipe
103- from ubuntuone.platform.windows.ipc import get_pipe_name
104- try:
105- CallNamedPipe(get_pipe_name(), '', 512, 0)
106- return True
107- except:
108- return False
109+ #TODO: Do not start two instances of this process
110+ # https://launchpad.net/bugs/803672
111+ return False
112
113=== modified file 'ubuntuone/platform/windows/ipc.py'
114--- ubuntuone/platform/windows/ipc.py 2011-06-30 19:05:16 +0000
115+++ ubuntuone/platform/windows/ipc.py 2011-06-30 21:21:22 +0000
116@@ -21,8 +21,6 @@
117 import logging
118
119 from threading import Thread
120-from win32api import GetUserNameEx
121-from win32con import NameSamCompatible
122
123 from twisted.internet import defer, reactor
124 from twisted.spread.pb import Referenceable, Root, PBServerFactory
125@@ -45,25 +43,27 @@
126 )
127
128 logger = logging.getLogger("ubuntuone.SyncDaemon.Pb")
129-NAMED_PIPE_URL = "\\\\.\\pipe\\ubuntuone_client\\%s"
130+HOST_PORT = "127.0.0.1", 50002
131 CLIENT_NOT_PROCESSED = -1
132
133
134-def get_pipe_name():
135- """Builds the pipe name for this user."""
136- return NAMED_PIPE_URL % GetUserNameEx(NameSamCompatible)
137+def get_sd_pb_hostport():
138+ """Returns the host and port for this user."""
139+ return HOST_PORT
140
141
142 def ipc_server_listen(server_factory):
143 """Connect the IPC server factory."""
144+ host, port = get_sd_pb_hostport()
145 # pylint: disable=E1101
146- return reactor.listenPipe(get_pipe_name(), server_factory)
147+ return reactor.listenTCP(port, server_factory, interface=host)
148
149
150 def ipc_client_connect(client_factory):
151 """Connect the IPC client factory."""
152+ host, port = get_sd_pb_hostport()
153 # pylint: disable=E1101
154- return reactor.connectPipe(get_pipe_name(), client_factory)
155+ return reactor.connectTCP(host, port, client_factory)
156
157
158 class NoAccessToken(Exception):
159
160=== modified file 'ubuntuone/platform/windows/ipc_client.py'
161--- ubuntuone/platform/windows/ipc_client.py 2011-06-30 19:05:16 +0000
162+++ ubuntuone/platform/windows/ipc_client.py 2011-06-30 21:21:22 +0000
163@@ -730,7 +730,7 @@
164 defer.returnValue(self)
165 except Exception, e:
166 raise SyncDaemonClientConnectionError(
167- 'Could not connect to the syncdaemon on pipe.', e)
168+ 'Could not connect to the syncdaemon ipc.', e)
169 # pylint: disable=W0702
170
171 @defer.inlineCallbacks
172
173=== modified file 'ubuntuone/platform/windows/tools.py'
174--- ubuntuone/platform/windows/tools.py 2011-06-30 19:20:39 +0000
175+++ ubuntuone/platform/windows/tools.py 2011-06-30 21:21:22 +0000
176@@ -24,13 +24,10 @@
177 import subprocess
178 import sys
179
180-from win32api import CloseHandle
181-from win32file import CreateFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING
182 from twisted.internet import defer, reactor
183 from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
184
185 from ubuntuone.syncdaemon.config import get_user_config
186-from ubuntuone.platform.windows.ipc import get_pipe_name
187 from ubuntuone.platform.windows.ipc_client import UbuntuOneClient
188
189 U1_REG_PATH = r'Software\\Ubuntu One'
190@@ -42,14 +39,9 @@
191 Running means the name is registered in the given bus.
192
193 """
194- pipe = get_pipe_name()
195- try:
196- handle = CreateFile(pipe, GENERIC_READ, FILE_SHARE_READ, None,
197- OPEN_EXISTING, 0,None)
198- CloseHandle(handle)
199- return True
200- except:
201- return False
202+ #TODO: Do not start two instances of this process
203+ # https://launchpad.net/bugs/803672
204+ return False
205
206
207 class SyncDaemonTool(object):

Subscribers

People subscribed via source and target branches