[rhythmbox/gobject-introspection: 30/34] rearrange stuff to get python plugin debug output working
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox/gobject-introspection: 30/34] rearrange stuff to get python plugin debug output working
- Date: Wed, 14 Jul 2010 05:58:36 +0000 (UTC)
commit 1d2256a49a0cc0b31f059b70bfb194ad8123b9d2
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jul 14 13:10:46 2010 +1000
rearrange stuff to get python plugin debug output working
backends/gstreamer/rb-player-gst-xfade.c | 2 +-
bindings/Makefile.am | 6 +-
lib/rb-debug.c | 52 +++++++++++++++-----
lib/rb-debug.h | 9 +++-
.../artdisplay/EmbeddedCoverArtSearch.py | 1 +
.../artdisplay/artdisplay/LastFMCoverArtSearch.py | 4 +-
.../artdisplay/MusicBrainzCoverArtSearch.py | 1 -
.../artdisplay/artdisplay/PodcastCoverArtSearch.py | 2 +-
plugins/coherence/upnp_coherence/UpnpSource.py | 1 +
plugins/coherence/upnp_coherence/__init__.py | 1 +
plugins/context/context/AlbumTab.py | 1 +
plugins/context/context/ArtistTab.py | 1 +
plugins/context/context/ContextView.py | 2 +-
plugins/context/context/LyricsTab.py | 1 +
plugins/im-status/im-status/__init__.py | 2 +-
plugins/jamendo/jamendo/JamendoConfigureDialog.py | 1 +
plugins/jamendo/jamendo/JamendoSaxHandler.py | 1 +
plugins/jamendo/jamendo/JamendoSource.py | 2 +-
plugins/jamendo/jamendo/__init__.py | 1 +
plugins/lyrics/lyrics/LyricsConfigureDialog.py | 4 +-
plugins/lyrics/lyrics/LyricsParse.py | 3 +-
plugins/lyrics/lyrics/__init__.py | 1 -
plugins/magnatune/magnatune/MagnatuneSource.py | 3 +-
plugins/magnatune/magnatune/TrackListHandler.py | 1 +
plugins/magnatune/magnatune/__init__.py | 2 +-
plugins/pythonconsole/pythonconsole.py | 2 +-
plugins/rb/__init__.py | 15 ++---
plugins/replaygain/replaygain/__init__.py | 2 +-
plugins/replaygain/replaygain/config.py | 2 +-
plugins/replaygain/replaygain/player.py | 3 +-
plugins/sample-python/sample-python.py | 2 +-
plugins/sendto/__init__.py | 2 +-
podcast/test-podcast-parse.c | 12 ++--
33 files changed, 90 insertions(+), 55 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 0634d4c..49ce1be 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -1822,7 +1822,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
}
details = gst_structure_to_string (s);
- rb_debug_real ("check-imperfect", __FILE__, __LINE__, TRUE, "%s: %s", uri, details);
+ rb_debug_realf ("check-imperfect", __FILE__, __LINE__, TRUE, "%s: %s", uri, details);
g_free (details);
} else if (strcmp (name, "redirect") == 0) {
const char *uri = gst_structure_get_string (s, "new-location");
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index db1641d..a11efe4 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS = gi
-if ENABLE_VALA
-SUBDIRS += vala
-endif
+#if ENABLE_VALA
+#SUBDIRS += vala
+#endif
diff --git a/lib/rb-debug.c b/lib/rb-debug.c
index b45eead..62454fb 100644
--- a/lib/rb-debug.c
+++ b/lib/rb-debug.c
@@ -90,12 +90,46 @@ rb_debug_matches (const char *func,
* include one.
*/
+static void
+_rb_debug_print (const char *func, const char *file, const int line, gboolean newline, const char *buffer)
+{
+ char str_time[255];
+ time_t the_time;
+
+ time (&the_time);
+ strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
+
+ g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
+ str_time, g_thread_self (), func, file, line, buffer);
+}
+
/**
* rb_debug_real:
* @func: function name
* @file: file name
* @line: line number
* @newline: if TRUE, add a newline to the output
+ * @message: the debug message
+ *
+ * If the debug output settings match the function or file names,
+ * the debug message will be formatted and written to standard error.
+ *
+ * Rename to: debug
+ */
+void
+rb_debug_real (const char *func, const char *file, const int line, gboolean newline, const char *message)
+{
+ if (rb_debug_matches (func, file)) {
+ _rb_debug_print (func, file, line, newline, message);
+ }
+}
+
+/**
+ * rb_debug_realf:
+ * @func: function name
+ * @file: file name
+ * @line: line number
+ * @newline: if TRUE, add a newline to the output
* @format: printf style format specifier
* @Varargs: substitution values for @format
*
@@ -103,16 +137,14 @@ rb_debug_matches (const char *func,
* the debug message will be formatted and written to standard error.
*/
void
-rb_debug_real (const char *func,
- const char *file,
- const int line,
- gboolean newline,
- const char *format, ...)
+rb_debug_realf (const char *func,
+ const char *file,
+ const int line,
+ gboolean newline,
+ const char *format, ...)
{
va_list args;
char buffer[1025];
- char str_time[255];
- time_t the_time;
if (!rb_debug_matches (func, file))
return;
@@ -123,11 +155,7 @@ rb_debug_real (const char *func,
va_end (args);
- time (&the_time);
- strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
-
- g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
- str_time, g_thread_self (), func, file, line, buffer);
+ _rb_debug_print (func, file, line, newline, buffer);
}
/**
diff --git a/lib/rb-debug.h b/lib/rb-debug.h
index dd96576..bcdbe48 100644
--- a/lib/rb-debug.h
+++ b/lib/rb-debug.h
@@ -35,9 +35,9 @@
G_BEGIN_DECLS
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define rb_debug(...) rb_debug_real (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#define rb_debug(...) rb_debug_realf (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
#elif defined(__GNUC__) && __GNUC__ >= 3
-#define rb_debug(...) rb_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#define rb_debug(...) rb_debug_realf (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
#else
#define rb_debug
#endif
@@ -51,6 +51,11 @@ void rb_debug_real (const char *func,
const char *file,
int line,
gboolean newline,
+ const char *message);
+void rb_debug_realf (const char *func,
+ const char *file,
+ int line,
+ gboolean newline,
const char *format, ...) G_GNUC_PRINTF (5, 6);
char **rb_debug_get_args (void);
diff --git a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
index 3eee7e5..9f60497 100644
--- a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
@@ -27,6 +27,7 @@
import gst
import gobject
+import rb
from gi.repository import GdkPixbuf
from gi.repository import RhythmDB
diff --git a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
index 5ab368b..cf4fea0 100644
--- a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
@@ -28,12 +28,10 @@ import urllib
import xml.dom.minidom as dom
import re
-import gi
+import rb
from gi.repository import GConf
from gi.repository import RhythmDB
-import rb
-
# this API key belongs to jonathan d14n org
# and was generated specifically for this use
API_KEY = 'ff56d530598d65c1a4088e57da7be2f9'
diff --git a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
index bc1a230..891adfe 100644
--- a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
@@ -28,7 +28,6 @@ import urllib
import xml.dom.minidom as dom
import rb
-import gi
from gi.repository import RhythmDB
# musicbrainz URLs
diff --git a/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py b/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
index 9f50597..d56ef9b 100644
--- a/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
@@ -24,7 +24,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import gi
+import rb
from gi.repository import RhythmDB
class PodcastCoverArtSearch (object):
diff --git a/plugins/coherence/upnp_coherence/UpnpSource.py b/plugins/coherence/upnp_coherence/UpnpSource.py
index 4b944f1..f6a841a 100644
--- a/plugins/coherence/upnp_coherence/UpnpSource.py
+++ b/plugins/coherence/upnp_coherence/UpnpSource.py
@@ -6,6 +6,7 @@
import gobject
+import rb
from gi.repository import RB, RhythmDB
from coherence import __version_info__ as coherence_version
diff --git a/plugins/coherence/upnp_coherence/__init__.py b/plugins/coherence/upnp_coherence/__init__.py
index c8438f6..4291520 100644
--- a/plugins/coherence/upnp_coherence/__init__.py
+++ b/plugins/coherence/upnp_coherence/__init__.py
@@ -12,6 +12,7 @@ from coherence import log
# for the icon
import os.path, urllib, gio
+import rb
from gi.repository import RB
from gi.repository import Gtk, GConf, GdkPixbuf
diff --git a/plugins/context/context/AlbumTab.py b/plugins/context/context/AlbumTab.py
index d73e60d..1642918 100644
--- a/plugins/context/context/AlbumTab.py
+++ b/plugins/context/context/AlbumTab.py
@@ -34,6 +34,7 @@ import xml.dom.minidom as dom
import LastFM
+import rb
from gi.repository import RhythmDB
from gi.repository import Gtk
diff --git a/plugins/context/context/ArtistTab.py b/plugins/context/context/ArtistTab.py
index fe75313..6975854 100644
--- a/plugins/context/context/ArtistTab.py
+++ b/plugins/context/context/ArtistTab.py
@@ -33,6 +33,7 @@ import xml.dom.minidom as dom
import webkit
from mako.template import Template
+import rb
import LastFM
from gi.repository import Gtk
diff --git a/plugins/context/context/ContextView.py b/plugins/context/context/ContextView.py
index 4aef0cd..c0321b7 100644
--- a/plugins/context/context/ContextView.py
+++ b/plugins/context/context/ContextView.py
@@ -32,9 +32,9 @@ import ArtistTab as at
import AlbumTab as abt
import LyricsTab as lt
+import rb
from gi.repository import Gtk, Gdk, Pango
from gi.repository import RB, RhythmDB
-import rb
context_ui = """
<ui>
diff --git a/plugins/context/context/LyricsTab.py b/plugins/context/context/LyricsTab.py
index 2e01c29..f921f43 100644
--- a/plugins/context/context/LyricsTab.py
+++ b/plugins/context/context/LyricsTab.py
@@ -30,6 +30,7 @@ import re, os
import cgi
from mako.template import Template
+import rb
from gi.repository import Gtk
from gi.repository import RhythmDB
diff --git a/plugins/im-status/im-status/__init__.py b/plugins/im-status/im-status/__init__.py
index e19f3de..b6a90c5 100644
--- a/plugins/im-status/im-status/__init__.py
+++ b/plugins/im-status/im-status/__init__.py
@@ -25,7 +25,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import gi.repository
+import rb
from gi.repository import RB
from gi.repository import RhythmDB
diff --git a/plugins/jamendo/jamendo/JamendoConfigureDialog.py b/plugins/jamendo/jamendo/JamendoConfigureDialog.py
index b4724c9..7bdb536 100644
--- a/plugins/jamendo/jamendo/JamendoConfigureDialog.py
+++ b/plugins/jamendo/jamendo/JamendoConfigureDialog.py
@@ -20,6 +20,7 @@
import gobject
+import rb
from gi.repository import Gtk, GConf
gconf_keys = { 'format' : '/apps/rhythmbox/plugins/jamendo/format',
diff --git a/plugins/jamendo/jamendo/JamendoSaxHandler.py b/plugins/jamendo/jamendo/JamendoSaxHandler.py
index 40f7b73..9cd9763 100644
--- a/plugins/jamendo/jamendo/JamendoSaxHandler.py
+++ b/plugins/jamendo/jamendo/JamendoSaxHandler.py
@@ -21,6 +21,7 @@
import xml.sax, xml.sax.handler
import datetime
+import rb
from gi.repository import RhythmDB
data = {"artist" : ["name"],
diff --git a/plugins/jamendo/jamendo/JamendoSource.py b/plugins/jamendo/jamendo/JamendoSource.py
index 410ca61..ec091c5 100644
--- a/plugins/jamendo/jamendo/JamendoSource.py
+++ b/plugins/jamendo/jamendo/JamendoSource.py
@@ -27,9 +27,9 @@ import xml
import gzip
import datetime
+import rb
from gi.repository import Gtk, Gdk, GConf
from gi.repository import RB, RhythmDB
-import rb
from JamendoSaxHandler import JamendoSaxHandler
import JamendoConfigureDialog
diff --git a/plugins/jamendo/jamendo/__init__.py b/plugins/jamendo/jamendo/__init__.py
index 6e273f7..c6d6704 100644
--- a/plugins/jamendo/jamendo/__init__.py
+++ b/plugins/jamendo/jamendo/__init__.py
@@ -34,6 +34,7 @@ import gobject
from JamendoSource import JamendoSource
from JamendoConfigureDialog import JamendoConfigureDialog
+import rb
from gi.repository import Gtk
from gi.repository import RB
diff --git a/plugins/lyrics/lyrics/LyricsConfigureDialog.py b/plugins/lyrics/lyrics/LyricsConfigureDialog.py
index 284d429..332a715 100644
--- a/plugins/lyrics/lyrics/LyricsConfigureDialog.py
+++ b/plugins/lyrics/lyrics/LyricsConfigureDialog.py
@@ -28,9 +28,9 @@
from LyricsSites import lyrics_sites
import gobject
-import gi
-
from os import system, path
+
+import rb
from gi.repository import Gtk, GConf
class LyricsConfigureDialog (object):
diff --git a/plugins/lyrics/lyrics/LyricsParse.py b/plugins/lyrics/lyrics/LyricsParse.py
index 610791a..637517b 100644
--- a/plugins/lyrics/lyrics/LyricsParse.py
+++ b/plugins/lyrics/lyrics/LyricsParse.py
@@ -27,9 +27,8 @@
import urllib
import re
import gobject
-import rb
-import gi
+import rb
from gi.repository import GConf
from LyricsSites import lyrics_sites
diff --git a/plugins/lyrics/lyrics/__init__.py b/plugins/lyrics/lyrics/__init__.py
index ea9ae29..11746fb 100644
--- a/plugins/lyrics/lyrics/__init__.py
+++ b/plugins/lyrics/lyrics/__init__.py
@@ -27,7 +27,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
import os, re
-import gi
import rb
from gi.repository import Gtk, GConf
diff --git a/plugins/magnatune/magnatune/MagnatuneSource.py b/plugins/magnatune/magnatune/MagnatuneSource.py
index bb947f7..0aafcdb 100644
--- a/plugins/magnatune/magnatune/MagnatuneSource.py
+++ b/plugins/magnatune/magnatune/MagnatuneSource.py
@@ -25,8 +25,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rb
-
import os
import gobject, gio
import xml
@@ -35,6 +33,7 @@ import urlparse
import threading
import zipfile
+import rb
from gi.repository import RB, RhythmDB
from gi.repository import Gtk, GConf, GnomeKeyring
diff --git a/plugins/magnatune/magnatune/TrackListHandler.py b/plugins/magnatune/magnatune/TrackListHandler.py
index b4f78a4..72ea523 100644
--- a/plugins/magnatune/magnatune/TrackListHandler.py
+++ b/plugins/magnatune/magnatune/TrackListHandler.py
@@ -28,6 +28,7 @@
import xml.sax, xml.sax.handler
import datetime, re, urllib
+import rb
from gi.repository import RhythmDB
class TrackListHandler(xml.sax.handler.ContentHandler):
diff --git a/plugins/magnatune/magnatune/__init__.py b/plugins/magnatune/magnatune/__init__.py
index 564d4ba..6a65884 100644
--- a/plugins/magnatune/magnatune/__init__.py
+++ b/plugins/magnatune/magnatune/__init__.py
@@ -25,7 +25,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rb
import gobject
import urllib
@@ -35,6 +34,7 @@ import xml
import datetime
import string
+import rb
from gi.repository import RhythmDB
from gi.repository import GConf, GnomeKeyring, Gtk
diff --git a/plugins/pythonconsole/pythonconsole.py b/plugins/pythonconsole/pythonconsole.py
index 006530f..c5d5f60 100644
--- a/plugins/pythonconsole/pythonconsole.py
+++ b/plugins/pythonconsole/pythonconsole.py
@@ -37,7 +37,7 @@ import sys
import re
import traceback
import gobject
-import gi.repository
+
from gi.repository import Gtk, Gdk, Pango, GConf
from gi.repository import RB
from gi.repository import RhythmDB
diff --git a/plugins/rb/__init__.py b/plugins/rb/__init__.py
index de7b6ab..92d0630 100644
--- a/plugins/rb/__init__.py
+++ b/plugins/rb/__init__.py
@@ -29,6 +29,10 @@
import sys
import os.path
import os
+import time
+import thread
+
+from gi.repository import RB
# rb classes
from Loader import Loader
@@ -37,12 +41,6 @@ from Loader import UpdateCheck
from Coroutine import Coroutine
from URLCache import URLCache
-#def _excepthandler (exc_class, exc_inst, trace):
-# import sys
-# # print out stuff ignoring our debug redirect
-# sys.__excepthook__ (exc_class, exc_inst, trace)
-
-
def try_load_icon(theme, icon, size, flags):
try:
return theme.load_icon(icon, size, flags)
@@ -88,7 +86,8 @@ class _rbdebugfile:
if fr.f_locals.has_key('self'):
methodname = '%s.%s' % (fr.f_locals['self'].__class__.__name__, methodname)
- rb._debug (methodname, filename, co.co_firstlineno + fr.f_lineno, True, str)
+ ln = co.co_firstlineno + fr.f_lineno
+ RB.debug (methodname, filename, ln, True, str)
def close(self): pass
def flush(self): pass
@@ -103,5 +102,3 @@ class _rbdebugfile:
truncate = tell
sys.stdout = _rbdebugfile(sys.stdout.fileno())
-#sys.excepthook = _excepthandler
-
diff --git a/plugins/replaygain/replaygain/__init__.py b/plugins/replaygain/replaygain/__init__.py
index 9d0ea46..8ad9ebb 100644
--- a/plugins/replaygain/replaygain/__init__.py
+++ b/plugins/replaygain/replaygain/__init__.py
@@ -25,7 +25,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
-import gi.repository
+import rb
from gi.repository import RB
from config import ReplayGainConfigDialog
diff --git a/plugins/replaygain/replaygain/config.py b/plugins/replaygain/replaygain/config.py
index 552332d..e4c2710 100644
--- a/plugins/replaygain/replaygain/config.py
+++ b/plugins/replaygain/replaygain/config.py
@@ -26,7 +26,7 @@
#
import gobject
-import gi.repository
+import rb
from gi.repository import Gtk
from gi.repository import GConf
from gi.repository import RB
diff --git a/plugins/replaygain/replaygain/player.py b/plugins/replaygain/replaygain/player.py
index fe6857f..4106220 100644
--- a/plugins/replaygain/replaygain/player.py
+++ b/plugins/replaygain/replaygain/player.py
@@ -27,7 +27,8 @@
import gobject
import gst
-import gi.repository
+
+import rb
from gi.repository import GConf
from gi.repository import RB
diff --git a/plugins/sample-python/sample-python.py b/plugins/sample-python/sample-python.py
index 7ee9c5a..4db47f2 100644
--- a/plugins/sample-python/sample-python.py
+++ b/plugins/sample-python/sample-python.py
@@ -1,6 +1,6 @@
import gobject
-import gi.repository
+import rb
from gi.repository import RB
class SamplePython(RB.Plugin):
diff --git a/plugins/sendto/__init__.py b/plugins/sendto/__init__.py
index 5afc308..af9df2d 100644
--- a/plugins/sendto/__init__.py
+++ b/plugins/sendto/__init__.py
@@ -25,7 +25,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
import glib
-import gi.repository
+import rb
from gi.repository import Gtk
from gi.repository import RB
diff --git a/podcast/test-podcast-parse.c b/podcast/test-podcast-parse.c
index f45431a..7ed5907 100644
--- a/podcast/test-podcast-parse.c
+++ b/podcast/test-podcast-parse.c
@@ -38,7 +38,7 @@
static gboolean debug = FALSE;
-void rb_debug_real (const char *func,
+void rb_debug_realf (const char *func,
const char *file,
int line,
gboolean newline,
@@ -46,11 +46,11 @@ void rb_debug_real (const char *func,
/* For the benefit of the podcast parsing code */
void
-rb_debug_real (const char *func,
- const char *file,
- int line,
- gboolean newline,
- const char *format, ...)
+rb_debug_realf (const char *func,
+ const char *file,
+ int line,
+ gboolean newline,
+ const char *format, ...)
{
va_list args;
char buffer[1025];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]