From 3f9299a9d1ce41c369ee2ba1597f35562c4280e4 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 27 Mar 2014 11:34:49 -0700 Subject: [PATCH] Use gramps.gen.const.HOME_DIR instead of os.environ['HOME'] $HOME doesn't exist on Windows, so os.environ['HOME'] gives the wrong answer. (cherry picked from commit 53c878aa085d7de87857d4d61d59994d50ad6ebd) --- gramps/gen/db/write.py | 8 ++++---- gramps/gui/configure.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index 157be961b..9e5793f0a 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -32,7 +32,7 @@ This is used since GRAMPS version 3.0 # Standard python modules # #------------------------------------------------------------------------- -from __future__ import print_function, with_statement +from __future__ import print_function, with_statement, unicode_literals import sys if sys.version_info[0] < 3: import cPickle as pickle @@ -81,7 +81,7 @@ from ..updatecallback import UpdateCallback from ..errors import DbError from ..constfunc import (win, conv_to_unicode, cuni, UNITYPE, handle2internal, get_env_var) -from ..const import GRAMPS_LOCALE as glocale +from ..const import HOME_DIR, GRAMPS_LOCALE as glocale _ = glocale.translation.gettext _LOG = logging.getLogger(DBLOGNAME) @@ -2276,7 +2276,7 @@ def write_lock_file(name): try: user = os.getlogin() except: - user = get_env_var('USER') + user = os.environ['USER'] #not win, don't need get_env_var if host: text = "%s@%s" % (user, host) else: @@ -2302,7 +2302,7 @@ if __name__ == "__main__": if len(sys.argv) > 1: db_name = sys.argv[1] else: - db_home = os.path.join(os.environ['HOME'], '.gramps','grampsdb') + db_home = os.path.join(HOME_DIR,'grampsdb') for dir in os.listdir(db_home): db_path = os.path.join(db_home, dir) db_fn = os.path.join(db_path, 'name.txt') diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index fed0a0087..a52e45a89 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -1407,7 +1407,7 @@ class GrampsPreferences(ConfigureDialog): Gtk.ResponseType.OK)) dbpath = config.get('behavior.database-path') if not dbpath: - dbpath = os.path.join(os.environ['HOME'], '.gramps','grampsdb') + dbpath = os.path.join(HOME_DIR,'grampsdb') f.set_current_folder(os.path.dirname(dbpath)) status = f.run()