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
=== modified file 'bin/ubuntuone-syncdaemon'
--- bin/ubuntuone-syncdaemon 2011-06-21 17:01:47 +0000
+++ bin/ubuntuone-syncdaemon 2011-06-30 21:21:22 +0000
@@ -21,8 +21,8 @@
21import sys21import sys
2222
23if sys.platform == 'win32':23if sys.platform == 'win32':
24 from txnamedpipes.reactor import install24 # use the standard reactor on windows
25 install()25 pass
26else:26else:
27 from twisted.internet import glib2reactor27 from twisted.internet import glib2reactor
28 glib2reactor.install()28 glib2reactor.install()
2929
=== modified file 'run-tests.bat'
--- run-tests.bat 2011-06-22 03:49:08 +0000
+++ run-tests.bat 2011-06-30 21:21:22 +0000
@@ -52,7 +52,7 @@
52ECHO Python found, executing the tests...52ECHO Python found, executing the tests...
53COPY windows\clientdefs.py ubuntuone\clientdefs.py53COPY windows\clientdefs.py ubuntuone\clientdefs.py
54:: execute the tests with a number of ignored linux only modules54:: execute the tests with a number of ignored linux only modules
55"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1trial" --reactor=txnp -c tests -p tests\platform\linux %155"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1trial" --reactor=twisted -c tests -p tests\platform\linux %1
56"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1lint"56"%PYTHONPATH%\python.exe" "%PYTHONPATH%\Scripts\u1lint"
57:: test for style if we can, if pep8 is not present, move to the end57:: test for style if we can, if pep8 is not present, move to the end
58IF EXIST "%PYTHONPATH%Scripts\pep8.exe"58IF EXIST "%PYTHONPATH%Scripts\pep8.exe"
5959
=== modified file 'tests/platform/windows/run_sdtool.py'
--- tests/platform/windows/run_sdtool.py 2011-06-27 14:58:10 +0000
+++ tests/platform/windows/run_sdtool.py 2011-06-30 21:21:22 +0000
@@ -17,8 +17,7 @@
17# with this program. If not, see <http://www.gnu.org/licenses/>.17# with this program. If not, see <http://www.gnu.org/licenses/>.
18"""Small example of how to use the sdtools on windows."""18"""Small example of how to use the sdtools on windows."""
1919
20from txnamedpipes.reactor import install20# we use the standard reactor on windows
21install()
22from twisted.internet import reactor, defer21from twisted.internet import reactor, defer
23from ubuntuone.platform.windows import tools22from ubuntuone.platform.windows import tools
2423
@@ -55,4 +54,4 @@
5554
56if __name__ == '__main__':55if __name__ == '__main__':
57 reactor.callLater(0, print_test)56 reactor.callLater(0, print_test)
58 reactor.run()
59\ No newline at end of file57\ No newline at end of file
58 reactor.run()
6059
=== modified file 'tests/platform/windows/test_ipc.py'
--- tests/platform/windows/test_ipc.py 2011-06-30 19:05:16 +0000
+++ tests/platform/windows/test_ipc.py 2011-06-30 21:21:22 +0000
@@ -58,15 +58,15 @@
58 SharesClient58 SharesClient
59)59)
6060
61TEST_PIPE_URL = "\\\\.\\pipe\\ubuntuone_sso\\tests_%s"61TEST_HOST_PORT = "127.0.0.1", 40404
6262
6363
64class BaseIPCTestCase(TestCase):64class BaseIPCTestCase(TestCase):
65 """Set the ipc to a random port/pipe for this instance."""65 """Set the ipc to a random port for this instance."""
6666
67 def setUp(self):67 def setUp(self):
68 """Initialize this test instance."""68 """Initialize this test instance."""
69 self.patch(ipc, "NAMED_PIPE_URL", TEST_PIPE_URL)69 self.patch(ipc, "HOST_PORT", TEST_HOST_PORT)
7070
7171
72class SaveProtocolServerFactory(PBServerFactory):72class SaveProtocolServerFactory(PBServerFactory):
7373
=== modified file 'tests/platform/windows/test_tools.py'
--- tests/platform/windows/test_tools.py 2011-06-30 20:00:25 +0000
+++ tests/platform/windows/test_tools.py 2011-06-30 21:21:22 +0000
@@ -42,7 +42,7 @@
42 SyncDaemonTool,42 SyncDaemonTool,
43)43)
4444
45TEST_TOOLS_PIPE_URL = "\\\\.\\pipe\\ubuntuone_sso\\test_tools_%s"45TEST_TOOLS_HOST_PORT = "127.0.0.1", 40405
4646
4747
48class SaveProtocolServerFactory(PBServerFactory):48class SaveProtocolServerFactory(PBServerFactory):
@@ -135,7 +135,7 @@
135 self.folders, self.files)135 self.folders, self.files)
136 self.server_factory = SaveProtocolServerFactory(self.syncdaemon_root)136 self.server_factory = SaveProtocolServerFactory(self.syncdaemon_root)
137 # pylint: disable=E1101137 # pylint: disable=E1101
138 self.patch(ipc, "NAMED_PIPE_URL", TEST_TOOLS_PIPE_URL)138 self.patch(ipc, "HOST_PORT", TEST_TOOLS_HOST_PORT)
139 self.listener = ipc_server_listen(self.server_factory)139 self.listener = ipc_server_listen(self.server_factory)
140 self.sdtool = SyncDaemonTool()140 self.sdtool = SyncDaemonTool()
141141
142142
=== modified file 'ubuntuone/platform/windows/__init__.py'
--- ubuntuone/platform/windows/__init__.py 2011-06-30 19:05:16 +0000
+++ ubuntuone/platform/windows/__init__.py 2011-06-30 21:21:22 +0000
@@ -106,10 +106,6 @@
106106
107def is_already_running():107def is_already_running():
108 """Return if the sd is running by asking the named pipe."""108 """Return if the sd is running by asking the named pipe."""
109 from win32pipe import CallNamedPipe109 #TODO: Do not start two instances of this process
110 from ubuntuone.platform.windows.ipc import get_pipe_name110 # https://launchpad.net/bugs/803672
111 try:111 return False
112 CallNamedPipe(get_pipe_name(), '', 512, 0)
113 return True
114 except:
115 return False
116112
=== modified file 'ubuntuone/platform/windows/ipc.py'
--- ubuntuone/platform/windows/ipc.py 2011-06-30 19:05:16 +0000
+++ ubuntuone/platform/windows/ipc.py 2011-06-30 21:21:22 +0000
@@ -21,8 +21,6 @@
21import logging21import logging
2222
23from threading import Thread23from threading import Thread
24from win32api import GetUserNameEx
25from win32con import NameSamCompatible
2624
27from twisted.internet import defer, reactor25from twisted.internet import defer, reactor
28from twisted.spread.pb import Referenceable, Root, PBServerFactory26from twisted.spread.pb import Referenceable, Root, PBServerFactory
@@ -45,25 +43,27 @@
45)43)
4644
47logger = logging.getLogger("ubuntuone.SyncDaemon.Pb")45logger = logging.getLogger("ubuntuone.SyncDaemon.Pb")
48NAMED_PIPE_URL = "\\\\.\\pipe\\ubuntuone_client\\%s"46HOST_PORT = "127.0.0.1", 50002
49CLIENT_NOT_PROCESSED = -147CLIENT_NOT_PROCESSED = -1
5048
5149
52def get_pipe_name():50def get_sd_pb_hostport():
53 """Builds the pipe name for this user."""51 """Returns the host and port for this user."""
54 return NAMED_PIPE_URL % GetUserNameEx(NameSamCompatible)52 return HOST_PORT
5553
5654
57def ipc_server_listen(server_factory):55def ipc_server_listen(server_factory):
58 """Connect the IPC server factory."""56 """Connect the IPC server factory."""
57 host, port = get_sd_pb_hostport()
59 # pylint: disable=E110158 # pylint: disable=E1101
60 return reactor.listenPipe(get_pipe_name(), server_factory)59 return reactor.listenTCP(port, server_factory, interface=host)
6160
6261
63def ipc_client_connect(client_factory):62def ipc_client_connect(client_factory):
64 """Connect the IPC client factory."""63 """Connect the IPC client factory."""
64 host, port = get_sd_pb_hostport()
65 # pylint: disable=E110165 # pylint: disable=E1101
66 return reactor.connectPipe(get_pipe_name(), client_factory)66 return reactor.connectTCP(host, port, client_factory)
6767
6868
69class NoAccessToken(Exception):69class NoAccessToken(Exception):
7070
=== modified file 'ubuntuone/platform/windows/ipc_client.py'
--- ubuntuone/platform/windows/ipc_client.py 2011-06-30 19:05:16 +0000
+++ ubuntuone/platform/windows/ipc_client.py 2011-06-30 21:21:22 +0000
@@ -730,7 +730,7 @@
730 defer.returnValue(self)730 defer.returnValue(self)
731 except Exception, e:731 except Exception, e:
732 raise SyncDaemonClientConnectionError(732 raise SyncDaemonClientConnectionError(
733 'Could not connect to the syncdaemon on pipe.', e)733 'Could not connect to the syncdaemon ipc.', e)
734 # pylint: disable=W0702734 # pylint: disable=W0702
735735
736 @defer.inlineCallbacks736 @defer.inlineCallbacks
737737
=== modified file 'ubuntuone/platform/windows/tools.py'
--- ubuntuone/platform/windows/tools.py 2011-06-30 19:20:39 +0000
+++ ubuntuone/platform/windows/tools.py 2011-06-30 21:21:22 +0000
@@ -24,13 +24,10 @@
24import subprocess24import subprocess
25import sys25import sys
2626
27from win32api import CloseHandle
28from win32file import CreateFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING
29from twisted.internet import defer, reactor27from twisted.internet import defer, reactor
30from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx28from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
3129
32from ubuntuone.syncdaemon.config import get_user_config30from ubuntuone.syncdaemon.config import get_user_config
33from ubuntuone.platform.windows.ipc import get_pipe_name
34from ubuntuone.platform.windows.ipc_client import UbuntuOneClient31from ubuntuone.platform.windows.ipc_client import UbuntuOneClient
3532
36U1_REG_PATH = r'Software\\Ubuntu One'33U1_REG_PATH = r'Software\\Ubuntu One'
@@ -42,14 +39,9 @@
42 Running means the name is registered in the given bus.39 Running means the name is registered in the given bus.
4340
44 """41 """
45 pipe = get_pipe_name()42 #TODO: Do not start two instances of this process
46 try:43 # https://launchpad.net/bugs/803672
47 handle = CreateFile(pipe, GENERIC_READ, FILE_SHARE_READ, None,44 return False
48 OPEN_EXISTING, 0,None)
49 CloseHandle(handle)
50 return True
51 except:
52 return False
5345
5446
55class SyncDaemonTool(object):47class SyncDaemonTool(object):

Subscribers

People subscribed via source and target branches