Merge lp:~ralsina/ubuntuone-client/find_exes into lp:ubuntuone-client

Proposed by Roberto Alsina on 2012-03-18
Status: Merged
Approved by: Alejandro J. Cura on 2012-03-19
Approved revision: 1219
Merged at revision: 1213
Proposed branch: lp:~ralsina/ubuntuone-client/find_exes
Merge into: lp:ubuntuone-client
Diff against target: 79 lines (+24/-1)
3 files modified
tests/syncdaemon/test_tunnel_runner.py (+10/-0)
ubuntuone/platform/constants.py (+5/-0)
ubuntuone/syncdaemon/tunnel_runner.py (+9/-1)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-client/find_exes
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) 2012-03-18 Approve on 2012-03-19
Brian Curtin (community) Approve on 2012-03-19
Natalia Bidart Approve on 2012-03-19
Review via email: mp+98107@code.launchpad.net

Commit Message

Fix tunnel spawning code so that it works on windows.

Description of the Change

Fix tunnel spawning code so that it works on windows.

To post a comment you must log in.
Alejandro J. Cura (alecu) wrote :

78 - args = [TUNNEL_EXECUTABLE, host, str(port)]
79 + args = [host, str(port)]

The above change will make this branch fail on linux.
According to the twisted docs, "The first string should be the executable's name.":
http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorProcess.spawnProcess.html

Did you need this change in order to make it work on Windows?

review: Needs Information
Roberto Alsina (ralsina) wrote :

> 78 - args = [TUNNEL_EXECUTABLE, host, str(port)]
> 79 + args = [host, str(port)]
>
> The above change will make this branch fail on linux.
> According to the twisted docs, "The first string should be the executable's
> name.":
> http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IRe
> actorProcess.spawnProcess.html
>
> Did you need this change in order to make it work on Windows?

No, I don't know where that came from. Reverted.

1216. By Roberto Alsina on 2012-03-19

style fix

1217. By Roberto Alsina on 2012-03-19

cleanup frozen on test

Natalia Bidart (nataliabidart) wrote :

* Can you please revert the unrelated change in ubuntuone/syncdaemon/interaction_interfaces.py?

* Typo in "surces".

* Since you already have changes to make, could you please add a space after the # in "#Only"?

Thanks!

review: Needs Fixing
1218. By Roberto Alsina on 2012-03-19

fixes suggested by nessita

Roberto Alsina (ralsina) wrote :

> * Can you please revert the unrelated change in
> ubuntuone/syncdaemon/interaction_interfaces.py?
>
> * Typo in "surces".
>
> * Since you already have changes to make, could you please add a space after
> the # in "#Only"?
>
> Thanks!

All 3 done in revo 1218

Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve
Brian Curtin (brian.curtin) wrote :

39 + TUNNEL_EXECUTABLE = "ubuntuone-proxy-tunnel.exe"

It'd be safer to do ```TUNNEL_EXECUTABLE += ".exe"```

review: Needs Fixing
1219. By Roberto Alsina on 2012-03-19

brian curtin's suggestion

Roberto Alsina (ralsina) wrote :

> 39 + TUNNEL_EXECUTABLE = "ubuntuone-proxy-tunnel.exe"
>
> It'd be safer to do ```TUNNEL_EXECUTABLE += ".exe"```

you are right, changed

Brian Curtin (brian.curtin) wrote :

+1

review: Approve
Alejandro J. Cura (alecu) wrote :

Looks fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_tunnel_runner.py'
2--- tests/syncdaemon/test_tunnel_runner.py 2012-03-16 03:15:28 +0000
3+++ tests/syncdaemon/test_tunnel_runner.py 2012-03-19 14:47:17 +0000
4@@ -15,6 +15,9 @@
5 # with this program. If not, see <http://www.gnu.org/licenses/>.
6 """Tests for the proxy tunnel runner."""
7
8+import os
9+import sys
10+
11 from twisted.internet import defer, error, reactor, task
12 from twisted.trial.unittest import TestCase
13
14@@ -116,3 +119,10 @@
15 client = yield self.tr.get_client()
16 self.assertEqual(client.tunnel_port, FAKE_PORT)
17 self.assertEqual(client.cookie, FAKE_COOKIE)
18+
19+ def test_frozen_path(self):
20+ """Ensure the path is correct if sys is frozen."""
21+ sys.frozen = "Yes"
22+ self.addCleanup(delattr, sys, "frozen")
23+ self.assertEqual(os.path.dirname(self.tr.get_process_path()),
24+ os.path.dirname(sys.executable))
25
26=== modified file 'ubuntuone/platform/constants.py'
27--- ubuntuone/platform/constants.py 2011-12-08 20:56:10 +0000
28+++ ubuntuone/platform/constants.py 2012-03-19 14:47:17 +0000
29@@ -21,7 +21,12 @@
30
31 import sys
32
33+TUNNEL_EXECUTABLE = "ubuntuone-proxy-tunnel"
34+
35 if sys.platform == "win32":
36 HASHQUEUE_DELAY = 3.0
37+ if getattr(sys, "frozen", None) is not None:
38+ # Only use the .exe suffix in windows+frozen
39+ TUNNEL_EXECUTABLE += ".exe"
40 else:
41 HASHQUEUE_DELAY = 0.5
42
43=== modified file 'ubuntuone/syncdaemon/tunnel_runner.py'
44--- ubuntuone/syncdaemon/tunnel_runner.py 2012-03-12 17:42:57 +0000
45+++ ubuntuone/syncdaemon/tunnel_runner.py 2012-03-19 14:47:17 +0000
46@@ -16,13 +16,14 @@
47 """Run the tunnel process and start a client, with a reactor as a fallback."""
48
49 import logging
50+import sys
51
52 from os import path
53
54 from twisted.internet import defer, reactor
55
56+from ubuntuone.platform.constants import TUNNEL_EXECUTABLE
57
58-TUNNEL_EXECUTABLE = "ubuntuone-proxy-tunnel"
59 logger = logging.getLogger("ubuntuone.SyncDaemon.TunnelRunner")
60
61
62@@ -48,11 +49,18 @@
63
64 def get_process_path(self):
65 """Get the path to the tunnel process."""
66+ # In a frozen setting, all binaries are in the same path
67+ if getattr(sys, "frozen", None) is not None:
68+ return path.join(path.dirname(
69+ path.abspath(sys.executable)), TUNNEL_EXECUTABLE)
70+
71+ # This works when we are running from sources
72 filename = path.join(path.dirname(__file__), "..", "..", "bin",
73 TUNNEL_EXECUTABLE)
74 if path.isfile(filename):
75 return filename
76
77+ # Use the configured LIBEXECDIR
78 from ubuntuone.clientdefs import LIBEXECDIR
79 return path.join(LIBEXECDIR, TUNNEL_EXECUTABLE)
80

Subscribers

People subscribed via source and target branches