Merge lp:~knny-myer/clicompanion/fix-636119 into lp:clicompanion

Proposed by Kenny Meyer
Status: Merged
Approved by: Duane Hinnen
Approved revision: 49
Merged at revision: 50
Proposed branch: lp:~knny-myer/clicompanion/fix-636119
Merge into: lp:clicompanion
Diff against target: 76 lines (+53/-1)
2 files modified
clicompanion.py (+3/-1)
utils.py (+50/-0)
To merge this branch: bzr merge lp:~knny-myer/clicompanion/fix-636119
Reviewer Review Type Date Requested Status
Duane Hinnen Approve
Review via email: mp+35765@code.launchpad.net

Description of the change

Fixes starting clicompanion with the wrong shell

To post a comment you must log in.
49. By Kenny Meyer

added utils.py

Revision history for this message
Duane Hinnen (duanedesign) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clicompanion.py'
2--- clicompanion.py 2010-09-13 11:53:55 +0000
3+++ clicompanion.py 2010-09-18 11:59:39 +0000
4@@ -30,6 +30,8 @@
5 import locale
6 import gettext
7
8+from utils import get_user_shell
9+
10 BASEDIR = os.curdir
11
12 def get_language():
13@@ -429,7 +431,7 @@
14 _vte = vte.Terminal()
15 _vte.set_size_request(700, 220)
16 _vte.connect ("child-exited", lambda term: gtk.main_quit())
17- _vte.fork_command('bash')
18+ _vte.fork_command(get_user_shell()) # Get the user's default shell
19
20 vte_tab = gtk.ScrolledWindow()
21 vte_tab.add(_vte)
22
23=== added file 'utils.py'
24--- utils.py 1970-01-01 00:00:00 +0000
25+++ utils.py 2010-09-18 11:59:39 +0000
26@@ -0,0 +1,50 @@
27+# -*- mode: python; coding: utf-8; -*-
28+#
29+# clicompanion.py - commandline tool.
30+#
31+# Copyright 2010 Duane Hinnen, Kenny Meyer, Marcos Vanetta
32+#
33+# This program is free software: you can redistribute it and/or modify it
34+# under the terms of the GNU General Public License version 3, as published
35+# by the Free Software Foundation.
36+#
37+# This program is distributed in the hope that it will be useful, but
38+# WITHOUT ANY WARRANTY; without even the implied warranties of
39+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
40+# PURPOSE. See the GNU General Public License for more details.
41+#
42+# You should have received a copy of the GNU General Public License along
43+# with this program. If not, see <http://www.gnu.org/licenses/>.
44+#
45+#
46+
47+"""
48+A collection of useful functions.
49+"""
50+
51+import getpass
52+
53+
54+def get_user_shell():
55+ """Get the user's shell defined in /etc/passwd ."""
56+ data = None
57+ try:
58+ # Read out the data in /etc/passwd
59+ with open('/etc/passwd') as f:
60+ data = f.readlines()
61+ except e:
62+ print "Something unexpected happened!"
63+ raise e
64+
65+ for i in data:
66+ tmp = i.split(":")
67+ # Check for the entry of the currently logged in user
68+ if tmp[0] == getpass.getuser():
69+ # Columns are separated by colons, so split each column.
70+ # Sample /etc/passwd entry for a user:
71+ #
72+ # jorge:x:1001:1002:,,,:/home/jorge:/bin/bash
73+ #
74+ # The last column is relevant for us.
75+ # Don't forget to strip the newline at the end of the string!
76+ return i.split(":")[-1:][0].strip('\n')

Subscribers

People subscribed via source and target branches