Merge lp://qastaging/~cmiller/desktopcouch/add-port-getting-program into lp://qastaging/desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: not available
Merged at revision: not available
Proposed branch: lp://qastaging/~cmiller/desktopcouch/add-port-getting-program
Merge into: lp://qastaging/desktopcouch
Diff against target: 44 lines (+40/-0)
1 file modified
bin/desktopcouch-get-port (+40/-0)
To merge this branch: bzr merge lp://qastaging/~cmiller/desktopcouch/add-port-getting-program
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Joshua Blount (community) Approve
Review via email: mp+20141@code.qastaging.launchpad.net

Commit message

Add a simple way for any language to get the communications port, by executing a program.

To post a comment you must log in.
Revision history for this message
Joshua Blount (jblount) :
review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

looks ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/desktopcouch-get-port'
2--- bin/desktopcouch-get-port 1970-01-01 00:00:00 +0000
3+++ bin/desktopcouch-get-port 2010-02-25 15:59:14 +0000
4@@ -0,0 +1,40 @@
5+#!/usr/bin/python
6+# Copyright 2010 Canonical Ltd.
7+#
8+# This file is part of desktopcouch.
9+#
10+# desktopcouch is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU Lesser General Public License version 3
12+# as published by the Free Software Foundation.
13+#
14+# desktopcouch is distributed in the hope that it will be useful,
15+# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+# GNU Lesser General Public License for more details.
18+#
19+# You should have received a copy of the GNU Lesser General Public License
20+# along with desktopcouch. If not, see <http://www.gnu.org/licenses/>.
21+#
22+# Authors: Chad Miller <chad.miller@canonical.com>
23+
24+"""Return on stdout the port that the personal couchdb is listening on.
25+As always, success returns a zero exit code, and an exception in Python
26+returns an exit code of one. On error, stderr should have information
27+useful for debugging."""
28+
29+import desktopcouch
30+import sys
31+import os
32+
33+devnull = open(os.devnull, "w")
34+saved_stdout = sys.stdout
35+try:
36+ # Don't let any of our output interfere
37+ sys.stdout = devnull
38+ port = desktopcouch.find_port()
39+finally:
40+ sys.stdout = saved_stdout
41+ devnull.close()
42+
43+print port
44+

Subscribers

People subscribed via source and target branches