From 3d3eda02a54d0111eeb525701188c04d9d052c26 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sun, 20 Aug 2006 21:52:49 +0000 Subject: [PATCH] * src/Config/_GrampsIniKeys.py: Report error on invalid filename * src/const.py.in: detect windows home directory before others svn: r7216 --- ChangeLog | 4 ++++ src/Config/_GrampsIniKeys.py | 10 ++++++++++ src/const.py.in | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fc638991..fa7b80fd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-08-20 Brian Matherly + * src/Config/_GrampsIniKeys.py: Report error on invalid filename + * src/const.py.in: detect windows home directory before others + 2006-08-19 Alex Roitman * src/plugins/MediaManager.py (Convert2Rel._run): Correct logic. diff --git a/src/Config/_GrampsIniKeys.py b/src/Config/_GrampsIniKeys.py index cefcf1f90..a8e6c64cc 100644 --- a/src/Config/_GrampsIniKeys.py +++ b/src/Config/_GrampsIniKeys.py @@ -29,6 +29,7 @@ import time import ConfigParser import errno import const +from QuestionDialog import ErrorDialog from _GrampsConfigKeys import * NL = "\n" # FIX: newlines on Mac/Windows, if different? @@ -50,6 +51,15 @@ class IniKeyClient: self.filename = filename if self.filename and os.path.exists(filename): self.data = self.load_ini(self.filename) + elif self.filename and not os.path.exists(filename): + try: + head, tail = os.path.split( filename ) + os.makedirs( head ) + except OSError, e: + ErrorDialog(_("Unable to load preferences from %s") % + self.filename, + _("Preferences will not be loaded or saved.")) + self.filename = None def notify_add(self, path, func): """ diff --git a/src/const.py.in b/src/const.py.in index 694e0233e..831e45d02 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -78,12 +78,12 @@ no_gconf = False # Windows apparently uses USERPROFILE # #------------------------------------------------------------------------- -if os.environ.has_key('HOME'): - user_home = os.environ['HOME'] - home_dir = os.path.join(user_home,'.gramps') -else: +if os.environ.has_key('USERPROFILE'): user_home = os.environ['USERPROFILE'] home_dir = os.path.join(user_home,'gramps') +else: + user_home = os.environ['HOME'] + home_dir = os.path.join(user_home,'.gramps') #------------------------------------------------------------------------- #