Merge lp:~mandel/ubuntuone-client/fix-881186 into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1164
Merged at revision: 1163
Proposed branch: lp:~mandel/ubuntuone-client/fix-881186
Merge into: lp:ubuntuone-client
Diff against target: 89 lines (+33/-6)
2 files modified
tests/platform/windows/test_tools.py (+21/-6)
ubuntuone/platform/tools/windows.py (+12/-0)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/fix-881186
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+83957@code.launchpad.net

Commit message

Fixes lp:881186

Ensure that if the path is missing we let the client now that we did not manage to start the sd.

Description of the change

Fixes lp:881186

Ensure that if the path is missing we let the client now that we did not manage to start the sd.

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/windows/test_tools.py'
2--- tests/platform/windows/test_tools.py 2011-10-28 19:17:47 +0000
3+++ tests/platform/windows/test_tools.py 2011-11-30 15:00:44 +0000
4@@ -14,14 +14,18 @@
5 # You should have received a copy of the GNU General Public License along
6 # with this program. If not, see <http://www.gnu.org/licenses/>.
7
8+import sys
9
10 from twisted.internet import defer
11 from twisted.trial.unittest import TestCase
12
13-from ubuntuone.platform.tools.windows import (
14- SyncDaemonToolProxy,
15- UbuntuOneClient,
16-)
17+from ubuntuone.platform.tools import windows
18+
19+
20+# ugly trick to stop pylint for complaining about
21+# WindowsError on Linux
22+if sys.platform != 'win32':
23+ WindowsError = None
24
25
26 class TestSyncDaemonTool(TestCase):
27@@ -30,8 +34,8 @@
28 @defer.inlineCallbacks
29 def setUp(self):
30 yield super(TestSyncDaemonTool, self).setUp()
31- self.patch(UbuntuOneClient, "connect", lambda _: defer.Deferred())
32- self.sdtool = SyncDaemonToolProxy()
33+ self.patch(windows.UbuntuOneClient, "connect", lambda _: defer.Deferred())
34+ self.sdtool = windows.SyncDaemonToolProxy()
35
36 def test_call_after_connection(self):
37 """Test the _call_after_connection method."""
38@@ -79,3 +83,14 @@
39 attr = getattr(self.sdtool, attr_name)
40 func_name = getattr(attr, "__name__", None)
41 self.assertNotEqual(func_name, "call_after_connection_inner")
42+
43+ def test_start_missing_exe(self):
44+ """Test starting the service when the exe is missing."""
45+ # file is missing
46+ self.patch(windows.os.path, 'exists', lambda f: False)
47+ key = 'key'
48+ path = 'path/to/exe'
49+ self.patch(windows, 'OpenKey', lambda k,p: key)
50+ self.patch(windows, 'QueryValueEx', lambda k,p: path)
51+
52+ self.assertFailure(self.sdtool.start(), WindowsError)
53
54=== modified file 'ubuntuone/platform/tools/windows.py'
55--- ubuntuone/platform/tools/windows.py 2011-11-07 15:39:32 +0000
56+++ ubuntuone/platform/tools/windows.py 2011-11-30 15:00:44 +0000
57@@ -16,7 +16,10 @@
58
59 """SyncDaemon Tools."""
60
61+import errno
62 import subprocess
63+import sys
64+import os
65
66 from twisted.internet import defer
67 from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
68@@ -30,6 +33,11 @@
69 U1_REG_PATH = r'Software\\Ubuntu One'
70 SD_INSTALL_PATH = 'SyncDaemonInstallPath'
71
72+# ugly trick to stop pylint for complaining about
73+# WindowsError on Linux
74+if sys.platform != 'win32':
75+ WindowsError = None
76+
77
78 class IPCError(Exception):
79 """An IPC specific error signal."""
80@@ -154,5 +162,9 @@
81 # to launch the sd on windows
82 key = OpenKey(HKEY_LOCAL_MACHINE, U1_REG_PATH)
83 path = QueryValueEx(key, SD_INSTALL_PATH)[0]
84+ if not os.path.exists(path):
85+ # either the .exe was moved of the value is wrong
86+ return defer.fail(WindowsError(errno.ENOENT,
87+ 'Could not start syncdaemon: File not found %s' % path))
88 p = subprocess.Popen([path])
89 return defer.succeed(p)

Subscribers

People subscribed via source and target branches