0002655: Directories and files with accents characters cause failures in Windows.

svn: r12106
This commit is contained in:
Brian Matherly 2009-02-24 04:41:23 +00:00
parent bc081c401c
commit bff93f186a
8 changed files with 10 additions and 15 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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()):

View File

@ -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):

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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())