From bff93f186a4b1e693b992d8b988ba0a7cd0eab8f Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 24 Feb 2009 04:41:23 +0000 Subject: [PATCH] 0002655: Directories and files with accents characters cause failures in Windows. svn: r12106 --- src/Editors/AddMedia.py | 4 ++-- src/ExportAssistant.py | 6 ++---- src/PluginUtils/_GuiOptions.py | 2 +- src/ReportBase/_FileEntry.py | 4 ++-- src/Utils.py | 1 - src/plugins/export/ExportPkg.py | 2 +- src/plugins/tool/Check.py | 3 +-- src/plugins/tool/EventCmp.py | 3 +-- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Editors/AddMedia.py b/src/Editors/AddMedia.py index 13789b938..ecc57e3f5 100644 --- a/src/Editors/AddMedia.py +++ b/src/Editors/AddMedia.py @@ -160,11 +160,11 @@ class AddMediaObject(ManagedWindow.ManagedWindow): filename = Utils.get_unicode_path(self.file_text.get_filename()) full_file = filename - pname = Utils.media_path(self.dbase) + pname = unicode(Utils.media_path(self.dbase)) if self.relpath.get_active(): filename = Utils.relative_path(filename, pname) - if os.path.exists(pname) == 0: + if not os.path.exists(pname): msgstr = _("Cannot import %s") msgstr2 = _("The filename supplied could not be found.") ErrorDialog(msgstr % filename, msgstr2) diff --git a/src/ExportAssistant.py b/src/ExportAssistant.py index 61ae2165a..826a14f1b 100644 --- a/src/ExportAssistant.py +++ b/src/ExportAssistant.py @@ -439,8 +439,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : #Allow for exotic error: file is still not correct self.check_fileselect(self.chooser, show=False) if self.get_page_complete(self.chooser) : - filename = unicode(self.chooser.get_filename(), - sys.getfilesystemencoding()) + filename = Utils.get_unicode_path(self.chooser.get_filename()) name = os.path.split(filename)[1] folder = os.path.split(filename)[0] confirm_text = _( @@ -563,8 +562,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : Depending on the success status, set the text for the final page. """ - filename = unicode(self.chooser.get_filename(), - sys.getfilesystemencoding()) + filename = Utils.get_unicode_path(self.chooser.get_filename()) Config.set(Config.RECENT_EXPORT_DIR, os.path.split(filename)[0]) ix = self.get_selected_format_index() Config.set(Config.RECENT_EXPORT_TYPE, ix) diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 39c9d5fd5..9b90c6148 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -1261,7 +1261,7 @@ class GuiDestinationOption(gtk.HBox): status = fcd.run() if status == gtk.RESPONSE_OK: - path = unicode(fcd.get_filename(), sys.getfilesystemencoding()) + path = Utils.get_unicode_path(fcd.get_filename()) if path: if not self.__option.get_directory_entry() and \ not path.endswith(self.__option.get_extension()): diff --git a/src/ReportBase/_FileEntry.py b/src/ReportBase/_FileEntry.py index c816718e4..e7f5688cd 100644 --- a/src/ReportBase/_FileEntry.py +++ b/src/ReportBase/_FileEntry.py @@ -23,6 +23,7 @@ import os import sys import gtk +import Utils class FileEntry(gtk.HBox): def __init__(self,defname,title): @@ -68,8 +69,7 @@ class FileEntry(gtk.HBox): f.present() status = f.run() if status == gtk.RESPONSE_OK: - self.set_filename(unicode(f.get_filename(), - sys.getfilesystemencoding())) + self.set_filename(Utils.get_unicode_path(f.get_filename())) f.destroy() def set_filename(self,path): diff --git a/src/Utils.py b/src/Utils.py index b014d8803..f8f60cc79 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1128,7 +1128,6 @@ def open_file_with_default_application( file_path ): return if os.sys.platform == 'win32': - norm_path = norm_path.encode(os.sys.getfilesystemencoding()) try: os.startfile(norm_path) except WindowsError, msg: diff --git a/src/plugins/export/ExportPkg.py b/src/plugins/export/ExportPkg.py index 3f7b46218..053051db2 100644 --- a/src/plugins/export/ExportPkg.py +++ b/src/plugins/export/ExportPkg.py @@ -185,7 +185,7 @@ class PackageWriter: # during the process (i.e. when removing object) for m_id in self.db.get_media_object_handles(): mobject = self.db.get_object_from_handle(m_id) - filename = str(Utils.media_path_full(self.db, mobject.get_path())) + filename = Utils.media_path_full(self.db, mobject.get_path()) archname = str(mobject.get_path()) if os.path.isfile(filename): archive.add(filename, archname) diff --git a/src/plugins/tool/Check.py b/src/plugins/tool/Check.py index b39eb2ff4..895e8083e 100644 --- a/src/plugins/tool/Check.py +++ b/src/plugins/tool/Check.py @@ -523,8 +523,7 @@ class CheckIntegrity: self.bad_photo.append(ObjectId) def fs_ok_clicked(obj): - name = unicode(fs_top.get_filename(), - sys.getfilesystemencoding()) + name = Utils.get_unicode_path(fs_top.get_filename()) if os.path.isfile(name): obj = self.db.get_object_from_handle(ObjectId) obj.set_path(name) diff --git a/src/plugins/tool/EventCmp.py b/src/plugins/tool/EventCmp.py index f684bc4e5..e110fa1ba 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -399,8 +399,7 @@ class DisplayChart(ManagedWindow.ManagedWindow): f.hide() if status == gtk.RESPONSE_OK: - name = unicode(f.get_filename(), - sys.getfilesystemencoding()) + name = Utils.get_unicode_path(f.get_filename()) doc = ODSTab(len(self.row_data)) doc.creator(self.db.get_researcher().get_name())