From 5dd18f38daf287c98dda014c8531346a6dd266bf Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Thu, 8 Dec 2011 10:23:50 +0100 Subject: [PATCH 1/3] Improve resources search. --- laditools/ladimenu.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/laditools/ladimenu.py b/laditools/ladimenu.py index 56d1253..6938b19 100644 --- a/laditools/ladimenu.py +++ b/laditools/ladimenu.py @@ -352,8 +352,9 @@ def find_data_file(path): start_dir = "." paths = [ - start_dir + os.sep + "data" + os.sep + path, - start_dir + os.sep + ".." + os.sep + "share"+ os.sep + "laditools" + os.sep + "data" + os.sep + path, + os.path.join(sys.path[0], 'data', path), + os.path.join(os.path.join(sys.path[0], os.pardir), 'data', path), + os.path.join(os.path.join(sys.path[0], os.pardir), 'share', 'laditools', 'data', path), ] for path in paths: From affc44313a364a71e64d5e5fd65ab129eec5ffd7 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Thu, 8 Dec 2011 10:36:04 +0100 Subject: [PATCH 2/3] Use new-style classes. --- laditools/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laditools/config.py b/laditools/config.py index 7e776c0..c7dc853 100644 --- a/laditools/config.py +++ b/laditools/config.py @@ -29,7 +29,7 @@ if not exists (config_dir): # Note to users of the config class. Only applications should create an instance # of the config object. The ladimenu is *NOT* an application... -class config: +class config(object): def __init__ (self): try: with open (config_filename) as config_file: From aadb58e15e004879449b237cb92921c999eeecf1 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Thu, 8 Dec 2011 11:10:13 +0100 Subject: [PATCH 3/3] Replace "print" calls with sys.stderr.{write,flush}() - Debug messages should go to the stderr rather than to the stdout - Plus, Python 3 has replaced the built-in "print" with a new function, whose syntax is quite different. --- laditools/config.py | 3 ++- laditools/jack_controller.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/laditools/config.py b/laditools/config.py index c7dc853..ef858bb 100644 --- a/laditools/config.py +++ b/laditools/config.py @@ -35,7 +35,8 @@ class config(object): with open (config_filename) as config_file: self.appdict = yaml.load (config_file) except: - print "Config file doesn't exist, creating a new one..." + sys.stderr.write("Config file doesn't exist, creating a new one...\n") + sys.stderr.flush() self.appdict = dict () # Returns the section named from the global config diff --git a/laditools/jack_controller.py b/laditools/jack_controller.py index afd9959..51fe571 100644 --- a/laditools/jack_controller.py +++ b/laditools/jack_controller.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import dbus +import sys name_base = 'org.jackaudio' controller_interface_name = name_base + '.JackControl' @@ -30,7 +31,8 @@ class jack_controller: # self.bus.add_signal_receiver (self.name_owner_changed, dbus_interface = controller_interface_name, signal_name = "NameOwnerChanged") def name_owner_changed (name = None, old_owner = None, new_owner = None): - print "Name changed : %r" % name + sys.stderr.write("Name changed : %r\n" % name) + sys.stderr.flush() def is_available (self): try: