[rhythmbox/gobject-introspection: 27/27] fix and hack around a variety of python plugin problems



commit f68b397b8a0e4f8a63cbca7964ad27710a307800
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Aug 4 11:26:12 2010 +1000

    fix and hack around a variety of python plugin problems

 plugins/jamendo/jamendo/JamendoSource.py        |   11 +++++------
 plugins/jamendo/jamendo/__init__.py             |   22 ++++++++++++----------
 plugins/lyrics/lyrics/__init__.py               |    2 +-
 plugins/magnatune/magnatune/MagnatuneSource.py  |   18 ++++++++++--------
 plugins/magnatune/magnatune/TrackListHandler.py |   23 +++++++++++++++--------
 plugins/magnatune/magnatune/__init__.py         |   19 +++++++++++--------
 plugins/rb/Loader.py                            |    1 +
 plugins/rb/__init__.py                          |    7 +++----
 8 files changed, 58 insertions(+), 45 deletions(-)
---
diff --git a/plugins/jamendo/jamendo/JamendoSource.py b/plugins/jamendo/jamendo/JamendoSource.py
index ec091c5..7c6e572 100644
--- a/plugins/jamendo/jamendo/JamendoSource.py
+++ b/plugins/jamendo/jamendo/JamendoSource.py
@@ -101,8 +101,8 @@ class JamendoSource(RB.BrowserSource):
 
 	def do_impl_pack_paned (self, paned):
 		self.__paned_box = Gtk.VBox(False, 5)
-		self.pack_start(self.__paned_box)
-		self.__paned_box.pack_start(paned)
+		self.pack_start(self.__paned_box, True, True, 0)
+		self.__paned_box.pack_start(paned, True, True, 0)
 
 	#
 	# RBSource methods
@@ -115,7 +115,7 @@ class JamendoSource(RB.BrowserSource):
 		return ["JamendoDownloadAlbum","JamendoDonateArtist"]
 
 
-	def do_impl_get_status(self):
+	def do_impl_get_status(self, status, progress, fraction):
 		if self.__updating:
 			if self.__load_total_size > 0:
 				progress = min (float(self.__load_current_size) / self.__load_total_size, 1.0)
@@ -144,7 +144,7 @@ class JamendoSource(RB.BrowserSource):
 				sort_key = "Artist,ascending"
 			self.get_entry_view().set_sorting_type(sort_key)
 
-		RB.BrowserSource.do_impl_activate (self)
+		# RB.BrowserSource.do_impl_activate (self)
 
 	def do_impl_delete_thyself(self):
 		if self.__update_id != 0:
@@ -164,7 +164,7 @@ class JamendoSource(RB.BrowserSource):
 			self.__catalogue_check = None
 
 		GConf.Client.get_default().set_string(JamendoConfigureDialog.gconf_keys['sorting'], self.get_entry_view().get_sorting_type())
-		RB.BrowserSource.do_impl_delete_thyself (self)
+		# RB.BrowserSource.do_impl_delete_thyself (self)
 
 
 	#
@@ -351,4 +351,3 @@ class JamendoSource(RB.BrowserSource):
 		return False
 
 gobject.type_register(JamendoSource)
-
diff --git a/plugins/jamendo/jamendo/__init__.py b/plugins/jamendo/jamendo/__init__.py
index 34f3a95..5304167 100644
--- a/plugins/jamendo/jamendo/__init__.py
+++ b/plugins/jamendo/jamendo/__init__.py
@@ -36,7 +36,7 @@ from JamendoConfigureDialog import JamendoConfigureDialog
 
 import rb
 from gi.repository import Gtk
-from gi.repository import RB
+from gi.repository import RB, RhythmDB
 
 popup_ui = """
 <ui>
@@ -54,13 +54,16 @@ popup_ui = """
 </ui>
 """
 
-class JamendoEntryType(rhythmdb.EntryType):
+class JamendoEntryType(RhythmDB.EntryType):
 	def __init__(self):
-		rhythmdb.EntryType.__init__(self, name='jamendo')
+		RhythmDB.EntryType.__init__(self, name="jamendo")
 
-	def can_sync_metadata(self, entry):
+	def do_can_sync_metadata(self, entry):
 		return True
 
+	def do_sync_metadata(self, entry, changes):
+		return
+
 class Jamendo(RB.Plugin):
 	#
 	# Core methods
@@ -78,10 +81,10 @@ class Jamendo(RB.Plugin):
 		theme = Gtk.icon_theme_get_default()
 		rb.append_plugin_source_path(theme, "/icons/")
 
-		width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
-		icon = RB.try_load_icon(theme, "jamendo", width, 0)
+		what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
+		icon = rb.try_load_icon(theme, "jamendo", width, 0)
 
-		group = RB.rb_source_group_get_by_name ("stores")	# RB.SourceGroup.get_by_name()?
+		group = RB.Source.group_get_by_name ("stores")	# RB.SourceGroup.get_by_name()?
 		self.source = gobject.new (JamendoSource,
 					   shell=shell,
 					   entry_type=self.entry_type,
@@ -95,7 +98,7 @@ class Jamendo(RB.Plugin):
 		manager = shell.get_player().get_property('ui-manager')
 		action = Gtk.Action(name='JamendoDownloadAlbum', label=_('_Download Album'),
 				tooltip=_("Download this album using BitTorrent"),
-				stock='gtk-save')
+				stock_id='gtk-save')
 		action.connect('activate', lambda a: shell.get_property("selected-source").download_album())
 		self.action_group = Gtk.ActionGroup(label='JamendoPluginActions')
 		self.action_group.add_action(action)
@@ -103,7 +106,7 @@ class Jamendo(RB.Plugin):
 		# Add Button for Donate
 		action = Gtk.Action(name='JamendoDonateArtist', label=_('_Donate to Artist'),
 				tooltip=_("Donate Money to this Artist"),
-				stock='gtk-jump-to')
+				stock_id='gtk-jump-to')
 		action.connect('activate', lambda a: shell.get_property("selected-source").launch_donate())
 		self.action_group.add_action(action)
 
@@ -138,4 +141,3 @@ class Jamendo(RB.Plugin):
 
 	def playing_entry_changed (self, sp, entry):
 		self.source.playing_entry_changed (entry)
-
diff --git a/plugins/lyrics/lyrics/__init__.py b/plugins/lyrics/lyrics/__init__.py
index 0cbe35c..d2edebb 100644
--- a/plugins/lyrics/lyrics/__init__.py
+++ b/plugins/lyrics/lyrics/__init__.py
@@ -278,7 +278,7 @@ class LyricPane(object):
 		self.get_lyrics()
 
 	def __got_lyrics(self, text):
-		self.buffer.set_text(text, -1)
+		self.buffer.set_text(str(text), -1)
 
 	def get_lyrics(self):
 		if self.entry is None:
diff --git a/plugins/magnatune/magnatune/MagnatuneSource.py b/plugins/magnatune/magnatune/MagnatuneSource.py
index 0aafcdb..a379ca8 100644
--- a/plugins/magnatune/magnatune/MagnatuneSource.py
+++ b/plugins/magnatune/magnatune/MagnatuneSource.py
@@ -102,7 +102,7 @@ class MagnatuneSource(RB.BrowserSource):
 	def do_impl_show_entry_popup(self):
 		self.show_source_popup("/MagnatuneSourceViewPopup")
 
-	def do_impl_get_status(self):
+	def dont_impl_get_status(self, text, progress, fraction):
 		if self.__updating:
 			complete, total = self.__load_progress
 			if total > 0:
@@ -145,7 +145,7 @@ class MagnatuneSource(RB.BrowserSource):
 
 			self.get_entry_view().set_sorting_type(self.__client.get_string("/apps/rhythmbox/plugins/magnatune/sorting"))
 
-		RB.BrowserSource.do_impl_activate(self)
+		#RB.BrowserSource.do_impl_activate(self)
 
 	def do_impl_get_browser_key(self):
 		return "/apps/rhythmbox/plugins/magnatune/show_browser"
@@ -158,8 +158,8 @@ class MagnatuneSource(RB.BrowserSource):
 
 	def do_impl_pack_paned(self, paned):
 		self.__paned_box = Gtk.VBox(homogeneous=False, spacing=5)
-		self.pack_start(self.__paned_box)
-		self.__paned_box.pack_start(paned)
+		self.pack_start(self.__paned_box, True, True, 0)
+		self.__paned_box.pack_start(paned, True, True, 0)
 
 
 	def do_impl_delete_thyself(self):
@@ -303,7 +303,7 @@ class MagnatuneSource(RB.BrowserSource):
 
 		def load_catalogue():
 			def got_items(result, items):
-				account_type = self.__client.get_string(self.__plugin.gconf_keys['account_type'])
+				account_type = "none" # self.__client.get_string(self.__plugin.gconf_keys['account_type'])
 				username = ""
 				password = ""
 				if account_type == 'none':
@@ -370,7 +370,8 @@ class MagnatuneSource(RB.BrowserSource):
 			self.__notify_status_changed()
 
 			load_size = {'size': 0}
-			keyring.find_items(GnomeKeyring.ItemType.GENERIC_SECRET, {'rhythmbox-plugin': 'magnatune'}, got_items)
+			# GnomeKeyring.find_items(GnomeKeyring.ItemType.GENERIC_SECRET, {'rhythmbox-plugin': 'magnatune'}, got_items)
+			got_items(None, None)
 
 
 		self.__catalogue_check = rb.UpdateCheck()
@@ -383,7 +384,7 @@ class MagnatuneSource(RB.BrowserSource):
 			builder = Gtk.Builder()
 			builder.add_from_file(self.__plugin.find_file("magnatune-loading.ui"))
 			self.__info_screen = builder.get_object("magnatune_loading_scrolledwindow")
-			self.pack_start(self.__info_screen)
+			self.pack_start(self.__info_screen, True, True, 0)
 			self.get_entry_view().set_no_show_all(True)
 			self.__info_screen.set_no_show_all(True)
 
@@ -462,7 +463,8 @@ class MagnatuneSource(RB.BrowserSource):
 						message = _("An error occurred while trying to download the album.\nThe error text is:\n%s") % str(e))
 
 
-		keyring.find_items(GnomeKeyring.ItemType.GENERIC_SECRET, {'rhythmbox-plugin': 'magnatune'}, got_items)
+		# GnomeKeyring.find_items(GnomeKeyring.ItemType.GENERIC_SECRET, {'rhythmbox-plugin': 'magnatune'}, got_items)
+		got_items("XXX keyring access not implemented", None)
 
 	def __download_album(self, audio_dl_uri, sku):
 		def download_progress(current, total):
diff --git a/plugins/magnatune/magnatune/TrackListHandler.py b/plugins/magnatune/magnatune/TrackListHandler.py
index 72ea523..5907644 100644
--- a/plugins/magnatune/magnatune/TrackListHandler.py
+++ b/plugins/magnatune/magnatune/TrackListHandler.py
@@ -66,10 +66,13 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
 				if self.__account_type != 'none':
 					trackurl = self.fix_trackurl(trackurl)
 
+				trackurl = str(trackurl)
+
 				# add the track to the source
 				entry = self.__db.entry_lookup_by_location (trackurl)
 				if entry == None:
-					entry = self.__db.entry_new(self.__entry_type, trackurl)
+					# entry = self.__db.entry_new(self.__entry_type, trackurl)
+					entry = RhythmDB.Entry.new(self.__db, self.__entry_type, trackurl)
 
 				# if year is not set, use launch date instead
 				try:
@@ -89,13 +92,15 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
 				except ValueError:
 					duration = 0
 
-				self.__db.set(entry, RhythmDB.PropType.ARTIST, self.__track['artist'])
-				self.__db.set(entry, RhythmDB.PropType.ALBUM, self.__track['albumname'])
-				self.__db.set(entry, RhythmDB.PropType.TITLE, self.__track['trackname'])
-				self.__db.set(entry, RhythmDB.PropType.TRACK_NUMBER, tracknum)
-				self.__db.set(entry, RhythmDB.PropType.DATE, date)
-				self.__db.set(entry, RhythmDB.PropType.GENRE, self.__track['magnatunegenres'])
-				self.__db.set(entry, RhythmDB.PropType.DURATION, duration)
+				self.__db.entry_set(entry, RhythmDB.PropType.ARTIST, str(self.__track['artist']))
+				self.__db.entry_set(entry, RhythmDB.PropType.ALBUM, str(self.__track['albumname']))
+				self.__db.entry_set(entry, RhythmDB.PropType.TITLE, str(self.__track['trackname']))
+				self.__db.entry_set(entry, RhythmDB.PropType.GENRE, str(self.__track['magnatunegenres']))
+				# setting ulong properties currently crashes because we don't have enough control
+				# over the type conversion; or maybe we need to be more flexible in rhythmdb?
+				#self.__db.entry_set(entry, RhythmDB.PropType.TRACK_NUMBER, long(tracknum))
+				#self.__db.entry_set(entry, RhythmDB.PropType.DATE, long(date))
+				#self.__db.entry_set(entry, RhythmDB.PropType.DURATION, long(duration))
 
 				key = str(trackurl)
 				sku = intern(str(self.__track['albumsku']))
@@ -105,6 +110,8 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
 
 				self.__db.commit()
 			except Exception,e: # This happens on duplicate uris being added
+				import sys
+				sys.excepthook(*sys.exc_info())
 				print "Couldn't add %s - %s" % (self.__track['artist'], self.__track['trackname']), e
 
 			self.__track = {}
diff --git a/plugins/magnatune/magnatune/__init__.py b/plugins/magnatune/magnatune/__init__.py
index 9fd7e3e..a0ccd43 100644
--- a/plugins/magnatune/magnatune/__init__.py
+++ b/plugins/magnatune/magnatune/__init__.py
@@ -57,13 +57,16 @@ popup_ui = """
 </ui>
 """
 
-class MagnatuneEntryType(rhythmdb.EntryType):
+class MagnatuneEntryType(RhythmDB.EntryType):
 	def __init__(self):
-		rhythmdb.EntryType.__init__(self, name='magnatune')
+		RhythmDB.EntryType.__init__(self, name='magnatune')
 
 	def can_sync_metadata(self, entry):
 		return True
 
+	def sync_metadata(self, entry, changes):
+		return
+
 class Magnatune(RB.Plugin):
 	client = GConf.Client.get_default()
 
@@ -95,10 +98,10 @@ class Magnatune(RB.Plugin):
 		theme = Gtk.IconTheme.get_default()
 		rb.append_plugin_source_path(theme, "/icons")
 
-		width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
-		icon = RB.try_load_icon(theme, "magnatune", width, 0)
+		what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
+		icon = rb.try_load_icon(theme, "magnatune", width, 0)
 
-		group = RB.rb_source_group_get_by_name("stores")
+		group = RB.Source.group_get_by_name("stores")		# XXX should be RB.SourceGroup.get_by_name()
 		self.source = gobject.new(MagnatuneSource,
 					  shell=shell,
 					  entry_type=self.entry_type,
@@ -115,17 +118,17 @@ class Magnatune(RB.Plugin):
 
 		action = Gtk.Action(name='MagnatuneDownloadAlbum', label=_('Download Album'),
 				tooltip=_("Download this album from Magnatune"),
-				stock='gtk-save')
+				stock_id='gtk-save')
 		action.connect('activate', lambda a: self.shell.get_property("selected-source").download_album())
 		self.action_group.add_action(action)
 		action = Gtk.Action(name='MagnatuneArtistInfo', label=_('Artist Information'),
 				tooltip=_("Get information about this artist"),
-				stock='gtk-info')
+				stock_id='gtk-info')
 		action.connect('activate', lambda a: self.shell.get_property("selected-source").display_artist_info())
 		self.action_group.add_action(action)
 		action = Gtk.Action(name='MagnatuneCancelDownload', label=_('Cancel Downloads'),
 				tooltip=_("Stop downloading purchased albums"),
-				stock='gtk-stop')
+				stock_id='gtk-stop')
 		action.connect('activate', lambda a: self.shell.get_property("selected-source").cancel_downloads())
 		action.set_sensitive(False)
 		self.action_group.add_action(action)
diff --git a/plugins/rb/Loader.py b/plugins/rb/Loader.py
index 08b7027..22854f5 100644
--- a/plugins/rb/Loader.py
+++ b/plugins/rb/Loader.py
@@ -84,6 +84,7 @@ class ChunkLoader(object):
 			return v
 		except Exception, e:
 			Gdk.threads_leave()
+			sys.excepthook(*sys.exc_info())
 			raise e
 
 	def _error_idle_cb(self, error):
diff --git a/plugins/rb/__init__.py b/plugins/rb/__init__.py
index 92d0630..411c8e6 100644
--- a/plugins/rb/__init__.py
+++ b/plugins/rb/__init__.py
@@ -65,10 +65,9 @@ class _rbdebugfile:
 	def __init__(self, fn):
 		self.fn = fn
 
-	def write(self, str):
-		if str == '\n':
+	def write(self, data):
+		if data == '\n':
 			return
-		import rb
 		fr = sys._getframe(1)
 
 		co = fr.f_code
@@ -87,7 +86,7 @@ class _rbdebugfile:
 			methodname = '%s.%s' % (fr.f_locals['self'].__class__.__name__, methodname)
 
 		ln = co.co_firstlineno + fr.f_lineno
-		RB.debug (methodname, filename, ln, True, str)
+		RB.debug (methodname, filename, ln, True, str(data))
 
 	def close(self):         pass
 	def flush(self):         pass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]