Merge lp:~manishsinha/software-properties/fix-887249-handle-404-error into lp:software-properties

Status: Merged
Merged at revision: 726
Proposed branch: lp:~manishsinha/software-properties/fix-887249-handle-404-error
Merge into: lp:software-properties
Diff against target: 26 lines (+8/-1)
1 file modified
add-apt-repository (+8/-1)
To merge this branch: bzr merge lp:~manishsinha/software-properties/fix-887249-handle-404-error
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+81488@code.launchpad.net

Commit message

In case the user provides a wrong username or ppa name, then the exception is handled

* The exception handler checks that if the username starts with a ~, in this case
  it suggests does the user mean the username without a ~. e.g. if the user does
  sudo apt-add-repository ppa:~gnome3team/stable, then the script will ask the user
  if he means ppa:gnome3team/stable
* Even better friendlier messages can be provided, but for that it will introduce
  lauchpadlib as a dependency

Description of the change

In case the user provides a wrong username or ppa name, then the exception is handled

* The exception handler checks that if the username starts with a ~, in this case
  it suggests does the user mean the username without a ~. e.g. if the user does
  sudo apt-add-repository ppa:~gnome3team/stable, then the script will ask the user
  if he means ppa:gnome3team/stable
* Even better friendlier messages can be provided, but for that it will introduce
  lauchpadlib as a dependency

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'add-apt-repository'
--- add-apt-repository 2011-10-18 19:16:25 +0000
+++ add-apt-repository 2011-11-07 19:23:24 +0000
@@ -10,6 +10,7 @@
10from aptsources.sourceslist import SourceEntry10from aptsources.sourceslist import SourceEntry
11from optparse import OptionParser11from optparse import OptionParser
12from gettext import gettext as _12from gettext import gettext as _
13from urllib2 import HTTPError
1314
14def utf8(s):15def utf8(s):
15 """16 """
@@ -85,7 +86,13 @@
85 from softwareproperties.ppa import get_ppa_info_from_lp86 from softwareproperties.ppa import get_ppa_info_from_lp
86 user, sep, ppa_name = line.split(":")[1].partition("/")87 user, sep, ppa_name = line.split(":")[1].partition("/")
87 ppa_name = ppa_name or "ppa"88 ppa_name = ppa_name or "ppa"
88 ppa_info = get_ppa_info_from_lp(user, ppa_name)89 try:
90 ppa_info = get_ppa_info_from_lp(user, ppa_name)
91 except HTTPError:
92 print _("Cannot add PPA. Please check that the PPA name or format is correct")
93 if user.startswith("~"):
94 print _("Did you mean ppa:%s/%s" %(user[1:], ppa_name))
95 sys.exit(1)
89 if options.remove:96 if options.remove:
90 print _("You are about to remove the following PPA from your system:")97 print _("You are about to remove the following PPA from your system:")
91 else:98 else: