Merge lp:~mikemc/ubuntuone-client/use-dirspec-get-cmdline into lp:ubuntuone-client

Proposed by Mike McCracken on 2012-07-12
Status: Merged
Approved by: Diego Sarmentero on 2012-07-16
Approved revision: 1282
Merged at revision: 1275
Proposed branch: lp:~mikemc/ubuntuone-client/use-dirspec-get-cmdline
Merge into: lp:ubuntuone-client
Diff against target: 517 lines (+142/-284)
10 files modified
tests/platform/tools/test_darwin.py (+0/-52)
tests/platform/tools/test_windows.py (+0/-64)
tests/syncdaemon/test_utils.py (+79/-0)
ubuntuone/platform/ipc/__init__.py (+0/-3)
ubuntuone/platform/ipc/darwin.py (+0/-44)
ubuntuone/platform/ipc/perspective_broker.py (+5/-2)
ubuntuone/platform/tools/darwin.py (+0/-49)
ubuntuone/platform/tools/perspective_broker.py (+3/-14)
ubuntuone/platform/tools/windows.py (+0/-56)
ubuntuone/syncdaemon/utils.py (+55/-0)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-client/use-dirspec-get-cmdline
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve on 2012-07-16
dobey (community) Abstain on 2012-07-13
Brian Curtin (community) 2012-07-12 Approve on 2012-07-12
Review via email: mp+114720@code.launchpad.net

Commit Message

- Use dirspec.get_program_path instead of SSO client to find path to syncdaemon executable.

Description of the Change

- Use dirspec.get_program_path instead of SSO client to find path to syncdaemon executable.

In detail:

- add utils.py with get_sd_bin_cmd to wrap dirspec's get_program_path with appropriate fallback and app names args, and add 'python' if frozen on mac or win (to use buildout generated python).
- change platform/ipc/perspective_broker to use get_sd_bin_cmd.
- change platform/tools/perspective_broker to use get_sd_bin_cmd, although I believe it is never called.
- removed platform/tools/darwin.py and platform/tools/windows.py and associated tests, they are now unused.

Because of fsevents not quite working yet, with current trunk, not all tests pass on darwin. The following test paths touch the code I've changed and added:

./run-mac-tests tests/platform/tools
./run-mac-tests tests/platform/ipc
./run-mac-tests tests/test_utils.py

To run the tests, you'll need to tweak your PYTHONPATH to include dirspec trunk, and lp:~diegosarmentero/+junk/python-macfsevents (build it and put the build/lib.blahblah path on your PYTHONPATH)

To post a comment you must log in.
Brian Curtin (brian.curtin) wrote :

Overall it looks reasonable to me.

515 + if getattr(sys, 'frozen', None) is None \
516 + and sys.platform in ('win32', 'darwin'):

I have one style nit to pick. Rather than breaking the line with '\', I think it's more common to wrap the entire condition in parentheses.

review: Needs Fixing
1279. By Mike McCracken on 2012-07-12

use saner syntax for multi-line conditions

review: Approve
dobey (dobey) wrote :

=== added file 'ubuntuone/utils.py'

This might be better as ubuntuone/syncdaemon/utils.py, as it's fairly specific to syncdaemon here, and not a general all-of-ubuntuone thing.

I know that clientdefs.py is there now, and a logger.py, but I actually think everything in ubuntuone-client needs to be moved under ubuntuone/syncdaemon/; just to keep things clear when looking at the code structure. Would also be nice to separate the internal bits from actual library code, and only install actual library code to /usr/lib/pythonwhatever, while installing the internal code bits to a private directory somewhere. But for now, let's keep new files under syncdaemon. A man can dream.

dobey (dobey) :
review: Needs Fixing
Diego Sarmentero (diegosarmentero) wrote :

./tests/test_utils.py:
    31: 'os' imported but unused

review: Needs Fixing
1280. By Mike McCracken on 2012-07-13

remove unused import

1281. By Mike McCracken on 2012-07-13

merge with trunk

1282. By Mike McCracken on 2012-07-13

move utils module into syncdaemon

dobey (dobey) wrote :

My main concern looks addressed, but I can't test this on osx/win, so abstaining now.

review: Abstain
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'tests/platform/tools/test_darwin.py'
2--- tests/platform/tools/test_darwin.py 2012-05-24 15:09:34 +0000
3+++ tests/platform/tools/test_darwin.py 1970-01-01 00:00:00 +0000
4@@ -1,52 +0,0 @@
5-# -*- coding: utf-8 -*-
6-#
7-# Copyright 2012 Canonical Ltd.
8-#
9-# This program is free software: you can redistribute it and/or modify it
10-# under the terms of the GNU General Public License version 3, as published
11-# by the Free Software Foundation.
12-#
13-# This program is distributed in the hope that it will be useful, but
14-# WITHOUT ANY WARRANTY; without even the implied warranties of
15-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16-# PURPOSE. See the GNU General Public License for more details.
17-#
18-# You should have received a copy of the GNU General Public License along
19-# with this program. If not, see <http://www.gnu.org/licenses/>.
20-#
21-# In addition, as a special exception, the copyright holders give
22-# permission to link the code of portions of this program with the
23-# OpenSSL library under certain conditions as described in each
24-# individual source file, and distribute linked combinations
25-# including the two.
26-# You must obey the GNU General Public License in all respects
27-# for all of the code used other than OpenSSL. If you modify
28-# file(s) with this exception, you may extend this exception to your
29-# version of the file(s), but you are not obligated to do so. If you
30-# do not wish to do so, delete this exception statement from your
31-# version. If you delete this exception statement from all source
32-# files in the program, then also delete it here.
33-"""Tests for the tools windows code."""
34-
35-from twisted.internet import defer
36-from twisted.trial.unittest import TestCase
37-
38-from ubuntuone.platform.tools import perspective_broker, darwin
39-
40-
41-class TestStartSyncdaemon(TestCase):
42- """Test the process of launching sd."""
43-
44- @defer.inlineCallbacks
45- def setUp(self):
46- yield super(TestStartSyncdaemon, self).setUp()
47- self.patch(perspective_broker.UbuntuOneClient, "connect",
48- lambda _: defer.Deferred())
49- self.sdtool = perspective_broker.SyncDaemonToolProxy()
50- self.calls = {}
51-
52- def test_start_missing_exe(self):
53- """Test starting the service when the exe is missing."""
54- # file is missing
55- self.patch(darwin.os.path, 'exists', lambda f: False)
56- self.assertFailure(self.sdtool.start(), Exception)
57
58=== removed file 'tests/platform/tools/test_windows.py'
59--- tests/platform/tools/test_windows.py 2012-05-24 15:09:34 +0000
60+++ tests/platform/tools/test_windows.py 1970-01-01 00:00:00 +0000
61@@ -1,64 +0,0 @@
62-# -*- coding: utf-8 -*-
63-#
64-# Copyright 2012 Canonical Ltd.
65-#
66-# This program is free software: you can redistribute it and/or modify it
67-# under the terms of the GNU General Public License version 3, as published
68-# by the Free Software Foundation.
69-#
70-# This program is distributed in the hope that it will be useful, but
71-# WITHOUT ANY WARRANTY; without even the implied warranties of
72-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
73-# PURPOSE. See the GNU General Public License for more details.
74-#
75-# You should have received a copy of the GNU General Public License along
76-# with this program. If not, see <http://www.gnu.org/licenses/>.
77-#
78-# In addition, as a special exception, the copyright holders give
79-# permission to link the code of portions of this program with the
80-# OpenSSL library under certain conditions as described in each
81-# individual source file, and distribute linked combinations
82-# including the two.
83-# You must obey the GNU General Public License in all respects
84-# for all of the code used other than OpenSSL. If you modify
85-# file(s) with this exception, you may extend this exception to your
86-# version of the file(s), but you are not obligated to do so. If you
87-# do not wish to do so, delete this exception statement from your
88-# version. If you delete this exception statement from all source
89-# files in the program, then also delete it here.
90-"""Tests for the tools windows code."""
91-
92-import sys
93-
94-from twisted.internet import defer
95-from twisted.trial.unittest import TestCase
96-
97-from ubuntuone.platform.tools import perspective_broker, windows
98-
99-# ugly trick to stop pylint for complaining about
100-# WindowsError on Linux
101-if sys.platform != 'win32':
102- WindowsError = None
103-
104-
105-class TestStartSyncdaemon(TestCase):
106- """Test the process of launching sd."""
107-
108- @defer.inlineCallbacks
109- def setUp(self):
110- yield super(TestStartSyncdaemon, self).setUp()
111- self.patch(perspective_broker.UbuntuOneClient, "connect",
112- lambda _: defer.Deferred())
113- self.sdtool = perspective_broker.SyncDaemonToolProxy()
114- self.calls = {}
115-
116- def test_start_missing_exe(self):
117- """Test starting the service when the exe is missing."""
118- # file is missing
119- self.patch(windows.os.path, 'exists', lambda f: False)
120- key = 'key'
121- path = 'path/to/exe'
122- self.patch(windows, 'OpenKey', lambda k,p: key)
123- self.patch(windows, 'QueryValueEx', lambda k,p: path)
124-
125- self.assertFailure(self.sdtool.start(), WindowsError)
126
127=== added file 'tests/syncdaemon/test_utils.py'
128--- tests/syncdaemon/test_utils.py 1970-01-01 00:00:00 +0000
129+++ tests/syncdaemon/test_utils.py 2012-07-13 17:12:18 +0000
130@@ -0,0 +1,79 @@
131+# -*- coding: utf-8 -*-
132+#
133+# Copyright 2012 Canonical Ltd.
134+#
135+# This program is free software: you can redistribute it and/or modify it
136+# under the terms of the GNU General Public License version 3, as published
137+# by the Free Software Foundation.
138+#
139+# This program is distributed in the hope that it will be useful, but
140+# WITHOUT ANY WARRANTY; without even the implied warranties of
141+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
142+# PURPOSE. See the GNU General Public License for more details.
143+#
144+# You should have received a copy of the GNU General Public License along
145+# with this program. If not, see <http://www.gnu.org/licenses/>.
146+#
147+# In addition, as a special exception, the copyright holders give
148+# permission to link the code of portions of this program with the
149+# OpenSSL library under certain conditions as described in each
150+# individual source file, and distribute linked combinations
151+# including the two.
152+# You must obey the GNU General Public License in all respects
153+# for all of the code used other than OpenSSL. If you modify
154+# file(s) with this exception, you may extend this exception to your
155+# version of the file(s), but you are not obligated to do so. If you
156+# do not wish to do so, delete this exception statement from your
157+# version. If you delete this exception statement from all source
158+# files in the program, then also delete it here.
159+"""Test utility functions."""
160+
161+import sys
162+
163+from twisted.trial.unittest import TestCase
164+
165+import ubuntuone.syncdaemon.utils
166+
167+
168+class UtilsTestCase(TestCase):
169+ """Test utils."""
170+
171+ def test_get_sd_bin_cmd_src_nonlinux(self):
172+ """Test that we use the buildout python running from source."""
173+ self.patch(sys, 'platform', 'darwin')
174+ self.patch(ubuntuone.syncdaemon.utils, 'get_program_path',
175+ lambda _, *args, **kwargs: 'test-path')
176+ args = ubuntuone.syncdaemon.utils.get_sd_bin_cmd()
177+ self.assertEqual(len(args), 2)
178+ self.assertEqual(args[0], 'python')
179+
180+ def test_get_sd_bin_cmd_src_linux(self):
181+ """Test that we DO NOT use the buildout python running from source."""
182+ self.patch(sys, 'platform', 'linux2')
183+ self.patch(ubuntuone.syncdaemon.utils, 'get_program_path',
184+ lambda _, *args, **kwargs: 'test-path')
185+ args = ubuntuone.syncdaemon.utils.get_sd_bin_cmd()
186+ self.assertEqual(len(args), 1)
187+ self.assertEqual(args[0], 'test-path')
188+
189+ def test_get_sd_bin_cmd_installed_nonlinux(self):
190+ """Test that we DO NOT use the buildout python when installed."""
191+ sys.frozen = True
192+ self.addCleanup(delattr, sys, 'frozen')
193+ self.patch(sys, 'platform', 'darwin')
194+ self.patch(ubuntuone.syncdaemon.utils, 'get_program_path',
195+ lambda _, *args, **kwargs: 'test-path')
196+ args = ubuntuone.syncdaemon.utils.get_sd_bin_cmd()
197+ self.assertEqual(len(args), 1)
198+ self.assertEqual(args[0], 'test-path')
199+
200+ def test_get_sd_bin_cmd_installed_linux(self):
201+ """Test that we DO NOT use the buildout python when installed."""
202+ sys.frozen = True
203+ self.addCleanup(delattr, sys, 'frozen')
204+ self.patch(sys, 'platform', 'linux2')
205+ self.patch(ubuntuone.syncdaemon.utils, 'get_program_path',
206+ lambda _, *args, **kwargs: 'test-path')
207+ args = ubuntuone.syncdaemon.utils.get_sd_bin_cmd()
208+ self.assertEqual(len(args), 1)
209+ self.assertEqual(args[0], 'test-path')
210
211=== modified file 'ubuntuone/platform/ipc/__init__.py'
212--- ubuntuone/platform/ipc/__init__.py 2012-05-22 15:03:52 +0000
213+++ ubuntuone/platform/ipc/__init__.py 2012-07-13 17:12:18 +0000
214@@ -34,9 +34,6 @@
215 if sys.platform in ('win32', 'darwin'):
216 from ubuntuone.platform.ipc import perspective_broker as source
217 ExternalInterface = source.IPCInterface
218-elif sys.platform == "darwin":
219- from ubuntuone.platform.ipc import darwin as source
220- ExternalInterface = source.IPCInterface
221 else:
222 from ubuntuone.platform.ipc import linux as source
223 ExternalInterface = source.DBusInterface
224
225=== removed file 'ubuntuone/platform/ipc/darwin.py'
226--- ubuntuone/platform/ipc/darwin.py 2012-05-15 14:56:44 +0000
227+++ ubuntuone/platform/ipc/darwin.py 1970-01-01 00:00:00 +0000
228@@ -1,44 +0,0 @@
229-# -*- coding: utf-8 -*-
230-#
231-# Copyright 2012 Canonical Ltd.
232-#
233-# This program is free software: you can redistribute it and/or modify it
234-# under the terms of the GNU General Public License version 3, as published
235-# by the Free Software Foundation.
236-#
237-# This program is distributed in the hope that it will be useful, but
238-# WITHOUT ANY WARRANTY; without even the implied warranties of
239-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
240-# PURPOSE. See the GNU General Public License for more details.
241-#
242-# You should have received a copy of the GNU General Public License along
243-# with this program. If not, see <http://www.gnu.org/licenses/>.
244-#
245-# In addition, as a special exception, the copyright holders give
246-# permission to link the code of portions of this program with the
247-# OpenSSL library under certain conditions as described in each
248-# individual source file, and distribute linked combinations
249-# including the two.
250-# You must obey the GNU General Public License in all respects
251-# for all of the code used other than OpenSSL. If you modify
252-# file(s) with this exception, you may extend this exception to your
253-# version of the file(s), but you are not obligated to do so. If you
254-# do not wish to do so, delete this exception statement from your
255-# version. If you delete this exception statement from all source
256-# files in the program, then also delete it here.
257-"""IPC implementation for MAC OS."""
258-
259-import logging
260-
261-# Disable the "Invalid Name" check here, as we have lots of DBus style names
262-# pylint: disable-msg=C0103
263-
264-logger = logging.getLogger("ubuntuone.SyncDaemon.DBus")
265-
266-
267-def is_already_running(bus=None):
268- """Return if the sd is running by trying to get the port."""
269-
270-
271-class IPCInterface(object):
272- """Holder of all exposed objects."""
273
274=== modified file 'ubuntuone/platform/ipc/perspective_broker.py'
275--- ubuntuone/platform/ipc/perspective_broker.py 2012-05-22 14:07:55 +0000
276+++ ubuntuone/platform/ipc/perspective_broker.py 2012-07-13 17:12:18 +0000
277@@ -43,7 +43,8 @@
278 Referenceable,
279 Root,
280 )
281-from ubuntu_sso.main import get_activation_cmdline
282+
283+from ubuntuone.syncdaemon.utils import get_sd_bin_cmd
284 from ubuntu_sso.utils.tcpactivation import (
285 ActivationClient,
286 ActivationConfig,
287@@ -71,7 +72,9 @@
288 """Get the configuration to activate the sso service."""
289 description = DescriptionFactory()
290 service_name = SD_SERVICE_NAME
291- cmdline = get_activation_cmdline(service_name)
292+
293+ cmdline = get_sd_bin_cmd()
294+
295 return ActivationConfig(service_name, cmdline, description)
296
297
298
299=== removed file 'ubuntuone/platform/tools/darwin.py'
300--- ubuntuone/platform/tools/darwin.py 2012-05-24 09:43:19 +0000
301+++ ubuntuone/platform/tools/darwin.py 1970-01-01 00:00:00 +0000
302@@ -1,49 +0,0 @@
303-# -*- coding: utf-8 -*-
304-#
305-# Copyright 2012 Canonical Ltd.
306-#
307-# This program is free software: you can redistribute it and/or modify it
308-# under the terms of the GNU General Public License version 3, as published
309-# by the Free Software Foundation.
310-#
311-# This program is distributed in the hope that it will be useful, but
312-# WITHOUT ANY WARRANTY; without even the implied warranties of
313-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
314-# PURPOSE. See the GNU General Public License for more details.
315-#
316-# You should have received a copy of the GNU General Public License along
317-# with this program. If not, see <http://www.gnu.org/licenses/>.
318-#
319-# In addition, as a special exception, the copyright holders give
320-# permission to link the code of portions of this program with the
321-# OpenSSL library under certain conditions as described in each
322-# individual source file, and distribute linked combinations
323-# including the two.
324-# You must obey the GNU General Public License in all respects
325-# for all of the code used other than OpenSSL. If you modify
326-# file(s) with this exception, you may extend this exception to your
327-# version of the file(s), but you are not obligated to do so. If you
328-# do not wish to do so, delete this exception statement from your
329-# version. If you delete this exception statement from all source
330-# files in the program, then also delete it here.
331-"""SyncDaemon Tools darwin implementation."""
332-
333-import errno
334-import os
335-
336-import ubuntuone
337-
338-
339-def get_sd_install_path():
340- """Return the path where the sd script was installed."""
341- # TODO: We need to find a nicer way to find paths on darwin when since this
342- # method will probably not work once the application has been packaged.
343- ubuntuone_pkg_dir = os.path.dirname(os.path.dirname(ubuntuone.__file__))
344- ubuntuone_bin_dir = os.path.join(ubuntuone_pkg_dir, 'bin')
345- ubuntuone_bin = os.path.join(ubuntuone_bin_dir,
346- 'ubuntuone-syncdaemon')
347- if not os.path.exists(ubuntuone_bin):
348- raise Exception(errno.ENOENT,
349- 'Could not start syncdaemon: File not found %s' % ubuntuone_bin)
350- return ubuntuone_bin
351-
352
353=== modified file 'ubuntuone/platform/tools/perspective_broker.py'
354--- ubuntuone/platform/tools/perspective_broker.py 2012-05-24 09:43:19 +0000
355+++ ubuntuone/platform/tools/perspective_broker.py 2012-07-13 17:12:18 +0000
356@@ -29,28 +29,17 @@
357 """SyncDaemon Tools."""
358
359 import subprocess
360-import sys
361
362 from twisted.internet import defer
363
364 from ubuntuone.platform.ipc.perspective_broker import is_already_running
365 from ubuntuone.platform.ipc.ipc_client import UbuntuOneClient
366+from ubuntuone.syncdaemon.utils import get_sd_bin_cmd
367
368
369 # make pyflakes happy since we can't disable the warning
370 is_already_running = is_already_running
371
372-if sys.platform == 'win32':
373- from ubuntuone.platform.tools import windows
374- get_sd_install_path = windows.get_sd_install_path
375-elif sys.platform == 'darwin':
376- from ubuntuone.platform.tools import darwin
377- get_sd_install_path = darwin.get_sd_install_path
378-else:
379- # add an implementation that will result in os.path.exists always to be
380- # false
381- get_sd_install_path = lambda: None
382-
383
384 class IPCError(Exception):
385 """An IPC specific error signal."""
386@@ -175,8 +164,8 @@
387 def start(self):
388 """Start syncdaemon, should *not* be running."""
389 try:
390- path = get_sd_install_path()
391+ cmd = get_sd_bin_cmd()
392 except Exception, e:
393 defer.fail(e)
394- p = subprocess.Popen([path])
395+ p = subprocess.Popen(cmd)
396 return defer.succeed(p)
397
398=== removed file 'ubuntuone/platform/tools/windows.py'
399--- ubuntuone/platform/tools/windows.py 2012-05-24 09:43:19 +0000
400+++ ubuntuone/platform/tools/windows.py 1970-01-01 00:00:00 +0000
401@@ -1,56 +0,0 @@
402-# -*- coding: utf-8 -*-
403-#
404-# Copyright 2012 Canonical Ltd.
405-#
406-# This program is free software: you can redistribute it and/or modify it
407-# under the terms of the GNU General Public License version 3, as published
408-# by the Free Software Foundation.
409-#
410-# This program is distributed in the hope that it will be useful, but
411-# WITHOUT ANY WARRANTY; without even the implied warranties of
412-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
413-# PURPOSE. See the GNU General Public License for more details.
414-#
415-# You should have received a copy of the GNU General Public License along
416-# with this program. If not, see <http://www.gnu.org/licenses/>.
417-#
418-# In addition, as a special exception, the copyright holders give
419-# permission to link the code of portions of this program with the
420-# OpenSSL library under certain conditions as described in each
421-# individual source file, and distribute linked combinations
422-# including the two.
423-# You must obey the GNU General Public License in all respects
424-# for all of the code used other than OpenSSL. If you modify
425-# file(s) with this exception, you may extend this exception to your
426-# version of the file(s), but you are not obligated to do so. If you
427-# do not wish to do so, delete this exception statement from your
428-# version. If you delete this exception statement from all source
429-# files in the program, then also delete it here.
430-"""SyncDaemon Tools windows implementation."""
431-
432-import errno
433-import os
434-import sys
435-
436-from _winreg import OpenKey, HKEY_LOCAL_MACHINE, QueryValueEx
437-
438-
439-U1_REG_PATH = r'Software\\Ubuntu One'
440-SD_INSTALL_PATH = 'SyncDaemonInstallPath'
441-
442-# ugly trick to stop pylint for complaining about
443-# WindowsError on Linux
444-if sys.platform != 'win32':
445- WindowsError = None
446-
447-
448-def get_sd_install_path():
449- """Return the path where the sd script was installed."""
450- # look in the reg to find the path of the .exe to be executed
451- # to launch the sd on windows
452- key = OpenKey(HKEY_LOCAL_MACHINE, U1_REG_PATH)
453- path = QueryValueEx(key, SD_INSTALL_PATH)[0]
454- if not os.path.exists(path):
455- raise WindowsError(errno.ENOENT,
456- 'Could not start syncdaemon: File not found %s' % path)
457- return path
458
459=== added file 'ubuntuone/syncdaemon/utils.py'
460--- ubuntuone/syncdaemon/utils.py 1970-01-01 00:00:00 +0000
461+++ ubuntuone/syncdaemon/utils.py 2012-07-13 17:12:18 +0000
462@@ -0,0 +1,55 @@
463+# -*- coding: utf-8 -*-
464+#
465+# Copyright 2012 Canonical Ltd.
466+#
467+# This program is free software: you can redistribute it and/or modify it
468+# under the terms of the GNU General Public License version 3, as published
469+# by the Free Software Foundation.
470+#
471+# This program is distributed in the hope that it will be useful, but
472+# WITHOUT ANY WARRANTY; without even the implied warranties of
473+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
474+# PURPOSE. See the GNU General Public License for more details.
475+#
476+# You should have received a copy of the GNU General Public License along
477+# with this program. If not, see <http://www.gnu.org/licenses/>.
478+#
479+# In addition, as a special exception, the copyright holders give
480+# permission to link the code of portions of this program with the
481+# OpenSSL library under certain conditions as described in each
482+# individual source file, and distribute linked combinations
483+# including the two.
484+# You must obey the GNU General Public License in all respects
485+# for all of the code used other than OpenSSL. If you modify
486+# file(s) with this exception, you may extend this exception to your
487+# version of the file(s), but you are not obligated to do so. If you
488+# do not wish to do so, delete this exception statement from your
489+# version. If you delete this exception statement from all source
490+# files in the program, then also delete it here.
491+"""Utility functions for ubuntuone client."""
492+
493+import os
494+import sys
495+
496+from dirspec.utils import get_program_path
497+
498+DARWIN_APP_NAMES = {'ubuntuone-syncdaemon': 'UbuntuOne Syncdaemon.app'}
499+
500+
501+def get_sd_bin_cmd():
502+ """Get cmd + args to launch syncdaemon executable."""
503+ syncdaemon_dir = os.path.dirname(__file__)
504+ ubuntuone_dir = os.path.dirname(syncdaemon_dir)
505+ tree_dir = os.path.dirname(ubuntuone_dir)
506+ fallback_dirs = [os.path.join(tree_dir, 'bin')]
507+ path = get_program_path('ubuntuone-syncdaemon',
508+ fallback_dirs=fallback_dirs,
509+ app_names=DARWIN_APP_NAMES)
510+ cmd_args = [path]
511+
512+ # adjust cmd for platforms using buildout-generated python
513+ # wrappers
514+ if (getattr(sys, 'frozen', None) is None
515+ and sys.platform in ('win32', 'darwin')):
516+ cmd_args.insert(0, 'python')
517+ return cmd_args

Subscribers

People subscribed via source and target branches