Merge lp:~dobey/ubuntuone-client/update-4-0 into lp:ubuntuone-client/stable-4-0

Proposed by dobey on 2012-06-19
Status: Merged
Approved by: dobey on 2012-06-19
Approved revision: no longer in the source branch.
Merged at revision: 1248
Proposed branch: lp:~dobey/ubuntuone-client/update-4-0
Merge into: lp:ubuntuone-client/stable-4-0
Diff against target: 1021 lines (+466/-133)
22 files modified
bin/ubuntuone-login (+1/-1)
data/syncdaemon.conf (+2/-1)
tests/platform/credentials/test_ipc_service.py (+1/-1)
tests/platform/credentials/test_linux.py (+27/-1)
tests/platform/filesystem_notifications/test_linux.py (+41/-0)
tests/platform/test_tools.py (+30/-0)
tests/platform/tools/__init__.py (+29/-0)
tests/platform/tools/test_darwin.py (+52/-0)
tests/platform/tools/test_tools.py (+4/-14)
tests/platform/tools/test_windows.py (+64/-0)
tests/syncdaemon/test_action_queue.py (+79/-12)
tests/syncdaemon/test_sync.py (+15/-7)
ubuntuone/platform/credentials/__init__.py (+5/-5)
ubuntuone/platform/credentials/dbus_service.py (+8/-3)
ubuntuone/platform/filesystem_notifications/linux.py (+10/-0)
ubuntuone/platform/tools/__init__.py (+6/-9)
ubuntuone/platform/tools/darwin.py (+0/-47)
ubuntuone/platform/tools/perspective_broker.py (+14/-17)
ubuntuone/platform/tools/windows.py (+56/-0)
ubuntuone/proxy/tunnel_client.py (+1/-1)
ubuntuone/syncdaemon/action_queue.py (+13/-12)
ubuntuone/syncdaemon/sync.py (+8/-2)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/update-4-0
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve on 2012-06-19
Eric Casteleijn (community) 2012-06-19 Approve on 2012-06-19
Review via email: mp+111063@code.launchpad.net

Commit Message

[Manuel de la Pena]

    Use the correct import for dbus service. (LP: #1014094).
    Refactored the tools code so that it is shared between windows and darwin (LP: #1002994).

[Guillermo Gonzalez]

    Force a "reput from local" when the server_hash (that came in the delta) is ""

[Mike McCracken]

    Use correct IPC mechanism on darwin for credentials (LP: #1013268)

[Facundo Batista]

    Fix failure handling when creating a share (LP: #1013180).

[Roberto Alsina]

    Added .goutputstream files to the ignore list (Fixes LP:1012620).

[Alejandro Cura]

    Add SSL verification to webapi calls.
    Validate SSL certificates (LP: #882062).
    Give the tunnel process a bit more time to account for dns resolving. (LP: #1006899)

[Roman Yepishev]

    Ignore IN_CLOSE_WRITE for directories.

[Diego Sarmentero]

    Decoding path for comparison (LP: #998079).

[Rodney Dawes]

    Use dbus.Dictionary to specify signature when using empty dicts for SSO calls. (LP: #711162)

To post a comment you must log in.
Eric Casteleijn (thisfred) wrote :

Can't see anything wrong

review: Approve
Mike McCracken (mikemc) wrote :

looks ok

review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (18.5 KiB)

The attempt to merge lp:~dobey/ubuntuone-client/update-4-0 into lp:ubuntuone-client/stable-4-0 failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.69
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.5
checking for libtool >= 1.5...
  testing libtoolize... found 2.4.2
checking for intltool >= 0.30...
  testing intltoolize... found 0.50.2
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.26
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.18
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... y...

Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (26.3 KiB)

The attempt to merge lp:~dobey/ubuntuone-client/update-4-0 into lp:ubuntuone-client/stable-4-0 failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.69
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.5
checking for libtool >= 1.5...
  testing libtoolize... found 2.4.2
checking for intltool >= 0.30...
  testing intltoolize... found 0.50.2
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.26
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.18
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... y...

Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (391.8 KiB)

The attempt to merge lp:~dobey/ubuntuone-client/update-4-0 into lp:ubuntuone-client/stable-4-0 failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.69
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.5
checking for libtool >= 1.5...
  testing libtoolize... found 2.4.2
checking for intltool >= 0.30...
  testing intltoolize... found 0.50.2
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.26
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.18
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... y...

1248. By Guillermo Gonzalez on 2012-06-19

[Manuel de la Pena]

    Use the correct import for dbus service. (LP: #1014094).
    Refactored the tools code so that it is shared between windows and darwin (LP: #1002994).

[Guillermo Gonzalez]

    Force a "reput from local" when the server_hash (that came in the delta) is ""

[Mike McCracken]

    Use correct IPC mechanism on darwin for credentials (LP: #1013268)

[Facundo Batista]

    Fix failure handling when creating a share (LP: #1013180).

[Roberto Alsina]

    Added .goutputstream files to the ignore list (Fixes LP:1012620).

[Alejandro Cura]

    Add SSL verification to webapi calls.
    Validate SSL certificates (LP: #882062).
    Give the tunnel process a bit more time to account for dns resolving. (LP: #1006899)

[Roman Yepishev]

    Ignore IN_CLOSE_WRITE for directories.

[Diego Sarmentero]

    Decoding path for comparison (LP: #998079).

[Rodney Dawes]

    Use dbus.Dictionary to specify signature when using empty dicts for SSO calls. (LP: #711162)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-login'
2--- bin/ubuntuone-login 2012-04-09 20:07:05 +0000
3+++ bin/ubuntuone-login 2012-06-19 17:02:31 +0000
4@@ -44,7 +44,7 @@
5
6 from ubuntuone.logger import basic_formatter
7 from ubuntuone.platform.credentials import logger
8-from ubuntuone.platform.credentials.linux import (
9+from ubuntuone.platform.credentials.dbus_service import (
10 DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH,
11 CredentialsManagement,
12 )
13
14=== modified file 'data/syncdaemon.conf'
15--- data/syncdaemon.conf 2012-03-05 13:37:12 +0000
16+++ data/syncdaemon.conf 2012-06-19 17:02:31 +0000
17@@ -2,7 +2,7 @@
18 host.default = fs-1.one.ubuntu.com
19 host.help = The server address
20
21-dns_srv.default = _https._tcp.fs.ubuntuone.com
22+dns_srv.default = _https._tcp.fs.one.ubuntu.com
23 dns_srv.help = The DNS SRV record
24
25 disable_ssl_verify.default = False
26@@ -84,6 +84,7 @@
27 \A.*\.swpx\Z
28 \A\..*\.tmp\Z
29 \A\.~lock\..*#\Z
30+ \A\.goutputstream-.*\Z
31
32 use_trash.default = True
33 use_trash.parser = bool
34
35=== renamed file 'tests/platform/credentials/test_windows.py' => 'tests/platform/credentials/test_ipc_service.py'
36--- tests/platform/credentials/test_windows.py 2012-05-14 19:04:43 +0000
37+++ tests/platform/credentials/test_ipc_service.py 2012-06-19 17:02:31 +0000
38@@ -38,7 +38,7 @@
39 from contrib.testing.testcase import FAKED_CREDENTIALS
40 from ubuntuone.devtools.handlers import MementoHandler
41 from ubuntuone.platform.credentials import APP_NAME
42-from ubuntuone.platform.credentials.windows import (
43+from ubuntuone.platform.credentials.ipc_service import (
44 CredentialsManagement,
45 RemovableSignal,
46 logger,
47
48=== modified file 'tests/platform/credentials/test_linux.py'
49--- tests/platform/credentials/test_linux.py 2012-05-14 19:04:43 +0000
50+++ tests/platform/credentials/test_linux.py 2012-06-19 17:02:31 +0000
51@@ -46,7 +46,7 @@
52 logger,
53 UI_PARAMS,
54 )
55-from ubuntuone.platform.credentials.linux import (
56+from ubuntuone.platform.credentials.dbus_service import (
57 APP_NAME,
58 CredentialsManagement,
59 dbus,
60@@ -402,6 +402,32 @@
61 self.assertEqual(self.sso_server._args, params)
62
63
64+class DictSignatureTestCase(DBusTestCase):
65+ """Test the errors with dict signatures."""
66+
67+ def verify(self, app_name, options_dict, reply_handler, error_handler):
68+ """Verify that the options_dict is a dbus.Dictionary."""
69+ self.assertIsInstance(options_dict, dbus.Dictionary)
70+
71+ def test_find_credentials_dict_signature(self):
72+ """Test for find_credentials."""
73+ creds_man = CredentialsManagement()
74+ self.patch(creds_man.sso_proxy, "find_credentials", self.verify)
75+ creds_man.find_credentials()
76+
77+ def test_find_credentials_sync_dict_signature(self):
78+ """Test for find_credentials_sync."""
79+ creds_man = CredentialsManagement()
80+ self.patch(creds_man.sso_proxy, "find_credentials_sync", self.verify)
81+ creds_man.find_credentials_sync()
82+
83+ def test_clear_credentials_dict_signature(self):
84+ """Test for clear_credentials."""
85+ creds_man = CredentialsManagement()
86+ self.patch(creds_man.sso_proxy, "clear_credentials", self.verify)
87+ creds_man.clear_credentials()
88+
89+
90 class SameAppNoErrorTestCase(CredentialsManagementTestCase):
91 """Test case when the app_name matches APP_NAME and there was no error."""
92
93
94=== modified file 'tests/platform/filesystem_notifications/test_linux.py'
95--- tests/platform/filesystem_notifications/test_linux.py 2012-04-30 15:19:03 +0000
96+++ tests/platform/filesystem_notifications/test_linux.py 2012-06-19 17:02:31 +0000
97@@ -34,6 +34,7 @@
98 import os
99
100 from twisted.internet import defer, reactor
101+from twisted.trial.unittest import TestCase as PlainTestCase
102
103 from ubuntuone.syncdaemon import (
104 event_queue,
105@@ -436,3 +437,43 @@
106 self.monitor.rm_watch(path_ancestor)
107 self.assertEqual(self.monitor._general_watchs, {})
108 self.assertEqual(self.monitor._ancestors_watchs, {})
109+
110+
111+class FakeEvent(object):
112+ """A fake event."""
113+
114+ mask = 0
115+ name = ""
116+
117+
118+class ECryptFsTestCase(PlainTestCase):
119+ """Tests for the eCryptFS weirdness."""
120+
121+ def test_close_write_on_folders_is_ignored(self):
122+ """When eCryptFS sends CLOSE_WRITE on folders, ignore it"""
123+ result = []
124+ monitor = None
125+ processor = filesystem_notifications._GeneralINotifyProcessor(monitor)
126+ self.patch(processor.general_processor, "push_event", result.append)
127+
128+ fake_event = FakeEvent()
129+ fake_event.mask = filesystem_notifications.pyinotify.IN_ISDIR
130+ fake_event.name = "/fake/directory/path"
131+ processor.process_IN_CLOSE_WRITE(fake_event)
132+
133+ self.assertNotIn(fake_event, result)
134+
135+
136+ def test_close_write_on_files_is_handled(self):
137+ """When anything sends CLOSE_WRITE on files, handle it."""
138+ result = []
139+ monitor = None
140+ processor = filesystem_notifications._GeneralINotifyProcessor(monitor)
141+ self.patch(processor.general_processor, "push_event", result.append)
142+
143+ fake_event = FakeEvent()
144+ fake_event.mask = filesystem_notifications.pyinotify.IN_CLOSE_WRITE
145+ fake_event.name = "/fake/directory/path"
146+ processor.process_IN_CLOSE_WRITE(fake_event)
147+
148+ self.assertIn(fake_event, result)
149
150=== modified file 'tests/platform/test_tools.py'
151--- tests/platform/test_tools.py 2012-04-09 20:07:05 +0000
152+++ tests/platform/test_tools.py 2012-06-19 17:02:31 +0000
153@@ -691,6 +691,36 @@
154 self.assertEqual('http://example.com', file_info['public_url'])
155
156 @defer.inlineCallbacks
157+ def test_change_public_access_with_unicode(self):
158+ """Test change_public_access."""
159+ # XXX: change public access is the only class that expects uuid's as
160+ # params this may indicate that we need to refactor that class to be
161+ # consistent with the rest of syncdaemon where ID's are always strings
162+ node_id = '59809aae-9c5a-47e0-b37c-5abbfbe7c50a'
163+ share_id = ""
164+ path = os.path.join(self.root_dir, u"ñoño")
165+ path = path.encode('utf-8')
166+ self.fs.create(path, "")
167+ self.fs.set_node_id(path, node_id)
168+
169+ def change_public_access(share_id, node_id, is_public):
170+ """Fake change_public_access"""
171+ self.main.event_q.push("AQ_CHANGE_PUBLIC_ACCESS_OK",
172+ share_id=share_id, node_id=node_id,
173+ is_public=True,
174+ public_url='http://example.com')
175+ self.patch(self.main.action_q, 'change_public_access',
176+ change_public_access)
177+
178+ file_info = yield self.tool.change_public_access(path, True)
179+
180+ self.assertEqual(path.decode('utf-8'), file_info['path'])
181+ self.assertEqual(share_id, file_info['share_id'])
182+ self.assertEqual(node_id, file_info['node_id'])
183+ self.assertEqual('True', file_info['is_public'])
184+ self.assertEqual('http://example.com', file_info['public_url'])
185+
186+ @defer.inlineCallbacks
187 def test_get_public_files(self):
188 """Get the public files."""
189 node_id = '59809aae-9c5a-47e0-b37c-5abbfbe7c50a'
190
191=== added directory 'tests/platform/tools'
192=== added file 'tests/platform/tools/__init__.py'
193--- tests/platform/tools/__init__.py 1970-01-01 00:00:00 +0000
194+++ tests/platform/tools/__init__.py 2012-06-19 17:02:31 +0000
195@@ -0,0 +1,29 @@
196+# -*- coding: utf-8 -*-
197+#
198+# Copyright 2012 Canonical Ltd.
199+#
200+# This program is free software: you can redistribute it and/or modify it
201+# under the terms of the GNU General Public License version 3, as published
202+# by the Free Software Foundation.
203+#
204+# This program is distributed in the hope that it will be useful, but
205+# WITHOUT ANY WARRANTY; without even the implied warranties of
206+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
207+# PURPOSE. See the GNU General Public License for more details.
208+#
209+# You should have received a copy of the GNU General Public License along
210+# with this program. If not, see <http://www.gnu.org/licenses/>.
211+#
212+# In addition, as a special exception, the copyright holders give
213+# permission to link the code of portions of this program with the
214+# OpenSSL library under certain conditions as described in each
215+# individual source file, and distribute linked combinations
216+# including the two.
217+# You must obey the GNU General Public License in all respects
218+# for all of the code used other than OpenSSL. If you modify
219+# file(s) with this exception, you may extend this exception to your
220+# version of the file(s), but you are not obligated to do so. If you
221+# do not wish to do so, delete this exception statement from your
222+# version. If you delete this exception statement from all source
223+# files in the program, then also delete it here.
224+"""Tests for the tools code."""
225
226=== added file 'tests/platform/tools/test_darwin.py'
227--- tests/platform/tools/test_darwin.py 1970-01-01 00:00:00 +0000
228+++ tests/platform/tools/test_darwin.py 2012-06-19 17:02:31 +0000
229@@ -0,0 +1,52 @@
230+# -*- coding: utf-8 -*-
231+#
232+# Copyright 2012 Canonical Ltd.
233+#
234+# This program is free software: you can redistribute it and/or modify it
235+# under the terms of the GNU General Public License version 3, as published
236+# by the Free Software Foundation.
237+#
238+# This program is distributed in the hope that it will be useful, but
239+# WITHOUT ANY WARRANTY; without even the implied warranties of
240+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
241+# PURPOSE. See the GNU General Public License for more details.
242+#
243+# You should have received a copy of the GNU General Public License along
244+# with this program. If not, see <http://www.gnu.org/licenses/>.
245+#
246+# In addition, as a special exception, the copyright holders give
247+# permission to link the code of portions of this program with the
248+# OpenSSL library under certain conditions as described in each
249+# individual source file, and distribute linked combinations
250+# including the two.
251+# You must obey the GNU General Public License in all respects
252+# for all of the code used other than OpenSSL. If you modify
253+# file(s) with this exception, you may extend this exception to your
254+# version of the file(s), but you are not obligated to do so. If you
255+# do not wish to do so, delete this exception statement from your
256+# version. If you delete this exception statement from all source
257+# files in the program, then also delete it here.
258+"""Tests for the tools windows code."""
259+
260+from twisted.internet import defer
261+from twisted.trial.unittest import TestCase
262+
263+from ubuntuone.platform.tools import perspective_broker, darwin
264+
265+
266+class TestStartSyncdaemon(TestCase):
267+ """Test the process of launching sd."""
268+
269+ @defer.inlineCallbacks
270+ def setUp(self):
271+ yield super(TestStartSyncdaemon, self).setUp()
272+ self.patch(perspective_broker.UbuntuOneClient, "connect",
273+ lambda _: defer.Deferred())
274+ self.sdtool = perspective_broker.SyncDaemonToolProxy()
275+ self.calls = {}
276+
277+ def test_start_missing_exe(self):
278+ """Test starting the service when the exe is missing."""
279+ # file is missing
280+ self.patch(darwin.os.path, 'exists', lambda f: False)
281+ self.assertFailure(self.sdtool.start(), Exception)
282
283=== renamed file 'tests/platform/windows/test_tools.py' => 'tests/platform/tools/test_tools.py'
284--- tests/platform/windows/test_tools.py 2012-04-16 12:21:35 +0000
285+++ tests/platform/tools/test_tools.py 2012-06-19 17:02:31 +0000
286@@ -34,7 +34,7 @@
287 from twisted.internet import defer
288 from twisted.trial.unittest import TestCase
289
290-from ubuntuone.platform.tools import windows
291+from ubuntuone.platform.tools import perspective_broker
292
293
294 # ugly trick to stop pylint for complaining about
295@@ -49,8 +49,9 @@
296 @defer.inlineCallbacks
297 def setUp(self):
298 yield super(TestSyncDaemonTool, self).setUp()
299- self.patch(windows.UbuntuOneClient, "connect", lambda _: defer.Deferred())
300- self.sdtool = windows.SyncDaemonToolProxy()
301+ self.patch(perspective_broker.UbuntuOneClient, "connect",
302+ lambda _: defer.Deferred())
303+ self.sdtool = perspective_broker.SyncDaemonToolProxy()
304 self.calls = {}
305
306 def test_call_after_connection(self):
307@@ -124,14 +125,3 @@
308 attr = getattr(self.sdtool, attr_name)
309 func_name = getattr(attr, "__name__", None)
310 self.assertNotEqual(func_name, "call_after_connection_inner")
311-
312- def test_start_missing_exe(self):
313- """Test starting the service when the exe is missing."""
314- # file is missing
315- self.patch(windows.os.path, 'exists', lambda f: False)
316- key = 'key'
317- path = 'path/to/exe'
318- self.patch(windows, 'OpenKey', lambda k,p: key)
319- self.patch(windows, 'QueryValueEx', lambda k,p: path)
320-
321- self.assertFailure(self.sdtool.start(), WindowsError)
322
323=== added file 'tests/platform/tools/test_windows.py'
324--- tests/platform/tools/test_windows.py 1970-01-01 00:00:00 +0000
325+++ tests/platform/tools/test_windows.py 2012-06-19 17:02:31 +0000
326@@ -0,0 +1,64 @@
327+# -*- coding: utf-8 -*-
328+#
329+# Copyright 2012 Canonical Ltd.
330+#
331+# This program is free software: you can redistribute it and/or modify it
332+# under the terms of the GNU General Public License version 3, as published
333+# by the Free Software Foundation.
334+#
335+# This program is distributed in the hope that it will be useful, but
336+# WITHOUT ANY WARRANTY; without even the implied warranties of
337+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
338+# PURPOSE. See the GNU General Public License for more details.
339+#
340+# You should have received a copy of the GNU General Public License along
341+# with this program. If not, see <http://www.gnu.org/licenses/>.
342+#
343+# In addition, as a special exception, the copyright holders give
344+# permission to link the code of portions of this program with the
345+# OpenSSL library under certain conditions as described in each
346+# individual source file, and distribute linked combinations
347+# including the two.
348+# You must obey the GNU General Public License in all respects
349+# for all of the code used other than OpenSSL. If you modify
350+# file(s) with this exception, you may extend this exception to your
351+# version of the file(s), but you are not obligated to do so. If you
352+# do not wish to do so, delete this exception statement from your
353+# version. If you delete this exception statement from all source
354+# files in the program, then also delete it here.
355+"""Tests for the tools windows code."""
356+
357+import sys
358+
359+from twisted.internet import defer
360+from twisted.trial.unittest import TestCase
361+
362+from ubuntuone.platform.tools import perspective_broker, windows
363+
364+# ugly trick to stop pylint for complaining about
365+# WindowsError on Linux
366+if sys.platform != 'win32':
367+ WindowsError = None
368+
369+
370+class TestStartSyncdaemon(TestCase):
371+ """Test the process of launching sd."""
372+
373+ @defer.inlineCallbacks
374+ def setUp(self):
375+ yield super(TestStartSyncdaemon, self).setUp()
376+ self.patch(perspective_broker.UbuntuOneClient, "connect",
377+ lambda _: defer.Deferred())
378+ self.sdtool = perspective_broker.SyncDaemonToolProxy()
379+ self.calls = {}
380+
381+ def test_start_missing_exe(self):
382+ """Test starting the service when the exe is missing."""
383+ # file is missing
384+ self.patch(windows.os.path, 'exists', lambda f: False)
385+ key = 'key'
386+ path = 'path/to/exe'
387+ self.patch(windows, 'OpenKey', lambda k,p: key)
388+ self.patch(windows, 'QueryValueEx', lambda k,p: path)
389+
390+ self.assertFailure(self.sdtool.start(), WindowsError)
391
392=== modified file 'tests/syncdaemon/test_action_queue.py'
393--- tests/syncdaemon/test_action_queue.py 2012-05-09 14:08:38 +0000
394+++ tests/syncdaemon/test_action_queue.py 2012-06-19 17:02:31 +0000
395@@ -329,6 +329,8 @@
396
397 class BasicTests(BasicTestCase):
398 """Basic tests to check ActionQueue."""
399+ fake_host = "fake_host"
400+ fake_iri = u"http://%s/" % fake_host
401
402 def test_implements_interface(self):
403 """Verify ActionQueue and FakeActionQueue interface."""
404@@ -433,19 +435,54 @@
405 self.assertEqual(set(defined_args[1:]), set(evtargs))
406
407 @defer.inlineCallbacks
408+ def test_get_webclient_called_with_iri(self):
409+ """The call to get_webclient includes the iri."""
410+ called_args = []
411+ real_get_webclient = action_queue.ActionQueue.get_webclient
412+
413+ def fake_get_webclient(aq, *args):
414+ """A fake get_webclient."""
415+ called_args.append(args)
416+ return real_get_webclient(aq, *args)
417+
418+ self.patch(action_queue.ActionQueue, "get_webclient",
419+ fake_get_webclient)
420+ self.patch(action_queue.txweb.WebClient, "request",
421+ lambda *args, **kwargs: defer.succeed(None))
422+
423+ yield self.action_queue.webcall(self.fake_iri)
424+ self.assertEqual(called_args, [(self.fake_iri,)])
425+
426+ @defer.inlineCallbacks
427 def test_get_webclient(self):
428- """The webclient is created if it does not exist."""
429- self.assertEqual(self.action_queue.webclient, None)
430- webclient = yield self.action_queue.get_webclient()
431- self.assertNotEqual(webclient, None)
432-
433- @defer.inlineCallbacks
434- def test_get_webclient_existing(self):
435- """The webclient is not created again if it exists."""
436- fake_wc = object()
437- self.patch(self.action_queue, "webclient", fake_wc)
438- webclient = yield self.action_queue.get_webclient()
439- self.assertEqual(webclient, fake_wc)
440+ """The webclient is created every time."""
441+ webclient1 = yield self.action_queue.get_webclient(self.fake_iri)
442+ webclient2 = yield self.action_queue.get_webclient(self.fake_iri)
443+ self.assertNotEqual(webclient1, webclient2)
444+
445+ @defer.inlineCallbacks
446+ def test_get_webclient_creates_context_with_host(self):
447+ """The ssl context is created with the right host."""
448+ used_host = []
449+
450+ def fake_get_ssl_context(disable_ssl_verify, host):
451+ """The host is used to call get_ssl_context."""
452+ used_host.append(host)
453+
454+ self.patch(action_queue, "get_ssl_context", fake_get_ssl_context)
455+ yield self.action_queue.get_webclient(self.fake_iri)
456+ self.assertEqual(used_host, [self.fake_host])
457+
458+ @defer.inlineCallbacks
459+ def test_get_webclient_uses_just_created_context(self):
460+ """The freshly created context is used to create the webclient."""
461+ calls = []
462+ fake_context = object()
463+ self.patch(action_queue, "get_ssl_context", lambda *args: fake_context)
464+ self.patch(action_queue.txweb.WebClient, "__init__",
465+ lambda *args, **kwargs: calls.append(kwargs))
466+ yield self.action_queue.get_webclient(self.fake_iri)
467+ self.assertEqual(calls[1]["context_factory"], fake_context)
468
469
470 class TestLoggingStorageClient(TwistedTestCase):
471@@ -1395,6 +1432,24 @@
472 "connectSSL is called on the client.")
473
474
475+class ContextRequestedWithHost(FactoryBaseTestCase):
476+ """Test that the context is requested passing the host."""
477+
478+ tunnel_runner_class = SavingConnectionTunnelRunner
479+
480+ @defer.inlineCallbacks
481+ def test_context_request_passes_host(self):
482+ """The context is requested passing the host."""
483+ fake_host = "fake_host"
484+
485+ def fake_get_ssl_context(disable_ssl_verify, host):
486+ """The host is used to call get_ssl_context."""
487+ self.assertEqual(host, fake_host)
488+
489+ self.patch(action_queue, "get_ssl_context", fake_get_ssl_context)
490+ yield self.action_queue._make_connection((fake_host, 1234))
491+
492+
493 class ConnectedBaseTestCase(FactoryBaseTestCase):
494 """Base test case generating a connected factory."""
495
496@@ -3709,6 +3764,18 @@
497 cmd._acquire_pathlock()
498 self.assertEqual(t, [('foo', 'bar'), {'logger': None}])
499
500+ def test_handle_failure_push_event(self):
501+ """Test AQ_CREATE_SHARE_ERROR is pushed on failure."""
502+ msg = 'Something went wrong'
503+ failure = Failure(DefaultException(msg))
504+ cmd = CreateShare(self.request_queue, NODE, 'share_to',
505+ 'share_name', ACCESS_LEVEL_RO, 'marker_id',
506+ os.path.join('foo', 'bar'))
507+ cmd.handle_failure(failure=failure)
508+ events = [('AQ_CREATE_SHARE_ERROR',
509+ {'marker': 'marker_id', 'error': msg})]
510+ self.assertEqual(events, cmd.action_queue.event_queue.events)
511+
512
513 class DeleteShareTestCase(ConnectedBaseTestCase):
514 """Test for DeleteShare ActionQueueCommand."""
515
516=== modified file 'tests/syncdaemon/test_sync.py'
517--- tests/syncdaemon/test_sync.py 2012-04-23 14:41:17 +0000
518+++ tests/syncdaemon/test_sync.py 2012-06-19 17:02:31 +0000
519@@ -387,20 +387,29 @@
520 self.sync._handle_SV_HASH_NEW(mdobj.share_id, mdobj.node_id, '')
521 self.assertTrue(self.called)
522
523- def test_SV_HASH_NEW_with_file_uploadinterrupted_coverage(self):
524- """A SV_HASH_NEW is received after upload interrupted."""
525+ def test_SV_HASH_NEW_with_special_hash(self):
526+ """A SV_HASH_NEW is received with hash in None, don't care state."""
527 self.called = False
528
529- # create a file and put it in local, without server_hash, as
530- # if the upload was cut in the middle after the make file
531+ def fake_meth(_, event, params, hash):
532+ """Wrap SSMR.reput_file_from_local to test."""
533+ self.assertEqual(event, 'SV_HASH_NEW')
534+ self.assertEqual(hash, '')
535+ self.called = True
536+ self.patch(SyncStateMachineRunner, 'reput_file_from_local', fake_meth)
537+
538+ # create a file and leave it as NONE state
539 somepath = os.path.join(self.root, 'somepath')
540 mdid = self.fsm.create(somepath, '', node_id='node_id')
541- self.fsm.set_by_mdid(mdid, local_hash='somehash', crc32='crc32',
542- stat='stat', size='size')
543+ self.fsm.set_by_mdid(mdid, local_hash='somehsh', server_hash='somehsh',
544+ crc32='crc32', stat='stat', size='size')
545
546 # send the event with no content and check
547 mdobj = self.fsm.get_by_mdid(mdid)
548 self.sync._handle_SV_HASH_NEW(mdobj.share_id, mdobj.node_id, '')
549+ self.assertTrue(self.called)
550+ mdobj = self.fsm.get_by_mdid(mdid)
551+ self.assertEqual(mdobj.server_hash, '')
552
553 def test_AQ_FILE_NEW_OK_with_md_in_none(self):
554 """Created the file, and MD says it's in NONE."""
555@@ -991,7 +1000,6 @@
556 with self._test_putcontent_upload_id(with_upload_id=False):
557 self.ssmr.reput_file_from_local("SV_HASH_NEW", None, '')
558
559-
560 def test_commit_file_without_partial(self):
561 """The .partial is lost when commiting the file."""
562 # create the partial correctly, and break it!
563
564=== modified file 'ubuntuone/platform/credentials/__init__.py'
565--- ubuntuone/platform/credentials/__init__.py 2012-04-09 20:07:05 +0000
566+++ ubuntuone/platform/credentials/__init__.py 2012-06-19 17:02:31 +0000
567@@ -138,12 +138,12 @@
568
569 def get_platform_source(self):
570 """Platform-specific source."""
571- if sys.platform == 'win32':
572- from ubuntuone.platform.credentials import windows
573- source = windows
574+ if sys.platform in ('win32', 'darwin'):
575+ from ubuntuone.platform.credentials import ipc_service
576+ source = ipc_service
577 else:
578- from ubuntuone.platform.credentials import linux
579- source = linux
580+ from ubuntuone.platform.credentials import dbus_service
581+ source = dbus_service
582 return source
583
584 @defer.inlineCallbacks
585
586=== renamed file 'ubuntuone/platform/credentials/linux.py' => 'ubuntuone/platform/credentials/dbus_service.py'
587--- ubuntuone/platform/credentials/linux.py 2012-04-09 20:07:05 +0000
588+++ ubuntuone/platform/credentials/dbus_service.py 2012-06-19 17:02:31 +0000
589@@ -30,6 +30,7 @@
590 # files in the program, then also delete it here.
591 """Ubuntu One credentials management dbus service."""
592
593+import dbus
594 import dbus.service
595 import ubuntu_sso
596
597@@ -181,7 +182,8 @@
598 def find_credentials(self, reply_handler=NO_OP, error_handler=NO_OP):
599 """Ask the Ubuntu One credentials."""
600 self.ref_count += 1
601- self.sso_proxy.find_credentials(APP_NAME, {},
602+ self.sso_proxy.find_credentials(APP_NAME,
603+ dbus.Dictionary({}, signature='ss'),
604 reply_handler=reply_handler, error_handler=error_handler)
605
606 @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE,
607@@ -205,7 +207,9 @@
608 self.ref_count -= 1
609
610 self.ref_count += 1
611- self.sso_proxy.find_credentials_sync(APP_NAME, {},
612+ self.sso_proxy.find_credentials_sync(
613+ APP_NAME,
614+ dbus.Dictionary({}, signature='ss'),
615 reply_handler=decrease_counter_success,
616 error_handler=decrease_counter_error)
617
618@@ -214,7 +218,8 @@
619 def clear_credentials(self, reply_handler=NO_OP, error_handler=NO_OP):
620 """Clear the Ubuntu One credentials."""
621 self.ref_count += 1
622- self.sso_proxy.clear_credentials(APP_NAME, {},
623+ self.sso_proxy.clear_credentials(APP_NAME,
624+ dbus.Dictionary({}, signature='ss'),
625 reply_handler=reply_handler, error_handler=error_handler)
626
627 @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE,
628
629=== renamed file 'ubuntuone/platform/credentials/windows.py' => 'ubuntuone/platform/credentials/ipc_service.py'
630=== modified file 'ubuntuone/platform/filesystem_notifications/linux.py'
631--- ubuntuone/platform/filesystem_notifications/linux.py 2012-05-14 21:24:24 +0000
632+++ ubuntuone/platform/filesystem_notifications/linux.py 2012-06-19 17:02:31 +0000
633@@ -212,6 +212,16 @@
634 if not (event.mask & pyinotify.IN_ISDIR):
635 self.general_processor.push_event(event)
636
637+ @validate_filename
638+ def process_IN_CLOSE_WRITE(self, event):
639+ """Filter IN_CLOSE_WRITE to make it happen only in files.
640+
641+ eCryptFS sends IN_CLOSE_WRITE event for lower directories.
642+
643+ """
644+ if not (event.mask & pyinotify.IN_ISDIR):
645+ self.general_processor.push_event(event)
646+
647 def process_IN_MOVE_SELF(self, event):
648 """Don't do anything here.
649
650
651=== modified file 'ubuntuone/platform/tools/__init__.py'
652--- ubuntuone/platform/tools/__init__.py 2012-05-16 16:24:23 +0000
653+++ ubuntuone/platform/tools/__init__.py 2012-06-19 17:02:31 +0000
654@@ -36,12 +36,9 @@
655 from twisted.internet import defer
656 from ubuntuone.logger import log_call
657
658-if sys.platform == 'win32':
659- from ubuntuone.platform.tools import windows
660- source = windows
661-elif sys.platform == 'darwin':
662- from ubuntuone.platform.tools import darwin
663- source = darwin
664+if sys.platform in ('win32', 'darwin'):
665+ from ubuntuone.platform.tools import perspective_broker
666+ source = perspective_broker
667 else:
668 from ubuntuone.platform.tools import linux
669 source = linux
670@@ -483,9 +480,9 @@
671 def change_public_access(self, path, is_public):
672 """Change the public access for a given path."""
673 d = self.wait_for_signals(
674- 'PublicAccessChanged', 'PublicAccessChangeError',
675- success_filter=lambda info: info['path'] == path,
676- error_filter=lambda info, _: info['path'] == path)
677+ 'PublicAccessChanged', 'PublicAccessChangeError',
678+ success_filter=lambda info: info['path'] == path.decode('utf-8'),
679+ error_filter=lambda info, _: info['path'] == path.decode('utf-8'))
680
681 metadata = yield self.get_metadata(path)
682 args = (metadata['share_id'], metadata['node_id'], is_public)
683
684=== added file 'ubuntuone/platform/tools/darwin.py'
685--- ubuntuone/platform/tools/darwin.py 1970-01-01 00:00:00 +0000
686+++ ubuntuone/platform/tools/darwin.py 2012-06-19 17:02:31 +0000
687@@ -0,0 +1,49 @@
688+# -*- coding: utf-8 -*-
689+#
690+# Copyright 2012 Canonical Ltd.
691+#
692+# This program is free software: you can redistribute it and/or modify it
693+# under the terms of the GNU General Public License version 3, as published
694+# by the Free Software Foundation.
695+#
696+# This program is distributed in the hope that it will be useful, but
697+# WITHOUT ANY WARRANTY; without even the implied warranties of
698+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
699+# PURPOSE. See the GNU General Public License for more details.
700+#
701+# You should have received a copy of the GNU General Public License along
702+# with this program. If not, see <http://www.gnu.org/licenses/>.
703+#
704+# In addition, as a special exception, the copyright holders give
705+# permission to link the code of portions of this program with the
706+# OpenSSL library under certain conditions as described in each
707+# individual source file, and distribute linked combinations
708+# including the two.
709+# You must obey the GNU General Public License in all respects
710+# for all of the code used other than OpenSSL. If you modify
711+# file(s) with this exception, you may extend this exception to your
712+# version of the file(s), but you are not obligated to do so. If you
713+# do not wish to do so, delete this exception statement from your
714+# version. If you delete this exception statement from all source
715+# files in the program, then also delete it here.
716+"""SyncDaemon Tools darwin implementation."""
717+
718+import errno
719+import os
720+
721+import ubuntuone
722+
723+
724+def get_sd_install_path():
725+ """Return the path where the sd script was installed."""
726+ # TODO: We need to find a nicer way to find paths on darwin when since this
727+ # method will probably not work once the application has been packaged.
728+ ubuntuone_pkg_dir = os.path.dirname(os.path.dirname(ubuntuone.__file__))
729+ ubuntuone_bin_dir = os.path.join(ubuntuone_pkg_dir, 'bin')
730+ ubuntuone_bin = os.path.join(ubuntuone_bin_dir,
731+ 'ubuntuone-syncdaemon')
732+ if not os.path.exists(ubuntuone_bin):
733+ raise Exception(errno.ENOENT,
734+ 'Could not start syncdaemon: File not found %s' % ubuntuone_bin)
735+ return ubuntuone_bin
736+
737
738=== removed file 'ubuntuone/platform/tools/darwin.py'
739--- ubuntuone/platform/tools/darwin.py 2012-05-17 11:59:26 +0000
740+++ ubuntuone/platform/tools/darwin.py 1970-01-01 00:00:00 +0000
741@@ -1,47 +0,0 @@
742-# -*- coding: utf-8 -*-
743-#
744-# Copyright 2012 Canonical Ltd.
745-#
746-# This program is free software: you can redistribute it and/or modify it
747-# under the terms of the GNU General Public License version 3, as published
748-# by the Free Software Foundation.
749-#
750-# This program is distributed in the hope that it will be useful, but
751-# WITHOUT ANY WARRANTY; without even the implied warranties of
752-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
753-# PURPOSE. See the GNU General Public License for more details.
754-#
755-# You should have received a copy of the GNU General Public License along
756-# with this program. If not, see <http://www.gnu.org/licenses/>.
757-#
758-# In addition, as a special exception, the copyright holders give
759-# permission to link the code of portions of this program with the
760-# OpenSSL library under certain conditions as described in each
761-# individual source file, and distribute linked combinations
762-# including the two.
763-# You must obey the GNU General Public License in all respects
764-# for all of the code used other than OpenSSL. If you modify
765-# file(s) with this exception, you may extend this exception to your
766-# version of the file(s), but you are not obligated to do so. If you
767-# do not wish to do so, delete this exception statement from your
768-# version. If you delete this exception statement from all source
769-# files in the program, then also delete it here.
770-"""SyncDaemon Tools."""
771-
772-
773-def is_already_running(*arg):
774- """Empty implementation for MAC OS"""
775-
776-
777-class IPCError(object):
778- """Empty implementation for MAC OS"""
779-
780- def __init__(self, *args):
781- """Empty implementation for MAC OS"""
782-
783-
784-class SyncDaemonToolProxy(object):
785- """Empty implementation for MAC OS"""
786-
787- def __init__(self, *args):
788- """Empty implementation for MAC OS"""
789
790=== renamed file 'ubuntuone/platform/tools/windows.py' => 'ubuntuone/platform/tools/perspective_broker.py'
791--- ubuntuone/platform/tools/windows.py 2012-05-22 14:13:48 +0000
792+++ ubuntuone/platform/tools/perspective_broker.py 2012-06-19 17:02:31 +0000
793@@ -28,13 +28,10 @@
794 # files in the program, then also delete it here.
795 """SyncDaemon Tools."""
796
797-import errno
798 import subprocess
799 import sys
800-import os
801
802 from twisted.internet import defer
803-from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
804
805 from ubuntuone.platform.ipc.perspective_broker import is_already_running
806 from ubuntuone.platform.ipc.ipc_client import UbuntuOneClient
807@@ -42,13 +39,17 @@
808
809 # make pyflakes happy since we can't disable the warning
810 is_already_running = is_already_running
811-U1_REG_PATH = r'Software\\Ubuntu One'
812-SD_INSTALL_PATH = 'SyncDaemonInstallPath'
813
814-# ugly trick to stop pylint for complaining about
815-# WindowsError on Linux
816-if sys.platform != 'win32':
817- WindowsError = None
818+if sys.platform == 'win32':
819+ from ubuntuone.platform.tools import windows
820+ get_sd_install_path = windows.get_sd_install_path
821+elif sys.platform == 'darwin':
822+ from ubuntuone.platform.tools import darwin
823+ get_sd_install_path = darwin.get_sd_install_path
824+else:
825+ # add an implementation that will result in os.path.exists always to be
826+ # false
827+ get_sd_install_path = lambda: None
828
829
830 class IPCError(Exception):
831@@ -173,13 +174,9 @@
832
833 def start(self):
834 """Start syncdaemon, should *not* be running."""
835- # look in the reg to find the path of the .exe to be executed
836- # to launch the sd on windows
837- key = OpenKey(HKEY_LOCAL_MACHINE, U1_REG_PATH)
838- path = QueryValueEx(key, SD_INSTALL_PATH)[0]
839- if not os.path.exists(path):
840- # either the .exe was moved of the value is wrong
841- return defer.fail(WindowsError(errno.ENOENT,
842- 'Could not start syncdaemon: File not found %s' % path))
843+ try:
844+ path = get_sd_install_path()
845+ except Exception, e:
846+ defer.fail(e)
847 p = subprocess.Popen([path])
848 return defer.succeed(p)
849
850=== added file 'ubuntuone/platform/tools/windows.py'
851--- ubuntuone/platform/tools/windows.py 1970-01-01 00:00:00 +0000
852+++ ubuntuone/platform/tools/windows.py 2012-06-19 17:02:31 +0000
853@@ -0,0 +1,56 @@
854+# -*- coding: utf-8 -*-
855+#
856+# Copyright 2012 Canonical Ltd.
857+#
858+# This program is free software: you can redistribute it and/or modify it
859+# under the terms of the GNU General Public License version 3, as published
860+# by the Free Software Foundation.
861+#
862+# This program is distributed in the hope that it will be useful, but
863+# WITHOUT ANY WARRANTY; without even the implied warranties of
864+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
865+# PURPOSE. See the GNU General Public License for more details.
866+#
867+# You should have received a copy of the GNU General Public License along
868+# with this program. If not, see <http://www.gnu.org/licenses/>.
869+#
870+# In addition, as a special exception, the copyright holders give
871+# permission to link the code of portions of this program with the
872+# OpenSSL library under certain conditions as described in each
873+# individual source file, and distribute linked combinations
874+# including the two.
875+# You must obey the GNU General Public License in all respects
876+# for all of the code used other than OpenSSL. If you modify
877+# file(s) with this exception, you may extend this exception to your
878+# version of the file(s), but you are not obligated to do so. If you
879+# do not wish to do so, delete this exception statement from your
880+# version. If you delete this exception statement from all source
881+# files in the program, then also delete it here.
882+"""SyncDaemon Tools windows implementation."""
883+
884+import errno
885+import os
886+import sys
887+
888+from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
889+
890+
891+U1_REG_PATH = r'Software\\Ubuntu One'
892+SD_INSTALL_PATH = 'SyncDaemonInstallPath'
893+
894+# ugly trick to stop pylint for complaining about
895+# WindowsError on Linux
896+if sys.platform != 'win32':
897+ WindowsError = None
898+
899+
900+def get_sd_install_path():
901+ """Return the path where the sd script was installed."""
902+ # look in the reg to find the path of the .exe to be executed
903+ # to launch the sd on windows
904+ key = OpenKey(HKEY_LOCAL_MACHINE, U1_REG_PATH)
905+ path = QueryValueEx(key, SD_INSTALL_PATH)[0]
906+ if not os.path.exists(path):
907+ raise WindowsError(errno.ENOENT,
908+ 'Could not start syncdaemon: File not found %s' % path)
909+ return path
910
911=== modified file 'ubuntuone/proxy/tunnel_client.py'
912--- ubuntuone/proxy/tunnel_client.py 2012-04-09 20:08:42 +0000
913+++ ubuntuone/proxy/tunnel_client.py 2012-06-19 17:02:31 +0000
914@@ -143,7 +143,7 @@
915 class TunnelProcessProtocol(protocol.ProcessProtocol):
916 """The dialog thru stdout with the tunnel server."""
917
918- timeout = 5
919+ timeout = 30
920
921 def __init__(self, client_d):
922 """Initialize this protocol."""
923
924=== modified file 'ubuntuone/syncdaemon/action_queue.py'
925--- ubuntuone/syncdaemon/action_queue.py 2012-05-09 14:08:38 +0000
926+++ ubuntuone/syncdaemon/action_queue.py 2012-06-19 17:02:31 +0000
927@@ -43,7 +43,7 @@
928 from collections import deque, defaultdict
929 from functools import partial
930 from urllib import urlencode
931-from urlparse import urljoin
932+from urlparse import urljoin, urlparse
933
934 import OpenSSL.SSL
935
936@@ -697,7 +697,6 @@
937 self.token = None
938 self.consumer = None
939 self.credentials = None
940- self.webclient = None
941
942 self.client = None # an instance of self.protocol
943
944@@ -836,26 +835,28 @@
945 @defer.inlineCallbacks
946 def webcall(self, iri, **kwargs):
947 """Perform a web call to the api servers."""
948- webclient = yield self.get_webclient()
949+ webclient = yield self.get_webclient(iri)
950 response = yield webclient.request(iri,
951 oauth_credentials=self.credentials, **kwargs)
952 defer.returnValue(response)
953
954 @defer.inlineCallbacks
955- def get_webclient(self):
956+ def get_webclient(self, iri):
957 """Get the webclient, creating it if needed."""
958- if self.webclient is None:
959- client = yield self.tunnel_runner.get_client()
960- self.webclient = txweb.WebClient(connector=client,
961- appname="Ubuntu One",
962- oauth_sign_plain=True)
963- defer.returnValue(self.webclient)
964+ uri = txweb.WebClient().iri_to_uri(iri)
965+ host = urlparse(uri).netloc.split(":")[0]
966+ ssl_context = get_ssl_context(self.disable_ssl_verify, host)
967+ connector = yield self.tunnel_runner.get_client()
968+ webclient = txweb.WebClient(connector=connector, appname="Ubuntu One",
969+ oauth_sign_plain=True,
970+ context_factory=ssl_context)
971+ defer.returnValue(webclient)
972
973 @defer.inlineCallbacks
974 def _make_connection(self, result):
975 """Do the real connect call."""
976 host, port = result
977- ssl_context = get_ssl_context(self.disable_ssl_verify)
978+ ssl_context = get_ssl_context(self.disable_ssl_verify, host)
979 client = yield self.tunnel_runner.get_client()
980 if self.use_ssl:
981 self.connector = client.connectSSL(host, port, factory=self,
982@@ -1852,7 +1853,7 @@
983 """It didn't work! Push the event."""
984 self.action_queue.event_queue.push('AQ_CREATE_SHARE_ERROR',
985 marker=self.marker,
986- error=failure.value[1])
987+ error=failure.getErrorMessage())
988
989 def _acquire_pathlock(self):
990 """Acquire pathlock."""
991
992=== modified file 'ubuntuone/syncdaemon/sync.py'
993--- ubuntuone/syncdaemon/sync.py 2012-04-09 20:08:42 +0000
994+++ ubuntuone/syncdaemon/sync.py 2012-06-19 17:02:31 +0000
995@@ -589,10 +589,10 @@
996 """Starts the scan again on a dir."""
997 self.m.lr.scan_dir(self.key['mdid'], self.key['path'], udfmode)
998
999- def reput_file_from_local(self, event, params, hash):
1000+ def reput_file_from_local(self, event, params, hash_value):
1001 """Re put the file from its local state."""
1002 self.m.action_q.cancel_upload(share_id=self.key['share_id'],
1003- node_id=self.key['node_id'])
1004+ node_id=self.key['node_id'])
1005
1006 local_hash = self.key['local_hash']
1007 previous_hash = self.key['server_hash']
1008@@ -841,7 +841,13 @@
1009 """on SV_HASH_NEW. No longer called by EQ, only internally."""
1010 key = FSKey(self.m.fs, share_id=share_id, node_id=node_id)
1011 log = FileLogger(self.logger, key)
1012+
1013 ssmr = SyncStateMachineRunner(self.fsm, self.m, key, log)
1014+ if hash == "":
1015+ # Special case for hash == "", aka broken node.
1016+ # Set the server_hash = hash to force LOCAL state
1017+ key.set(server_hash=hash)
1018+ key.sync()
1019 ssmr.signal_event_with_hash("SV_HASH_NEW", hash)
1020
1021 def _handle_SV_FILE_NEW(self, share_id, node_id, parent_id, name):

Subscribers

People subscribed via source and target branches

to all changes: