2003-05-17 09:44:13 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-08-28 02:34:49 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2010-04-04 04:14:41 +05:30
|
|
|
# Copyright (C) 2009 Benny Malengier
|
|
|
|
# Copyright (C) 2009-2010 Stephen George
|
|
|
|
# Copyright (C) 2010 Doug Blank <doug.blank@gmail.com>
|
2011-10-13 23:47:08 +05:30
|
|
|
# Copyright (C) 2011 Paul Franklin
|
2003-05-17 09:44:13 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2014-08-09 07:59:07 +05:30
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-05-17 09:44:13 +05:30
|
|
|
#
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-11-02 05:53:35 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-02-13 10:45:39 +05:30
|
|
|
import sys
|
|
|
|
import os
|
2003-06-10 22:40:44 +05:30
|
|
|
import signal
|
2013-01-18 01:12:11 +05:30
|
|
|
|
2006-01-06 20:53:28 +05:30
|
|
|
import logging
|
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
LOG = logging.getLogger(".")
|
2003-02-13 10:45:39 +05:30
|
|
|
|
2010-10-14 18:23:01 +05:30
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
2003-11-02 05:53:35 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2015-02-28 23:27:00 +05:30
|
|
|
# Gramps modules
|
2003-11-02 05:53:35 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2013-03-12 04:14:15 +05:30
|
|
|
from .gen.const import APP_GRAMPS, USER_DIRLIST, HOME_DIR
|
|
|
|
from .version import VERSION_TUPLE
|
2014-03-12 04:22:59 +05:30
|
|
|
from .gen.constfunc import win, get_env_var
|
2013-01-18 01:12:11 +05:30
|
|
|
|
2012-07-17 04:25:36 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Setup logging
|
|
|
|
#
|
2013-04-21 04:38:53 +05:30
|
|
|
# Ideally, this needs to be done before any Gramps modules are
|
|
|
|
# imported, so that any code that is executed as the modules are
|
|
|
|
# imported can log errors or warnings. const and constfunc have to be
|
|
|
|
# imported before this code is executed because they are used in this
|
|
|
|
# code. That unfortunately initializes GrampsLocale, so it has its own
|
|
|
|
# logging setup during initialization.
|
2012-07-17 04:25:36 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
"""Setup basic logging support."""
|
|
|
|
|
|
|
|
# Setup a formatter
|
2013-02-05 00:44:29 +05:30
|
|
|
form = logging.Formatter(fmt="%(asctime)s.%(msecs).03d: %(levelname)s: "
|
|
|
|
"%(filename)s: line %(lineno)d: %(message)s",
|
|
|
|
datefmt='%Y-%m-%d %H:%M:%S')
|
2012-07-17 04:25:36 +05:30
|
|
|
|
|
|
|
# Create the log handlers
|
|
|
|
if win():
|
|
|
|
# If running in GUI mode redirect stdout and stderr to log file
|
|
|
|
if hasattr(sys.stdout, "fileno") and sys.stdout.fileno() < 0:
|
2015-08-23 23:12:07 +05:30
|
|
|
logfile = os.path.join(HOME_DIR,
|
|
|
|
"Gramps%s%s.log") % (VERSION_TUPLE[0],
|
2012-07-17 04:25:36 +05:30
|
|
|
VERSION_TUPLE[1])
|
|
|
|
# We now carry out the first step in build_user_paths(), to make sure
|
|
|
|
# that the user home directory is available to store the log file. When
|
|
|
|
# build_user_paths() is called, the call is protected by a try...except
|
|
|
|
# block, and any failure will be logged. However, if the creation of the
|
|
|
|
# user directory fails here, there is no way to report the failure,
|
|
|
|
# because stdout/stderr are not available, and neither is the logfile.
|
|
|
|
if os.path.islink(HOME_DIR):
|
|
|
|
pass # ok
|
|
|
|
elif not os.path.isdir(HOME_DIR):
|
|
|
|
os.makedirs(HOME_DIR)
|
2014-01-22 00:07:28 +05:30
|
|
|
sys.stdout = sys.stderr = open(logfile, "w")
|
2012-07-17 04:25:36 +05:30
|
|
|
stderrh = logging.StreamHandler(sys.stderr)
|
|
|
|
stderrh.setFormatter(form)
|
|
|
|
stderrh.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
# Setup the base level logger, this one gets
|
|
|
|
# everything.
|
|
|
|
l = logging.getLogger()
|
|
|
|
l.setLevel(logging.WARNING)
|
|
|
|
l.addHandler(stderrh)
|
|
|
|
|
|
|
|
# put a hook on to catch any completely unhandled exceptions.
|
|
|
|
def exc_hook(type, value, tb):
|
|
|
|
if type == KeyboardInterrupt:
|
|
|
|
# Ctrl-C is not a bug.
|
|
|
|
return
|
|
|
|
if type == IOError:
|
|
|
|
# strange Windows logging error on close
|
|
|
|
return
|
2013-11-13 08:20:10 +05:30
|
|
|
#Use this to show variables in each frame:
|
|
|
|
#from gramps.gen.utils.debug import format_exception
|
|
|
|
import traceback
|
2012-07-17 04:25:36 +05:30
|
|
|
LOG.error("Unhandled exception\n" +
|
2013-11-13 08:20:10 +05:30
|
|
|
"".join(traceback.format_exception(type, value, tb)))
|
2012-07-17 04:25:36 +05:30
|
|
|
|
|
|
|
sys.excepthook = exc_hook
|
|
|
|
|
2012-11-07 23:23:14 +05:30
|
|
|
from .gen.mime import mime_type_is_defined
|
2013-01-18 01:12:11 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2013-01-18 01:12:11 +05:30
|
|
|
# Instantiate Localization
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-02-06 22:47:20 +05:30
|
|
|
|
2013-01-18 01:12:11 +05:30
|
|
|
from .gen.const import GRAMPS_LOCALE as glocale
|
2013-04-13 04:02:11 +05:30
|
|
|
_ = glocale.translation.gettext
|
2010-02-06 22:47:20 +05:30
|
|
|
|
2007-10-21 02:54:32 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Minimum version check
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2015-02-28 23:27:00 +05:30
|
|
|
MIN_PYTHON_VERSION = (3, 2, 0, '', 0)
|
2007-10-21 02:54:32 +05:30
|
|
|
if not sys.version_info >= MIN_PYTHON_VERSION :
|
2012-07-17 04:25:36 +05:30
|
|
|
logging.warning(_("Your Python version does not meet the "
|
2012-04-19 19:14:56 +05:30
|
|
|
"requirements. At least python %(v1)d.%(v2)d.%(v3)d is needed to"
|
2010-01-12 18:35:41 +05:30
|
|
|
" start Gramps.\n\n"
|
2012-04-19 19:14:56 +05:30
|
|
|
"Gramps will terminate now.") % {
|
2015-08-23 23:12:07 +05:30
|
|
|
'v1': MIN_PYTHON_VERSION[0],
|
2012-04-19 19:14:56 +05:30
|
|
|
'v2': MIN_PYTHON_VERSION[1],
|
|
|
|
'v3': MIN_PYTHON_VERSION[2]})
|
2007-10-21 02:54:32 +05:30
|
|
|
sys.exit(1)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2015-02-28 23:27:00 +05:30
|
|
|
# Gramps libraries
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-12 11:10:44 +05:30
|
|
|
try:
|
|
|
|
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
|
|
|
except:
|
|
|
|
pass
|
2003-06-10 22:40:44 +05:30
|
|
|
|
2004-06-21 10:40:27 +05:30
|
|
|
args = sys.argv
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def build_user_paths():
|
|
|
|
""" check/make user-dirs on each Gramps session"""
|
2012-06-27 23:00:30 +05:30
|
|
|
for path in USER_DIRLIST:
|
2010-01-24 20:54:36 +05:30
|
|
|
if os.path.islink(path):
|
|
|
|
pass # ok
|
|
|
|
elif not os.path.isdir(path):
|
2011-06-16 16:12:08 +05:30
|
|
|
os.makedirs(path)
|
2006-01-06 20:53:28 +05:30
|
|
|
|
2010-04-04 04:14:41 +05:30
|
|
|
def show_settings():
|
|
|
|
"""
|
|
|
|
Shows settings of all of the major components.
|
|
|
|
"""
|
|
|
|
py_str = '%d.%d.%d' % sys.version_info[:3]
|
|
|
|
try:
|
2012-06-18 02:55:37 +05:30
|
|
|
from gi.repository import Gtk
|
2010-04-04 04:14:41 +05:30
|
|
|
try:
|
2015-08-23 23:12:07 +05:30
|
|
|
gtkver_str = '%d.%d.%d' % (Gtk.get_major_version(),
|
2012-06-18 02:55:37 +05:30
|
|
|
Gtk.get_minor_version(), Gtk.get_micro_version())
|
2010-04-04 04:14:41 +05:30
|
|
|
except : # any failure to 'get' the version
|
|
|
|
gtkver_str = 'unknown version'
|
|
|
|
except ImportError:
|
|
|
|
gtkver_str = 'not found'
|
2011-08-19 07:27:43 +05:30
|
|
|
# no DISPLAY is a RuntimeError in an older pygtk (e.g. 2.17 in Fedora 14)
|
|
|
|
except RuntimeError:
|
|
|
|
gtkver_str = 'DISPLAY not set'
|
2010-04-04 04:14:41 +05:30
|
|
|
#exept TypeError: To handle back formatting on version split
|
|
|
|
|
|
|
|
try:
|
2012-06-18 02:55:37 +05:30
|
|
|
from gi.repository import GObject
|
2010-04-04 04:14:41 +05:30
|
|
|
try:
|
2013-01-11 20:21:28 +05:30
|
|
|
pygobjectver_str = '%d.%d.%d' % GObject.pygobject_version
|
2010-04-04 04:14:41 +05:30
|
|
|
except :# any failure to 'get' the version
|
2013-01-11 20:21:28 +05:30
|
|
|
pygobjectver_str = 'unknown version'
|
2010-04-04 04:14:41 +05:30
|
|
|
|
|
|
|
except ImportError:
|
2013-01-11 20:21:28 +05:30
|
|
|
pygobjectver_str = 'not found'
|
2010-04-04 04:14:41 +05:30
|
|
|
|
2012-12-30 20:44:58 +05:30
|
|
|
try:
|
|
|
|
from gi.repository import Pango
|
|
|
|
try:
|
|
|
|
pangover_str = Pango.version_string()
|
|
|
|
except :# any failure to 'get' the version
|
|
|
|
pangover_str = 'unknown version'
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
pangover_str = 'not found'
|
|
|
|
|
2010-04-04 04:14:41 +05:30
|
|
|
try:
|
|
|
|
import cairo
|
|
|
|
try:
|
2015-08-23 23:12:07 +05:30
|
|
|
pycairover_str = '%d.%d.%d' % cairo.version_info
|
2012-12-30 20:44:58 +05:30
|
|
|
cairover_str = cairo.cairo_version_string()
|
2010-04-04 04:14:41 +05:30
|
|
|
except :# any failure to 'get' the version
|
2012-12-30 20:44:58 +05:30
|
|
|
pycairover_str = 'unknown version'
|
2010-04-04 04:14:41 +05:30
|
|
|
cairover_str = 'unknown version'
|
|
|
|
|
|
|
|
except ImportError:
|
2012-12-30 20:44:58 +05:30
|
|
|
pycairover_str = 'not found'
|
2010-04-04 04:14:41 +05:30
|
|
|
cairover_str = 'not found'
|
|
|
|
|
2011-05-03 20:08:54 +05:30
|
|
|
try:
|
2012-09-02 14:38:31 +05:30
|
|
|
from gi import Repository
|
|
|
|
repository = Repository.get_default()
|
|
|
|
if repository.enumerate_versions("OsmGpsMap"):
|
|
|
|
from gi.repository import OsmGpsMap as osmgpsmap
|
|
|
|
try:
|
|
|
|
osmgpsmap_str = osmgpsmap._version
|
|
|
|
except :# any failure to 'get' the version
|
|
|
|
osmgpsmap_str = 'unknown version'
|
|
|
|
else:
|
|
|
|
osmgpsmap_str = 'not found'
|
2011-05-03 20:08:54 +05:30
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
osmgpsmap_str = 'not found'
|
|
|
|
|
2011-04-21 21:26:40 +05:30
|
|
|
try:
|
2013-02-27 02:06:52 +05:30
|
|
|
from gi import Repository
|
|
|
|
repository = Repository.get_default()
|
|
|
|
if repository.enumerate_versions("GExiv2"):
|
|
|
|
from gi.repository import GExiv2
|
|
|
|
try:
|
|
|
|
gexiv2_str = GExiv2._version
|
|
|
|
except: # any failure to 'get' the version
|
|
|
|
gexiv2_str = 'unknown version'
|
|
|
|
else:
|
|
|
|
gexiv2_str = 'not found'
|
|
|
|
|
2011-04-21 21:26:40 +05:30
|
|
|
except ImportError:
|
2013-02-24 05:06:12 +05:30
|
|
|
gexiv2_str = 'not found'
|
2011-04-21 21:26:40 +05:30
|
|
|
|
2013-03-03 08:49:56 +05:30
|
|
|
try:
|
|
|
|
import PyICU
|
|
|
|
try:
|
|
|
|
pyicu_str = PyICU.VERSION
|
|
|
|
icu_str = PyICU.ICU_VERSION
|
|
|
|
except: # any failure to 'get' the version
|
|
|
|
pyicu_str = 'unknown version'
|
|
|
|
icu_str = 'unknown version'
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
pyicu_str = 'not found'
|
|
|
|
icu_str = 'not found'
|
|
|
|
|
2010-04-04 04:14:41 +05:30
|
|
|
try:
|
2015-02-28 23:27:00 +05:30
|
|
|
import bsddb3 as bsddb
|
2010-04-04 04:14:41 +05:30
|
|
|
bsddb_str = bsddb.__version__
|
2012-12-30 20:44:58 +05:30
|
|
|
bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
|
|
|
|
.replace('(', '').replace(')', '')
|
2010-04-04 04:14:41 +05:30
|
|
|
except:
|
|
|
|
bsddb_str = 'not found'
|
2011-01-24 02:55:51 +05:30
|
|
|
bsddb_db_str = 'not found'
|
2010-04-04 04:14:41 +05:30
|
|
|
|
2015-08-23 23:12:07 +05:30
|
|
|
try:
|
2013-03-27 00:31:54 +05:30
|
|
|
from .gen.const import VERSION
|
2012-06-27 23:00:30 +05:30
|
|
|
gramps_str = VERSION
|
2010-04-04 04:14:41 +05:30
|
|
|
except:
|
|
|
|
gramps_str = 'not found'
|
|
|
|
|
|
|
|
if hasattr(os, "uname"):
|
|
|
|
kernel = os.uname()[2]
|
|
|
|
else:
|
|
|
|
kernel = None
|
|
|
|
|
2014-03-12 04:22:59 +05:30
|
|
|
lang_str = get_env_var('LANG','not set')
|
|
|
|
language_str = get_env_var('LANGUAGE','not set')
|
|
|
|
grampsi18n_str = get_env_var('GRAMPSI18N','not set')
|
|
|
|
grampshome_str = get_env_var('GRAMPSHOME','not set')
|
|
|
|
grampsdir_str = get_env_var('GRAMPSDIR','not set')
|
2010-04-04 04:14:41 +05:30
|
|
|
|
2010-10-14 18:23:01 +05:30
|
|
|
try:
|
|
|
|
dotversion_str = Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1]
|
2013-03-08 05:00:21 +05:30
|
|
|
if isinstance(dotversion_str, bytes) and sys.stdin.encoding:
|
2013-02-05 20:41:45 +05:30
|
|
|
dotversion_str = dotversion_str.decode(sys.stdin.encoding)
|
2010-10-14 18:23:01 +05:30
|
|
|
if dotversion_str:
|
2013-02-05 20:41:45 +05:30
|
|
|
dotversion_str = dotversion_str.replace('\n','')[23:27]
|
2010-10-14 18:23:01 +05:30
|
|
|
except:
|
|
|
|
dotversion_str = 'Graphviz not in system PATH'
|
|
|
|
|
|
|
|
try:
|
2012-06-10 02:26:43 +05:30
|
|
|
if win():
|
2010-10-14 18:23:01 +05:30
|
|
|
gsversion_str = Popen(['gswin32c', '--version'], stdout=PIPE).communicate(input=None)[0]
|
|
|
|
else:
|
|
|
|
gsversion_str = Popen(['gs', '--version'], stdout=PIPE).communicate(input=None)[0]
|
2013-03-08 05:00:21 +05:30
|
|
|
if isinstance(gsversion_str, bytes) and sys.stdin.encoding:
|
2013-02-05 20:41:45 +05:30
|
|
|
gsversion_str = gsversion_str.decode(sys.stdin.encoding)
|
2010-10-14 18:23:01 +05:30
|
|
|
if gsversion_str:
|
|
|
|
gsversion_str = gsversion_str.replace('\n', '')
|
|
|
|
except:
|
2011-10-10 22:00:22 +05:30
|
|
|
gsversion_str = 'Ghostscript not in system PATH'
|
2010-10-14 18:23:01 +05:30
|
|
|
|
2014-03-12 04:22:59 +05:30
|
|
|
os_path = get_env_var('PATH','not set')
|
2010-11-20 20:17:36 +05:30
|
|
|
os_path = os_path.split(os.pathsep)
|
2015-08-23 23:12:07 +05:30
|
|
|
|
2012-11-07 23:23:14 +05:30
|
|
|
print ("Gramps Settings:")
|
|
|
|
print ("----------------")
|
|
|
|
print (' python : %s' % py_str)
|
|
|
|
print (' gramps : %s' % gramps_str)
|
|
|
|
print (' gtk++ : %s' % gtkver_str)
|
2013-01-11 20:21:28 +05:30
|
|
|
print (' pygobject : %s' % pygobjectver_str)
|
2012-12-30 20:44:58 +05:30
|
|
|
print (' pango : %s' % pangover_str)
|
2012-11-07 23:23:14 +05:30
|
|
|
print (' bsddb : %s' % bsddb_str)
|
|
|
|
print (' bsddb.db : %s' % bsddb_db_str)
|
|
|
|
print (' cairo : %s' % cairover_str)
|
2012-12-30 20:44:58 +05:30
|
|
|
print (' pycairo : %s' % pycairover_str)
|
2012-11-07 23:23:14 +05:30
|
|
|
print (' osmgpsmap : %s' % osmgpsmap_str)
|
2013-02-24 05:06:12 +05:30
|
|
|
print (' GExiv2 : %s' % gexiv2_str)
|
2013-03-03 08:49:56 +05:30
|
|
|
print (' ICU : %s' % icu_str)
|
|
|
|
print (' PyICU : %s' % pyicu_str)
|
2013-01-23 00:51:04 +05:30
|
|
|
print (' o.s. : %s' % sys.platform)
|
2010-04-04 04:14:41 +05:30
|
|
|
if kernel:
|
2012-11-07 23:23:14 +05:30
|
|
|
print (' kernel : %s' % kernel)
|
|
|
|
print ('')
|
|
|
|
print ("Environment settings:")
|
|
|
|
print ("---------------------")
|
|
|
|
print (' LANG : %s' % lang_str)
|
|
|
|
print (' LANGUAGE : %s' % language_str)
|
|
|
|
print (' GRAMPSI18N: %s' % grampsi18n_str)
|
|
|
|
print (' GRAMPSHOME: %s' % grampshome_str)
|
|
|
|
print (' GRAMPSDIR : %s' % grampsdir_str)
|
|
|
|
print (' PYTHONPATH:')
|
2010-04-04 04:14:41 +05:30
|
|
|
for folder in sys.path:
|
2012-11-07 23:23:14 +05:30
|
|
|
print (" ", folder)
|
|
|
|
print ('')
|
|
|
|
print ("Non-python dependencies:")
|
|
|
|
print ("------------------------")
|
|
|
|
print (' Graphviz : %s' % dotversion_str)
|
|
|
|
print (' Ghostscr. : %s' % gsversion_str)
|
|
|
|
print ('')
|
|
|
|
print ("System PATH env variable:")
|
|
|
|
print ("-------------------------")
|
2010-11-20 20:17:36 +05:30
|
|
|
for folder in os_path:
|
2012-11-07 23:23:14 +05:30
|
|
|
print (" ", folder)
|
|
|
|
print ('')
|
2010-04-04 04:14:41 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def run():
|
|
|
|
error = []
|
2015-08-23 23:12:07 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
try:
|
2015-08-23 23:12:07 +05:30
|
|
|
build_user_paths()
|
2012-11-07 23:23:14 +05:30
|
|
|
except OSError as msg:
|
2011-11-24 01:49:19 +05:30
|
|
|
error += [(_("Configuration error:"), str(msg))]
|
2010-01-12 18:35:41 +05:30
|
|
|
return error
|
|
|
|
except msg:
|
2009-06-19 03:26:37 +05:30
|
|
|
LOG.error("Error reading configuration.", exc_info=True)
|
2010-01-12 18:35:41 +05:30
|
|
|
return [(_("Error reading configuration"), str(msg))]
|
2015-08-23 23:12:07 +05:30
|
|
|
|
2012-06-27 23:00:30 +05:30
|
|
|
if not mime_type_is_defined(APP_GRAMPS):
|
2015-08-23 23:12:07 +05:30
|
|
|
error += [(_("Configuration error:"),
|
2009-06-19 03:26:37 +05:30
|
|
|
_("A definition for the MIME-type %s could not "
|
2009-11-18 01:44:53 +05:30
|
|
|
"be found \n\n Possibly the installation of Gramps "
|
2009-06-19 03:26:37 +05:30
|
|
|
"was incomplete. Make sure the MIME-types "
|
2009-11-18 01:44:53 +05:30
|
|
|
"of Gramps are properly installed.")
|
2012-06-27 23:00:30 +05:30
|
|
|
% APP_GRAMPS)]
|
2015-08-23 23:12:07 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
#we start with parsing the arguments to determine if we have a cli or a
|
|
|
|
# gui session
|
2010-04-04 04:14:41 +05:30
|
|
|
|
2010-08-26 17:47:00 +05:30
|
|
|
if "-v" in sys.argv or "--version" in sys.argv:
|
2010-04-04 04:14:41 +05:30
|
|
|
show_settings()
|
|
|
|
return error
|
|
|
|
|
2012-11-07 23:23:14 +05:30
|
|
|
from .cli.argparser import ArgParser
|
2011-08-19 07:27:43 +05:30
|
|
|
argv_copy = sys.argv[:]
|
|
|
|
argpars = ArgParser(argv_copy)
|
2011-09-03 21:14:06 +05:30
|
|
|
|
2015-08-23 23:12:07 +05:30
|
|
|
# Calls to LOG must be after setup_logging() and ArgParser()
|
2011-09-03 21:14:06 +05:30
|
|
|
LOG = logging.getLogger(".locale")
|
2013-04-21 04:38:53 +05:30
|
|
|
LOG.debug("Encoding: %s", glocale.encoding)
|
|
|
|
LOG.debug("Translating Gramps to %s", glocale.language[0])
|
|
|
|
LOG.debug("Collation Locale: %s", glocale.collation)
|
|
|
|
LOG.debug("Date/Time Locale: %s", glocale.calendar)
|
|
|
|
LOG.debug("Currency Locale: %s", glocale.currency)
|
|
|
|
LOG.debug("Number-format Locale: %s", glocale.numeric)
|
|
|
|
|
2011-10-11 01:05:04 +05:30
|
|
|
if 'LANG' in os.environ:
|
|
|
|
LOG.debug('Using LANG: %s' %
|
2014-03-12 04:22:59 +05:30
|
|
|
get_env_var('LANG'))
|
2011-10-11 01:05:04 +05:30
|
|
|
else:
|
|
|
|
LOG.debug('environment: LANG is not defined')
|
|
|
|
if 'LANGUAGE' in os.environ:
|
|
|
|
LOG.debug('Using LANGUAGE: %s' %
|
2014-03-12 04:22:59 +05:30
|
|
|
get_env_var('LANGUAGE'))
|
2011-10-11 01:05:04 +05:30
|
|
|
else:
|
|
|
|
LOG.debug('environment: LANGUAGE is not defined')
|
2015-08-23 23:12:07 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
if argpars.need_gui():
|
2013-08-22 01:16:16 +05:30
|
|
|
LOG.debug("A GUI is needed, set it up")
|
2011-01-24 02:55:51 +05:30
|
|
|
if "--qml" in sys.argv:
|
2012-11-07 23:23:14 +05:30
|
|
|
from .guiQML.grampsqml import startqml
|
2011-01-24 02:55:51 +05:30
|
|
|
startqml(error, argpars)
|
|
|
|
else:
|
2011-11-24 01:49:19 +05:30
|
|
|
try:
|
2012-11-07 23:23:14 +05:30
|
|
|
from .gui.grampsgui import startgtkloop
|
2011-11-24 01:49:19 +05:30
|
|
|
# no DISPLAY is a RuntimeError in an older pygtk (e.g. F14's 2.17)
|
2012-11-07 23:23:14 +05:30
|
|
|
except RuntimeError as msg:
|
2011-11-24 01:49:19 +05:30
|
|
|
error += [(_("Configuration error:"), str(msg))]
|
|
|
|
return error
|
2011-01-24 02:55:51 +05:30
|
|
|
startgtkloop(error, argpars)
|
2009-06-19 03:26:37 +05:30
|
|
|
else:
|
2015-02-28 23:27:00 +05:30
|
|
|
#CLI use of Gramps
|
2015-02-18 03:06:52 +05:30
|
|
|
|
|
|
|
#Ensure that output is encoded correctly to stdout and
|
|
|
|
#stderr. This is much less cumbersome and error-prone than
|
2015-02-28 23:27:00 +05:30
|
|
|
#encoding individual outputs:
|
2015-02-18 03:06:52 +05:30
|
|
|
try:
|
|
|
|
_encoding = sys.stdout.encoding or sys.getdefaultencoding()
|
|
|
|
except:
|
|
|
|
_encoding = "UTF-8"
|
2015-03-02 04:23:14 +05:30
|
|
|
import codecs
|
2015-02-28 23:27:00 +05:30
|
|
|
sys.stdout = codecs.getwriter(_encoding)(sys.stdout.detach(),
|
|
|
|
'backslashreplace')
|
|
|
|
sys.stderr = codecs.getwriter(_encoding)(sys.stderr.detach(),
|
|
|
|
'backslashreplace')
|
2009-06-19 03:26:37 +05:30
|
|
|
argpars.print_help()
|
2010-10-14 17:16:05 +05:30
|
|
|
argpars.print_usage()
|
2012-11-07 23:23:14 +05:30
|
|
|
from .cli.grampscli import startcli
|
2009-06-19 03:26:37 +05:30
|
|
|
startcli(error, argpars)
|
|
|
|
|
2012-09-30 16:00:08 +05:30
|
|
|
def main():
|
|
|
|
errors = run()
|
|
|
|
if errors and isinstance(errors, list):
|
|
|
|
for error in errors:
|
|
|
|
logging.warning(error[0] + error[1])
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-01-18 01:11:58 +05:30
|
|
|
main()
|