From d319c2fa75a639cef3eab2ec6cd54b08dad258f2 Mon Sep 17 00:00:00 2001 From: Robert M Ochshorn Date: Fri, 27 May 2016 12:24:39 +0200 Subject: [PATCH] fallback on .gentle for get_resourcepath --- gentle/paths.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gentle/paths.py b/gentle/paths.py index 2fe37e71..f48b78d3 100644 --- a/gentle/paths.py +++ b/gentle/paths.py @@ -11,19 +11,22 @@ def get_binary(name): elif os.path.exists(name): binpath = "./%s" % (name) - logging.info("binpath %s", binpath) + logging.debug("binpath %s", binpath) return binpath def get_resource(path): rpath = path if hasattr(sys, "frozen"): rpath = os.path.abspath(os.path.join(sys._MEIPASS, '..', 'Resources', path)) - logging.info("resourcepath %s", rpath) + if not os.path.exists(rpath): + # DMG may be read-only; fall-back to datadir (ie. so language models can be added) + rpath = get_datadir(path) + logging.debug("resourcepath %s", rpath) return rpath def get_datadir(path): datadir = path if hasattr(sys, "frozen"):# and sys.frozen == "macosx_app": datadir = os.path.join(os.environ['HOME'], '.gentle', path) - logging.info("datadir %s", datadir) + logging.debug("datadir %s", datadir) return datadir