From d6f3dfb5dd301fd7b1aba49f2a28deebf5a03b2a Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 15 Jun 2012 19:52:33 +0000 Subject: [PATCH] Changes for Gramps-Connect to work on Windows without using gramps.py svn: r19846 --- src/const.py.in | 3 +++ src/gen/datehandler/_grampslocale.py | 5 +++-- src/webapp/utils.py | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/const.py.in b/src/const.py.in index 42d127312..438475b63 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -85,6 +85,9 @@ if sys.platform == "win32": if sys.prefix == os.path.dirname(os.getcwd()): PREFIXDIR = sys.prefix SYSCONFDIR = os.path.join(sys.prefix, "etc") + else: + PREFIXDIR = os.path.dirname(__file__) + SYSCONFDIR = os.path.join(PREFIXDIR, "etc") elif sys.platform == "darwin" and sys.prefix != sys.exec_prefix: PREFIXDIR = sys.prefix SYSCONFDIR = os.path.join(sys.prefix, "etc") diff --git a/src/gen/datehandler/_grampslocale.py b/src/gen/datehandler/_grampslocale.py index fd54ed718..36a9ca24d 100644 --- a/src/gen/datehandler/_grampslocale.py +++ b/src/gen/datehandler/_grampslocale.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2004-2005 Donald N. Allingham +# Copyright (C) 2012 Doug Blank # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -131,10 +132,10 @@ try: except: import time - + codeset = None if win() or mac(): codeset = locale.getlocale()[1] - else: + if codeset is None: codeset = locale.getpreferredencoding() month_to_int = { diff --git a/src/webapp/utils.py b/src/webapp/utils.py index 6b4319c28..5a09c1521 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -144,7 +144,10 @@ def probably_alive(handle): def format_number(number, with_grouping=True): # FIXME: should be user's setting - locale.setlocale(locale.LC_ALL, "en_US.utf8") + try: + locale.setlocale(locale.LC_ALL, "en_US.utf8") + except: + pass if number != "": return locale.format("%d", number, with_grouping) else: @@ -152,7 +155,10 @@ def format_number(number, with_grouping=True): def table_count(table, with_grouping=True): # FIXME: should be user's setting - locale.setlocale(locale.LC_ALL, "en_US.utf8") + try: + locale.setlocale(locale.LC_ALL, "en_US.utf8") + except: + pass if table == "person": number = models.Person.objects.count() elif table == "family":