diff --git a/src/ExportAssistant.py b/src/ExportAssistant.py index ab112a8d4..13fb8cbab 100644 --- a/src/ExportAssistant.py +++ b/src/ExportAssistant.py @@ -476,7 +476,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 = Utils.get_unicode_path(self.chooser.get_filename()) + filename = Utils.get_unicode_path_from_file_chooser(self.chooser.get_filename()) name = os.path.split(filename)[1] folder = os.path.split(filename)[0] confirm_text = _( @@ -610,7 +610,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : hasattr(self.option_box_instance, "no_fileselect")): filename = "" else: - filename = Utils.get_unicode_path(self.chooser.get_filename()) + filename = Utils.get_unicode_path_from_file_chooser(self.chooser.get_filename()) config.set('paths.recent-export-dir', os.path.split(filename)[0]) ix = self.get_selected_format_index() config.set('behavior.recent-export-type', ix) diff --git a/src/Filters/_FilterList.py b/src/Filters/_FilterList.py index b486a691e..12c56ea1f 100644 --- a/src/Filters/_FilterList.py +++ b/src/Filters/_FilterList.py @@ -27,6 +27,7 @@ #------------------------------------------------------------------------- from xml.sax import make_parser, SAXParseException import os +import sys #------------------------------------------------------------------------- # @@ -84,8 +85,7 @@ class FilterList(object): return l.replace('"', '"') def save(self): - f = open(self.file.encode('utf-8'), 'w') - + f = open(self.file.encode(sys.getfilesystemencoding()), 'w') f.write("\n") f.write('\n') for namespace in self.filter_namespaces: diff --git a/src/ImgManip.py b/src/ImgManip.py index 6898831ec..aeaf22de7 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -38,6 +38,13 @@ import tempfile # #------------------------------------------------------------------------- +#------------------------------------------------------------------------- +# +# Gramps modules +# +#------------------------------------------------------------------------- +import Utils + #------------------------------------------------------------------------- # # resize_to_jpeg @@ -111,6 +118,7 @@ def resize_to_jpeg_buffer(source, width, height): img = gtk.gdk.pixbuf_new_from_file(source) scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR) os.close(filed) + dest = Utils.get_unicode_path_from_env_var(dest) scaled.save(dest, 'jpeg') ofile = open(dest, mode='rb') data = ofile.read() diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index edd332fdc..3faa518f8 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -1275,7 +1275,7 @@ class GuiDestinationOption(gtk.HBox): status = fcd.run() if status == gtk.RESPONSE_OK: - path = Utils.get_unicode_path(fcd.get_filename()) + path = Utils.get_unicode_path_from_file_chooser(fcd.get_filename()) if path: if not self.__option.get_directory_entry() and \ not path.endswith(self.__option.get_extension()): diff --git a/src/PluginUtils/_PluginWindows.py b/src/PluginUtils/_PluginWindows.py index d7302dc00..97660a4c5 100644 --- a/src/PluginUtils/_PluginWindows.py +++ b/src/PluginUtils/_PluginWindows.py @@ -601,7 +601,7 @@ class PluginStatus(ManagedWindow.ManagedWindow): # But don't use converted filenames # in the call to self.__pmgr.reg_plugins # as that will break in reg_plugins. - u_gpr_file = unicode(gpr_file, sys.getfilesystemencoding()) + u_gpr_file = Utils.get_unicode_path_from_file_chooser(gpr_file) callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n") self.__pmgr.reg_plugins(gpr_file) @@ -629,7 +629,7 @@ class PluginStatus(ManagedWindow.ManagedWindow): status = fcd.run() if status == gtk.RESPONSE_OK: - path = Utils.get_unicode_path(fcd.get_filename()) + path = Utils.get_unicode_path_from_file_chooser(fcd.get_filename()) if path: self.install_addon_path.set_text(path) fcd.destroy() diff --git a/src/ReportBase/_FileEntry.py b/src/ReportBase/_FileEntry.py index 7bbb25a4d..19fcdf7f6 100644 --- a/src/ReportBase/_FileEntry.py +++ b/src/ReportBase/_FileEntry.py @@ -73,7 +73,7 @@ class FileEntry(gtk.HBox): dialog.present() status = dialog.run() if status == gtk.RESPONSE_OK: - self.set_filename(Utils.get_unicode_path(dialog.get_filename())) + self.set_filename(Utils.get_unicode_path_from_file_chooser(dialog.get_filename())) dialog.destroy() def set_filename(self, path): diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 9a1c9077b..a219abae0 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -35,6 +35,7 @@ import time from types import ClassType, InstanceType from gen.ggettext import gettext as _ from subprocess import Popen, PIPE +import sys #------------------------------------------------------------------------------- # @@ -446,7 +447,11 @@ class GVPsDoc(GVDocBase): # If I take a correct multip page PDF and convert it with pdf2ps I get multip pages, # but the output is clipped, some margins have disappeared. I used 1 inch margins always. # See bug tracker issue 2815 - command = 'dot -Tps:cairo -o"%s" "%s"' % (self._filename, tmp_dot) + + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) + + command = 'dot -Tps:cairo -o"%s" "%s"' % (fname, tmp_dot) dotversion = Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1] if dotversion.find('2.26.3') != -1: command=command.replace(':cairo','') @@ -455,7 +460,7 @@ class GVPsDoc(GVDocBase): os.remove(tmp_dot) if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # @@ -493,15 +498,17 @@ class GVSvgDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the SVG file. - os.system( 'dot -Tsvg -o"%s" "%s"' % (self._filename, tmp_dot) ) + os.system( 'dot -Tsvg -o"%s" "%s"' % (fname, tmp_dot) ) # Delete the temporary dot file os.remove(tmp_dot) if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # @@ -539,15 +546,17 @@ class GVSvgzDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the SVGZ file. - os.system( 'dot -Tsvgz -o"%s" "%s"' % (self._filename, tmp_dot) ) + os.system( 'dot -Tsvgz -o"%s" "%s"' % (fname, tmp_dot) ) # Delete the temporary dot file os.remove(tmp_dot) if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # @@ -585,15 +594,17 @@ class GVPngDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the PNG file. - os.system( 'dot -Tpng -o"%s" "%s"' % (self._filename, tmp_dot) ) + os.system( 'dot -Tpng -o"%s" "%s"' % (fname, tmp_dot) ) # Delete the temporary dot file os.remove(tmp_dot) if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # @@ -631,9 +642,11 @@ class GVJpegDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the JPEG file. - os.system( 'dot -Tjpg -o"%s" "%s"' % (self._filename, tmp_dot) ) + os.system( 'dot -Tjpg -o"%s" "%s"' % (fname, tmp_dot) ) # Delete the temporary dot file os.remove(tmp_dot) @@ -677,9 +690,11 @@ class GVGifDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the GIF file. - os.system( 'dot -Tgif -o"%s" "%s"' % (self._filename, tmp_dot) ) + os.system( 'dot -Tgif -o"%s" "%s"' % (fname, tmp_dot) ) # Delete the temporary dot file os.remove(tmp_dot) @@ -726,16 +741,18 @@ class GVPdfGvDoc(GVDocBase): dotfile = os.fdopen(handle,"w") dotfile.write(self._dot.getvalue()) dotfile.close() - + # Covert filename to str using file system encoding. + fname = self._filename.encode(sys.getfilesystemencoding()) # Generate the PDF file. - command = 'dot -Tpdf -o"%s" "%s"' % (self._filename, tmp_dot) + command = 'dot -Tpdf -o"%s" "%s"' % (fname, tmp_dot) + os.system( command ) # Delete the temporary dot file os.remove(tmp_dot) - + if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # @@ -791,16 +808,18 @@ class GVPdfGsDoc(GVDocBase): height_pt = int( (paper_size.get_height_inches() * 72) + 0.5 ) # Convert to PDF using ghostscript + fname = self._filename.encode(sys.getfilesystemencoding()) command = '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dDEVICEWIDTHPOINTS=%d' \ ' -dDEVICEHEIGHTPOINTS=%d -sOutputFile="%s" "%s" -c quit' \ - % ( _GS_CMD, width_pt, height_pt, self._filename, tmp_ps ) + % ( _GS_CMD, width_pt, height_pt, fname, tmp_ps ) + os.system(command) os.remove(tmp_ps) os.remove(tmp_dot) if self.open_req: - open_file_with_default_application(self._filename) + open_file_with_default_application(fname) #------------------------------------------------------------------------------- # diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 23f431b0f..936f54fa9 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -57,6 +57,7 @@ from _StyleComboBox import StyleComboBox from _StyleEditor import StyleListDisplay from _FileEntry import FileEntry from const import URL_MANUAL_PAGE +import Utils #------------------------------------------------------------------------- # @@ -466,7 +467,7 @@ class ReportDialog(ManagedWindow.ManagedWindow): to tell the calling routine to give up. This function also saves the current directory so that any future reports will default to the most recently used directory.""" - self.target_path = self.target_fileentry.get_full_path(0) + self.target_path = Utils.get_unicode_path_from_file_chooser(self.target_fileentry.get_full_path(0)) if not self.target_path: return None diff --git a/src/TransUtils.py b/src/TransUtils.py index dfa81f0a2..ac9d6939b 100644 --- a/src/TransUtils.py +++ b/src/TransUtils.py @@ -226,6 +226,11 @@ def get_addon_translator(filename=None, domain="addon"): gramps_translator = gettext.translation(LOCALEDOMAIN, LOCALEDIR, fallback=True) path = os.path.dirname(os.path.abspath(filename)) + # Check if path is of type str. Do import and conversion if so. + # The import cannot be done at the top as that will conflict with the translation system. + if type(path) == str: + from Utils import get_unicode_path_from_env_var + path = get_unicode_path_from_env_var(path) addon_translator = gettext.translation(domain, os.path.join(path,"locale"), fallback=True) gramps_translator.add_fallback(addon_translator) diff --git a/src/Utils.py b/src/Utils.py index 5fb3edb8a..ea852eea9 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -324,14 +324,14 @@ def find_folder( filename): # not found return '' -def get_unicode_path(path): +def get_unicode_path_from_file_chooser(path): """ Return the Unicode version of a path string. :type path: str :param path: The path to be converted to Unicode :rtype: unicode - :returns: The Unicode version of path. + :returns: The Unicode version of path. """ # Don't make unicode of unicode if isinstance(path, unicode): @@ -351,6 +351,34 @@ def get_unicode_path(path): LOG.warn("Problem encountered converting string: %s." % path) return unicode(path, sys.getfilesystemencoding(), errors='replace') +def get_unicode_path_from_env_var(path): + """ + Return the Unicode version of a path string. + + :type path: str + :param path: The path to be converted to Unicode + :rtype: unicode + :returns: The Unicode version of path. + """ + if isinstance(path, unicode): + return path + + if constfunc.win(): + # In Windows path/filename returned from a emvironment variable is in filesystemencoding + try: + new_path = unicode(path, sys.getfilesystemencoding()) + return new_path + except: + LOG.warn("Problem encountered converting string: %s." % path) + return unicode(path, sys.getfilesystemencoding(), errors='replace') + else: + try: + return unicode(path) + except: + LOG.warn("Problem encountered converting string: %s." % path) + return unicode(path, sys.getfilesystemencoding(), errors='replace') + + #------------------------------------------------------------------------- # # Iterate over ancestors. @@ -943,6 +971,7 @@ def get_empty_tempdir(dirname): if os.path.isdir(dirpath): shutil.rmtree(dirpath) os.makedirs(dirpath) + dirpath = get_unicode_path_from_env_var(dirpath) return dirpath def rm_tempdir(path): diff --git a/src/cli/clidbman.py b/src/cli/clidbman.py index b8fb959f7..64125dcf6 100644 --- a/src/cli/clidbman.py +++ b/src/cli/clidbman.py @@ -168,6 +168,7 @@ class CLIDbManager(object): """ # make the default directory if it does not exist dbdir = os.path.expanduser(config.get('behavior.database-path')) + dbdir = dbdir.encode(sys.getfilesystemencoding()) make_dbdir(dbdir) self.current_names = [] @@ -355,6 +356,7 @@ def find_next_db_dir(): while True: base = "%x" % int(time.time()) dbdir = os.path.expanduser(config.get('behavior.database-path')) + dbdir = dbdir.encode(sys.getfilesystemencoding()) new_path = os.path.join(dbdir, base) if not os.path.isdir(new_path): break diff --git a/src/const.py.in b/src/const.py.in index a702862df..1336fdd1a 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -117,10 +117,7 @@ else: # Conversion of USER_HOME to unicode was needed to have better # support for non ASCII path names in Windows for the Gramps database. USER_HOME = unicode(USER_HOME, sys.getfilesystemencoding()) - -# Tried also coversion of HOME_DIR, but that caused a lot of problems -# in Windows. Leave it unconverted for now. -#HOME_DIR = unicode(HOME_DIR, sys.getfilesystemencoding()) +HOME_DIR = unicode(HOME_DIR, sys.getfilesystemencoding()) #------------------------------------------------------------------------- # diff --git a/src/gen/plug/_pluginreg.py b/src/gen/plug/_pluginreg.py index 31487ac15..333685088 100644 --- a/src/gen/plug/_pluginreg.py +++ b/src/gen/plug/_pluginreg.py @@ -955,8 +955,6 @@ class PluginRegister(object): lenpd = len(self.__plugindata) full_filename = os.path.join(dir, filename) local_gettext = get_addon_translator(full_filename).gettext - if type(full_filename) == str: - full_filename = unicode(full_filename, sys.getfilesystemencoding()) try: #execfile(full_filename, execfile(full_filename.encode(sys.getfilesystemencoding()), diff --git a/src/gui/configure.py b/src/gui/configure.py index d4d4ad54d..902318c7c 100644 --- a/src/gui/configure.py +++ b/src/gui/configure.py @@ -1012,7 +1012,7 @@ class GrampsPreferences(ConfigureDialog): status = f.run() if status == gtk.RESPONSE_OK: - val = Utils.get_unicode_path(f.get_filename()) + val = Utils.get_unicode_path_from_file_chooser(f.get_filename()) if val: self.path_entry.set_text(val) f.destroy() diff --git a/src/gui/dbloader.py b/src/gui/dbloader.py index b79c20f46..572dc5ffb 100644 --- a/src/gui/dbloader.py +++ b/src/gui/dbloader.py @@ -86,8 +86,15 @@ class DbLoader(CLIDbLoader): return 1 def _dberrordialog(self, msg): - DBErrorDialog(str(msg.value)) - + import traceback + exc = traceback.format_exc() + try: + DBErrorDialog(str(msg.value)) + _LOG.error(str(msg.value)) + except: + DBErrorDialog(str(msg)) + _LOG.error(str(msg) +"\n" + exc) + def _begin_progress(self): self.uistate.set_busy_cursor(1) self.uistate.progress.show() @@ -154,7 +161,7 @@ class DbLoader(CLIDbLoader): if response == gtk.RESPONSE_CANCEL: break elif response == gtk.RESPONSE_OK: - filename = Utils.get_unicode_path(import_dialog.get_filename()) + filename = Utils.get_unicode_path_from_file_chooser(import_dialog.get_filename()) if self.check_errors(filename): # displays errors if any continue @@ -312,11 +319,12 @@ class DbLoader(CLIDbLoader): except Errors.DbError, msg: self.dbstate.no_database() self._dberrordialog(msg) - except Exception: + except Exception as newerror: self.dbstate.no_database() + self._dberrordialog(str(newerror)) self._end_progress() return True - + #------------------------------------------------------------------------- # # default dir selection diff --git a/src/gui/dbman.py b/src/gui/dbman.py index bc1ec6cbc..49202b2eb 100644 --- a/src/gui/dbman.py +++ b/src/gui/dbman.py @@ -77,6 +77,7 @@ import RecentFiles from glade import Glade from gen.db.backup import restore from gen.db.exceptions import DbException +from Utils import get_unicode_path_from_env_var _RETURN = gtk.gdk.keyval_from_name("Return") @@ -233,7 +234,7 @@ class DbManager(CLIDbManager): self.rcs.set_sensitive(False) if store.get_value(node, STOCK_COL) == gtk.STOCK_DIALOG_ERROR: - path = store.get_value(node, PATH_COL) + path = get_unicode_path_from_env_var(store.get_value(node, PATH_COL)) backup = os.path.join(path, "person.gbkp") self.repair.set_sensitive(os.path.isfile(backup)) else: @@ -346,8 +347,8 @@ class DbManager(CLIDbManager): self.top.destroy() del self.selection del self.name_renderer - return (store.get_value(node, PATH_COL), - store.get_value(node, NAME_COL)) + path = get_unicode_path_from_env_var(store.get_value(node, PATH_COL)) + return (path, store.get_value(node, NAME_COL)) else: self.top.destroy() del self.selection @@ -381,7 +382,7 @@ class DbManager(CLIDbManager): try: self.break_lock(self.lock_file) store, node = self.selection.get_selected() - dbpath = store.get_value(node, PATH_COL) + dbpath = get_unicode_path_from_env_var(store.get_value(node, PATH_COL)) (tval, last) = time_val(dbpath) store.set_value(node, OPEN_COL, 0) store.set_value(node, STOCK_COL, "") @@ -510,12 +511,12 @@ class DbManager(CLIDbManager): imports it into the db """ new_path, newname = self._create_new_db("%s : %s" % (parent_name, name)) - + self.__start_cursor(_("Extracting archive...")) dbclass = DbBsddb dbase = dbclass() dbase.load(new_path, None) - + self.__start_cursor(_("Importing archive...")) check_out(dbase, revision, db_path, None) self.__end_cursor() @@ -787,7 +788,7 @@ def check_out(dbase, rev, path, callback): Checks out the revision from rcs, and loads the resulting XML file into the database. """ - co_cmd = [ "co", "-x,v", "-q%s" % rev] + [ os.path.join(path, ARCHIVE), + co_cmd = [ "co", "-x,v", "-q%s" % rev] + [ os.path.join(path, ARCHIVE), os.path.join(path, ARCHIVE_V)] proc = subprocess.Popen(co_cmd, stderr = subprocess.PIPE) diff --git a/src/gui/editors/addmedia.py b/src/gui/editors/addmedia.py index 95f77ca70..92d9ddf34 100644 --- a/src/gui/editors/addmedia.py +++ b/src/gui/editors/addmedia.py @@ -149,7 +149,7 @@ class AddMediaObject(ManagedWindow.ManagedWindow): ErrorDialog(msgstr, msgstr2) return - filename = Utils.get_unicode_path(self.file_text.get_filename()) + filename = Utils.get_unicode_path_from_file_chooser(self.file_text.get_filename()) full_file = filename if self.relpath.get_active(): @@ -186,7 +186,7 @@ class AddMediaObject(ManagedWindow.ManagedWindow): fname = self.file_text.get_filename() if not fname: return - filename = Utils.get_unicode_path(fname) + filename = Utils.get_unicode_path_from_file_chooser(fname) basename = os.path.basename(filename) (root, ext) = os.path.splitext(basename) old_title = unicode(self.description.get_text()) diff --git a/src/gui/editors/editmedia.py b/src/gui/editors/editmedia.py index 1ffaa50e2..5667bb131 100644 --- a/src/gui/editors/editmedia.py +++ b/src/gui/editors/editmedia.py @@ -231,7 +231,7 @@ class EditMedia(EditPrimary): def select_file(self, val): self.determine_mime() path = self.file_path.get_text() - self.obj.set_path(Utils.get_unicode_path(path)) + self.obj.set_path(Utils.get_unicode_path_from_file_chooser(path)) AddMediaObject(self.dbstate, self.uistate, self.track, self.obj, self._update_addmedia) @@ -275,7 +275,7 @@ class EditMedia(EditPrimary): path = self.file_path.get_text() self.determine_mime() - self.obj.set_path(Utils.get_unicode_path(path)) + self.obj.set_path(Utils.get_unicode_path_from_file_chooser(path)) trans = self.db.transaction_begin() if not self.obj.get_handle(): diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index e7d8c1625..eb6e61c72 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -35,6 +35,7 @@ import os from gen.ggettext import gettext as _ from cStringIO import StringIO from collections import defaultdict +import sys #------------------------------------------------------------------------- # @@ -1221,6 +1222,7 @@ class ViewManager(CLIManager): value = dialog.run() if value: (filename, title) = value + filename = filename.encode(sys.getfilesystemencoding()) self.db_loader.read_file(filename) self._post_load_newdb(filename, 'x-directory/normal', title) diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index e27c083e3..17ccf85dc 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -909,6 +909,7 @@ class ListView(NavigationView): while True: value = chooser.run() fn = chooser.get_filename() + fn = Utils.get_unicode_path_from_file_chooser(fn) fl = combobox.get_active() if value == gtk.RESPONSE_OK: if fn: diff --git a/src/plugins/docgen/PdfDoc.py b/src/plugins/docgen/PdfDoc.py index e656f4eb7..7e63d4801 100644 --- a/src/plugins/docgen/PdfDoc.py +++ b/src/plugins/docgen/PdfDoc.py @@ -30,6 +30,7 @@ # #------------------------------------------------------------------------ from gen.ggettext import gettext as _ +import sys #------------------------------------------------------------------------ # @@ -85,7 +86,8 @@ class PdfDoc(libcairodoc.CairoDoc): top_margin = self.paper.get_top_margin() * DPI / 2.54 # create cairo context and pango layout - surface = cairo.PDFSurface(self._backend.filename, paper_width, paper_height) + filename = self._backend.filename.encode(sys.getfilesystemencoding()) + surface = cairo.PDFSurface(filename, paper_width, paper_height) surface.set_fallback_resolution(300, 300) cr = pangocairo.CairoContext(cairo.Context(surface)) diff --git a/src/plugins/export/ExportPkg.py b/src/plugins/export/ExportPkg.py index ea3b40d82..d6b877abe 100644 --- a/src/plugins/export/ExportPkg.py +++ b/src/plugins/export/ExportPkg.py @@ -177,8 +177,7 @@ class PackageWriter(object): pass def fs_ok_clicked(obj): - name = unicode(fs_top.get_filename(), - sys.getfilesystemencoding()) + name = Utils.get_unicode_path_from_file_chooser(fs_top.get_filename()) if os.path.isfile(name): archive.add(name) diff --git a/src/plugins/tool/Check.py b/src/plugins/tool/Check.py index cc2c3ed82..997a9e02f 100644 --- a/src/plugins/tool/Check.py +++ b/src/plugins/tool/Check.py @@ -525,7 +525,7 @@ class CheckIntegrity(object): self.bad_photo.append(ObjectId) def fs_ok_clicked(obj): - name = Utils.get_unicode_path(fs_top.get_filename()) + name = Utils.get_unicode_path_from_file_chooser(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 a8194a724..f34726ac3 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -395,7 +395,7 @@ class DisplayChart(ManagedWindow.ManagedWindow): f.hide() if status == gtk.RESPONSE_OK: - name = Utils.get_unicode_path(f.get_filename()) + name = Utils.get_unicode_path_from_file_chooser(f.get_filename()) doc = ODSTab(len(self.row_data)) doc.creator(self.db.get_researcher().get_name()) diff --git a/src/plugins/view/geoview.py b/src/plugins/view/geoview.py index 5689fc7c9..93c78dc8f 100644 --- a/src/plugins/view/geoview.py +++ b/src/plugins/view/geoview.py @@ -106,7 +106,7 @@ from htmlrenderer import HtmlView # #------------------------------------------------------------------------- #covert to unicode for better hadnling of path in Windows -GEOVIEW_SUBPATH = Utils.get_unicode_path(Utils.get_empty_tempdir('geoview')) +GEOVIEW_SUBPATH = Utils.get_empty_tempdir('geoview') NB_MARKERS_PER_PAGE = 200 #------------------------------------------------------------------------- diff --git a/src/plugins/view/pedigreeview.py b/src/plugins/view/pedigreeview.py index 114666c07..7ae875fe8 100644 --- a/src/plugins/view/pedigreeview.py +++ b/src/plugins/view/pedigreeview.py @@ -31,6 +31,7 @@ from gen.ggettext import sgettext as _ from gen.ggettext import ngettext from cgi import escape import math +import sys #------------------------------------------------------------------------- # @@ -169,8 +170,11 @@ class PersonBoxWidget_cairo( gtk.DrawingArea, _PersonWidget_base): self.bgcolor = (211/256.0, 215/256.0, 207/256.0) self.bordercolor = (0,0,0) self.image = image + image1 = image + if isinstance(image1, unicode): + image1 = image.encode(sys.getfilesystemencoding()) try: - self.img_surf = cairo.ImageSurface.create_from_png(image) + self.img_surf = cairo.ImageSurface.create_from_png(image1) except: self.image = False self.connect("enter-notify-event", self.on_enter_cb) # enable mouse-over