Merge lp:~xintx-ua/command-not-found/auto-install-add-root into lp:~command-not-found-developers/command-not-found/trunk

Proposed by Serhiy
Status: Merged
Merged at revision: 145
Proposed branch: lp:~xintx-ua/command-not-found/auto-install-add-root
Merge into: lp:~command-not-found-developers/command-not-found/trunk
Diff against target: 32 lines (+6/-2)
1 file modified
CommandNotFound/CommandNotFound.py (+6/-2)
To merge this branch: bzr merge lp:~xintx-ua/command-not-found/auto-install-add-root
Reviewer Review Type Date Requested Status
Zygmunt Krynicki Approve
Review via email: mp+85203@code.launchpad.net

Description of the change

Adds auto-installation support for root.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CommandNotFound/CommandNotFound.py'
2--- CommandNotFound/CommandNotFound.py 2011-12-04 15:10:19 +0000
3+++ CommandNotFound/CommandNotFound.py 2011-12-09 23:01:27 +0000
4@@ -10,7 +10,6 @@
5 import string
6 import sys
7 import subprocess
8-import re
9
10 _ = gettext.translation("command-not-found", fallback=True).ugettext
11
12@@ -198,7 +197,11 @@
13 # Decode the answer so that we get an unicode value
14 answer = answer.decode(sys.stdin.encoding)
15 if answer.lower() == _("y"):
16- install_command = "sudo apt-get install %s" % package_name
17+ if posix.geteuid() == 0:
18+ command_prefix = ""
19+ else:
20+ command_prefix = "sudo "
21+ install_command = "%sapt-get install %s" % (command_prefix, package_name)
22 print >> sys.stdout, "%s" % install_command
23 subprocess.call(install_command.split(), shell=False)
24
25@@ -248,6 +251,7 @@
26 if posix.geteuid() == 0:
27 print >> sys.stderr, _("You can install it by typing:")
28 print >> sys.stderr, "apt-get install %s" % packages[0][0]
29+ self.install_prompt(packages[0][0])
30 elif self.user_can_sudo:
31 print >> sys.stderr, _("You can install it by typing:")
32 print >> sys.stderr, "sudo apt-get install %s" % packages[0][0]

Subscribers

People subscribed via source and target branches