From 16a8c477ec544970414592c1c5e5786d4ba369e5 Mon Sep 17 00:00:00 2001 From: nikosapi Date: Mon, 27 Oct 2008 20:36:44 +0000 Subject: [PATCH] Add a --debug switch on the command line git-svn-id: https://garage.maemo.org/svn/panucci/trunk@47 b83bf47a-295c-422b-8be9-b3ce96edbbb2 --- bin/panucci | 4 +++- src/panucci/panucci.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/panucci b/bin/panucci index b130630..230bcbe 100755 --- a/bin/panucci +++ b/bin/panucci @@ -24,7 +24,9 @@ except dbus.exceptions.DBusException: if remote_object is None: from panucci import panucci - panucci.run(filename) + # This could eventually be made fancy with optparse + debug = '--debug' in sys.argv + panucci.run(filename=filename, debug=debug) else: if filename is None: remote_object.show_main_window(dbus_interface='org.panucci.interface') diff --git a/src/panucci/panucci.py b/src/panucci/panucci.py index 56da903..2010ecb 100644 --- a/src/panucci/panucci.py +++ b/src/panucci/panucci.py @@ -56,11 +56,13 @@ gconf_dir = '/apps/panucci' coverart_names = [ 'cover', 'cover.jpg', 'cover.png' ] coverart_size = [240, 240] if running_on_tablet else [130, 130] - +debug_override = False def log( msg ): """ A very simple log function (no log output is produced when using the python optimization (-O, -OO) options) """ - if __debug__: + global debug_override + + if __debug__ or debug_override: print msg def open_link(d, url, data): @@ -954,7 +956,10 @@ class GTK_Main(dbus.service.Object): return time_str -def run(filename=None): +def run(filename=None, debug=False): + global debug_override + debug_override = debug + session_bus = dbus.SessionBus(mainloop=dbus.glib.DBusGMainLoop()) bus_name = dbus.service.BusName('org.panucci', bus=session_bus) GTK_Main(bus_name, filename) @@ -963,6 +968,6 @@ def run(filename=None): pm.save() if __name__ == '__main__': - log( 'WARNING: Use the "panucci" executable, to run this program.' ) + log( 'WARNING: Use the "panucci" executable to run this program.' ) log( 'Exiting...' ) -- 2.11.4.GIT