Merge lp:~chipaca/rhythmbox-ubuntuone/fix-634545 into lp:rhythmbox-ubuntuone

Proposed by John Lenton
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 88
Merged at revision: 87
Proposed branch: lp:~chipaca/rhythmbox-ubuntuone/fix-634545
Merge into: lp:rhythmbox-ubuntuone
Diff against target: 166 lines (+69/-41)
1 file modified
umusicstore/MusicStoreWidget.py (+69/-41)
To merge this branch: bzr merge lp:~chipaca/rhythmbox-ubuntuone/fix-634545
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+35602@code.launchpad.net

Commit message

Fix the mp3 plugin install code wrt aptdaemon changes (fixes LP:634545)

Description of the change

This makes the rb plugin able to download the mp3 plugin once again (fixes LP:634545)

To post a comment you must log in.
Revision history for this message
Manuel de la Peña (mandel) wrote :

Code goos look, I have tried in my system with no partners repo, no gstreamer-plugins-ugly etc.. and works as expected.

Some tests for this at some point would be nice ;)

review: Approve
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Works good for me also, after upgrading some apt-related packages

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'umusicstore/MusicStoreWidget.py'
2--- umusicstore/MusicStoreWidget.py 2010-09-09 14:46:24 +0000
3+++ umusicstore/MusicStoreWidget.py 2010-09-15 22:00:02 +0000
4@@ -20,12 +20,16 @@
5 import gtk, gobject, os, urllib, gconf, stat, urlparse, gio
6 import gst, gst.pbutils
7 import aptdaemon.client
8+from aptdaemon import policykit1
9+from aptdaemon.defer import inline_callbacks
10 from aptdaemon.enums import *
11 from aptdaemon.gtkwidgets import AptErrorDialog, \
12 AptProgressBar
13+from commands import getstatusoutput
14 import rb, rhythmdb
15 from ubuntuone.gtkwidgets import MusicStore as U1MusicStore
16 import xdg.BaseDirectory
17+import dbus
18 import dbus.exceptions
19
20 import gettext
21@@ -36,6 +40,9 @@
22 MUSIC_STORE_WIDGET = U1MusicStore() # keep this around for later
23 U1LIBRARYPATH = MUSIC_STORE_WIDGET.get_library_location()
24 RB_LIBRARY_LOCATIONS = "/apps/rhythmbox/library_locations"
25+PARTNER_LIST = "canonical-partner-maverick.list"
26+SOURCES_DIR = "/etc/apt/sources.list.d/"
27+PLUGIN_PACKAGENAME = "gstreamer0.10-fluendo-plugins-mp3-partner"
28
29 class U1EntryType(rhythmdb.EntryType):
30 def __init__(self):
31@@ -340,7 +347,8 @@
32 ', you need to install MP3 plugins. Click below to install them.'))
33 self.install_label_body.set_alignment(0.0, 0.5)
34 self.install_label_eula = gtk.Label()
35- # EULA text copied from /var/lib/dpkg/info/gstreamer0.10-fluendo-plugins-mp3-partner.templates
36+ # EULA text copied from
37+ # /var/lib/dpkg/info/gstreamer0.10-fluendo-plugins-mp3-partner.templates
38 # The partner package shows the EULA itself on installations, but
39 # aptdaemon installations work like DEBIAN_FRONTEND=noninteractive
40 # so we show the EULA here. (This also avoids a popup window.)
41@@ -373,56 +381,74 @@
42 self.install_box.show_all()
43 self.add(self.install_box)
44
45+ @inline_callbacks
46+ def _authenticate_for_add_and_install(self):
47+ """Authenticate with aptdaemon"""
48+ bus = dbus.SystemBus()
49+ name = bus.get_unique_name()
50+ action = policykit1.PK_ACTION_INSTALL_PACKAGES_FROM_NEW_REPO
51+ flags = policykit1.CHECK_AUTH_ALLOW_USER_INTERACTION
52+ yield policykit1.check_authorization_by_name(name, action, flags=flags)
53+
54+ @inline_callbacks
55 def _start_mp3_install(self, btn):
56 """Add the 'partner' repository and update the package list from it."""
57 self.ac = aptdaemon.client.AptClient()
58 try:
59- self.ac.add_repository("deb","http://archive.canonical.com/", "lucid", ["partner"])
60- except dbus.exceptions.DBusException, e:
61- if e.get_dbus_name() == "org.freedesktop.PolicyKit.Error.NotAuthorized":
62- # user cancelled, so exit from here so they can press the button again
63- return
64- self.ac.update_cache(reply_handler=self._finish_updating_packages,
65- error_handler=self._on_error)
66-
67- def _finish_updating_packages(self, transaction):
68- """Now that partner is added, install our mp3 codec package."""
69- self.update_progress = AptProgressBar(transaction)
70- self.update_progress.show()
71- self.install_label_head.set_text("")
72- self.install_label_body.set_text(_("Finding MP3 plugins"))
73- self.install_label_eula.hide()
74- self.install_hbtn.hide()
75- self.install_vbox.pack_start(self.update_progress, expand=False)
76- transaction.run(reply_handler=lambda: True,
77- error_handler=self._on_error)
78- self.ac.install_packages(["gstreamer0.10-fluendo-plugins-mp3-partner"],
79- reply_handler=self._run_transaction,
80- error_handler=self._on_error)
81+ yield self._authenticate_for_add_and_install()
82+ trans = yield self.ac.add_repository(
83+ src_type="deb",
84+ uri="http://archive.canonical.com/",
85+ dist="maverick",
86+ comps=["partner"],
87+ comment="added by U1MusicStoreWidget",
88+ sourcesfile=PARTNER_LIST, defer=True)
89+ yield trans.run(defer=True)
90+ trans = yield self.ac.update_cache(sources_list=SOURCES_DIR
91+ + PARTNER_LIST,
92+ defer=True)
93+ self.update_progress = AptProgressBar(trans)
94+ self.update_progress.show()
95+ self.install_label_head.set_text("")
96+ self.install_label_body.set_text(_("Finding MP3 plugins"))
97+ self.install_label_eula.hide()
98+ self.install_hbtn.hide()
99+ self.install_vbox.pack_start(self.update_progress, expand=False)
100+ trans.connect("finished", self._package_update_finished)
101+ yield trans.run(defer=True)
102+ except Exception, e:
103+ self._on_error(e)
104
105- def _run_transaction(self, transaction):
106- """Show progress of aptdaemon package installation."""
107+ @inline_callbacks
108+ def _package_update_finished(self, transaction, exit_code):
109+ """Packagelist update complete; kick off the install"""
110 self.update_progress.hide()
111- self.install_progress = AptProgressBar(transaction)
112- self.install_progress.show()
113- self.install_label_head.set_text("")
114- self.install_label_body.set_text(_("Installing MP3 plugins"))
115- self.install_label_eula.hide()
116- self.install_hbtn.hide()
117- self.install_vbox.pack_start(self.install_progress, expand=False)
118- transaction.run(reply_handler=lambda: True,
119- error_handler=self._on_error)
120- transaction.connect("finished", self._finished)
121+ if exit_code != EXIT_SUCCESS:
122+ self._on_error(transaction)
123+ return
124+ try:
125+ trans = yield self.ac.install_packages([PLUGIN_PACKAGENAME],
126+ defer=True)
127+ self.install_progress = AptProgressBar(transaction)
128+ self.install_progress.show()
129+ self.install_label_head.set_text("")
130+ self.install_label_body.set_text(_("Installing MP3 plugins"))
131+ self.install_label_eula.hide()
132+ self.install_hbtn.hide()
133+ self.install_vbox.pack_start(self.install_progress, expand=False)
134+ trans.connect("finished", self._package_install_finished)
135+ yield trans.run(defer=True)
136+ except Exception, e:
137+ self._on_error(e)
138
139- def _finished(self, trans, exit_code):
140+ def _package_install_finished(self, trans, exit_code):
141 """Aptdaemon package installation finished; show music store."""
142- if exit_code == 0 or exit_code == 2: # 0: success, 2: already installed
143+ if exit_code == EXIT_SUCCESS:
144 self.remove(self.install_box)
145 gst.update_registry()
146 self.add_music_store_widget()
147 else:
148- self._on_error("Could not find the "
149- "gstreamer0.10-fluendo-plugins-mp3-partner package.")
150+ self._on_error("Could not find the %r package" % PLUGIN_PACKAGENAME)
151
152 def _on_error(self, error):
153 """Error handler for aptdaemon."""
154@@ -432,8 +458,10 @@
155 '%s</span>' % problem_installing)
156 self.install_label_body.set_text(_('Check your internet connection and '
157 'try again.'))
158- if getattr(self, "install_progress"):
159- self.install_progress.hide()
160+ for widget in ("install_progress", "update_progress"):
161+ widget = getattr(self, widget, None)
162+ if widget is not None:
163+ widget.hide()
164 self.install_hbtn.show()
165
166 def add_music_store_widget(self):

Subscribers

People subscribed via source and target branches