From 0b4e1f2b412ad236c271b8f77cb0007dd091d4c3 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 17 May 2012 14:04:09 +0200 Subject: Fix the "No such file or directory" logo bug --- lib/mat.py | 14 +++++++------- mat | 2 +- mat-gui | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/mat.py b/lib/mat.py index 9196ed2..59f6058 100644 --- a/lib/mat.py +++ b/lib/mat.py @@ -31,16 +31,16 @@ LOGGING_LEVEL = logging.DEBUG logging.basicConfig(filename=fname, level=LOGGING_LEVEL) -def get_sharedir(): +def get_sharedir(filename): ''' - An ugly hack to find where is the "FORMATS" file. + An ugly hack to find various files ''' - if os.path.isfile('FORMATS'): + if os.path.exists(os.path.join('/usr/local/share/mat/', filename)): + return os.path.join('/usr/local/share/mat/', filename) + elif os.path.exists(os.path.join('/usr/share/mat/', filename)): + return os.path.join('/usr/share/mat', filename) + elif os.path.isfile('FORMATS'): return '.' - elif os.path.exists('/usr/local/share/mat/'): - return '/usr/local/share/mat/' - elif os.path.exists('/usr/share/mat/'): - return '/usr/share/mat' class XMLParser(xml.sax.handler.ContentHandler): diff --git a/mat b/mat index 6ce09d9..93792e3 100755 --- a/mat +++ b/mat @@ -104,7 +104,7 @@ def list_supported(): handler = mat.XMLParser() parser = xml.sax.make_parser() parser.setContentHandler(handler) - path = os.path.join(mat.get_sharedir(), 'FORMATS') + path = mat.get_sharedir('FORMATS') with open(path, 'r') as xmlfile: parser.parse(xmlfile) diff --git a/mat-gui b/mat-gui index 3942689..18c7467 100755 --- a/mat-gui +++ b/mat-gui @@ -52,8 +52,8 @@ class GUI: self.window.set_title('Metadata Anonymisation Toolkit') self.window.connect('destroy', gtk.main_quit) self.window.set_default_size(800, 600) - path = os.path.join(mat.get_sharedir(), 'logo.png') - icon = gtk.gdk.pixbuf_new_from_file_at_size(path, 50, 50) + self.logo = mat.get_sharedir('logo.png') + icon = gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 50, 50) self.window.set_icon(icon) self.accelerator = gtk.AccelGroup() @@ -379,7 +379,7 @@ class GUI: w.set_artists(['Marine BenoƮt', ]) w.set_copyright('GNU Public License v2') w.set_comments(_('This software was coded during the GSoC 2011')) - w.set_logo(gtk.gdk.pixbuf_new_from_file_at_size('logo.png', 400, 200)) + w.set_logo(gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 400, 200)) w.set_program_name('Metadata Anonymisation Toolkit') w.set_version(mat.__version__) w.set_website('https://mat.boum.org') @@ -405,7 +405,7 @@ class GUI: handler = mat.XMLParser() parser = xml.sax.make_parser() parser.setContentHandler(handler) - path = os.path.join(mat.get_sharedir(), 'FORMATS') + path = mat.get_sharedir('FORMATS') with open(path, 'r') as xmlfile: parser.parse(xmlfile) -- cgit v1.3