0000995: Don't have write access on import/open in paths containing non-ASCII characters.

svn: r8367
This commit is contained in:
Brian Matherly 2007-04-09 04:24:06 +00:00
parent bc0b71f125
commit b7b80b3d0a
12 changed files with 47 additions and 29 deletions

View File

@ -1,3 +1,18 @@
2007-04-08 Brian Matherly <brian@gramps-project.org>
* src\Exporter.py
* src\ReportBase\_FileEntry.py
* src\Editors\_EditMedia.py
* src\plugins\WriteCD.py
* src\plugins\WritePkg.py
* src\plugins\Check.py
* src\plugins\EventCmp.py
* src\AddMedia.py
* src\Utils.py
* src\ArgHandler.py
* src\DbLoader.py
0000995: Don't have write access on import/open in paths containing
non-ASCII characters.
2007-04-08 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: 0001006: Narrative Web: Media objects missing
title (description), mime_type, or path, are displayed poorly.

View File

@ -131,8 +131,7 @@ class AddMediaObject(ManagedWindow.ManagedWindow):
mobj.set_handle(Utils.create_id())
mobj.set_mime_type(None)
else:
filename = unicode(self.file_text.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(self.file_text.get_filename())
full_file = filename
if self.relpath.get_active():
@ -176,7 +175,7 @@ class AddMediaObject(ManagedWindow.ManagedWindow):
fn = self.file_text.get_filename()
if not fn:
return
filename = unicode(fn, sys.getfilesystemencoding())
filename = Utils.get_unicode_path(fn)
basename = os.path.basename(filename)
(root,ext) = os.path.splitext(basename)
old_title = unicode(self.description.get_text())

View File

@ -743,8 +743,7 @@ class NewNativeDbPrompter:
while (True):
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(choose.get_filename())
if filename == None:
continue
if os.path.splitext(filename)[1] != ".grdb":

View File

@ -99,8 +99,7 @@ class DbLoader:
choose.set_current_folder(get_default_dir())
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(choose.get_filename())
if self.check_errors(filename):
return ('','')
@ -156,8 +155,7 @@ class DbLoader:
while (True):
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(choose.get_filename())
if self.check_errors(filename):
return ('','')
@ -219,8 +217,7 @@ class DbLoader:
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(choose.get_filename())
if self.check_errors(filename):
return ('','')
@ -311,8 +308,7 @@ class DbLoader:
choose.set_current_folder(default_dir)
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
filename = Utils.get_unicode_path(choose.get_filename())
if self.check_errors(filename):
return False

View File

@ -46,6 +46,7 @@ import Config
import RelLib
import Mime
import ImgManip
import Utils
from _EditPrimary import EditPrimary
from GrampsWidgets import *
@ -217,8 +218,7 @@ class EditMedia(EditPrimary):
status = f.run()
if status == gtk.RESPONSE_OK:
self.file_path.set_text(unicode(f.get_filename(),
sys.getfilesystemencoding()))
self.file_path.set_text(Utils.get_unicode_path(f.get_filename()))
f.destroy()
def setup_filepath(self):

View File

@ -152,8 +152,7 @@ class Exporter:
the selected options (format, filename) and present the summary
of the proposed action.
"""
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]
ix = self.get_selected_format_index()
@ -174,8 +173,7 @@ class Exporter:
Perform the actual Save As/Export operation.
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()
self.pre_save()

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

@ -335,6 +335,20 @@ def find_folder( filename):
# not found
return ''
def get_unicode_path(path):
"""
Return the Unicode version of a path string.
@type path: str
@param path: The path to be converted to Unicode
@rtype: unicode
@return: The Unicode version of path.
"""
if os.sys.platform == "win32":
return unicode(path)
else:
return unicode(path,sys.getfilesystemencoding())
#-------------------------------------------------------------------------
#
#

View File

@ -502,8 +502,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

@ -417,8 +417,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())
pstyle = BaseDoc.PaperStyle("junk",10,10)
doc = ODSDoc.ODSDoc(pstyle,BaseDoc.PAPER_PORTRAIT)
doc.creator(self.db.get_researcher().get_name())

View File

@ -71,6 +71,7 @@ import Mime
import const
import QuestionDialog
import ImgManip
import Utils
from PluginUtils import register_export
_title_string = _("Export to CD")
@ -235,8 +236,7 @@ class PackageWriter:
pass
def fs_ok_clicked(obj):
newfile = unicode(fs_top.get_filename(),
sys.getfilesystemencoding())
newfile = Utils.get_unicode_path(fs_top.get_filename())
if os.path.isfile(newfile):
self.copy_file(newfile,'burn:///%s/%s' % (base,obase))
ntype = Mime.get_type(newfile)

View File

@ -140,8 +140,7 @@ class PackageWriter:
pass
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):
archive.add(name)