Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __check_bdb_version(self, name, force_bsddb_upgrade=False,
force_bsddb_downgrade=False):
"""Older version of Berkeley DB can't read data created by a newer
version."""
bdb_version = db.version()
versionpath = os.path.join(self.path, str(BDBVERSFN))
# Compare the current version of the database (bsddb_version) with the
# version of the database code (env_version). If it is a downgrade,
# raise an exception because we can't do anything. If they are the same,
# return. If it is an upgrade, raise an exception unless the user has
# already told us we can upgrade.
if os.path.isfile(versionpath):
with open(versionpath, "r") as version_file:
bsddb_version = version_file.read().strip()
env_version = tuple(map(int, bsddb_version[1:-1].split(', ')))
else:
# bsddb version is unknown
bsddb_version = "Unknown"
env_version = "Unknown"
# _LOG.debug("db version %s, program version %s" % (bsddb_version, bdb_version))
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'
try:
import bsddb3 as bsddb
bsddb_str = bsddb.__version__
bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
.replace('(', '').replace(')', '')
bsddb_location_str = bsddb.__file__
except:
bsddb_str = 'not found'
bsddb_db_str = 'not found'
bsddb_location_str = 'not found'
try:
import sqlite3
sqlite3_py_version_str = sqlite3.version
sqlite3_version_str = sqlite3.sqlite_version
sqlite3_location_str = sqlite3.__file__
except:
sqlite3_version_str = 'not found'
sqlite3_py_version_str = 'not found'
sqlite3_location_str = 'not found'
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.constfunc import get_env_var
from .display import display_url
def ellipses(text):
"""
Ellipsize text on length 40
"""
if len(text) > 40:
return text[:40] + "..."
return text
try:
import bsddb3 as bsddb ## ok, in try/except
BSDDB_STR = ellipses(str(bsddb.__version__) + " " + str(bsddb.db.version()))
except:
BSDDB_STR = 'not found'
try:
import sqlite3
sqlite3_py_version_str = sqlite3.version
sqlite3_version_str = sqlite3.sqlite_version
except:
sqlite3_py_version_str = 'not found'
sqlite3_version_str = 'not found'
#-------------------------------------------------------------------------
#
# GrampsAboutDialog
#
#-------------------------------------------------------------------------
pyexiv2_str = '%d.%d.%d' % pyexiv2.version_info
except :# any failure to 'get' the version
pyexiv2_str = 'unknown version'
except ImportError:
pyexiv2_str = 'not found'
from gen.config import config
usebsddb3 = config.get('preferences.use-bsddb3')
try:
if usebsddb3:
import bsddb3 as bsddb
else:
import bsddb
bsddb_str = bsddb.__version__
bsddb_db_str = str(bsddb.db.version())
except:
bsddb_str = 'not found'
bsddb_db_str = 'not found'
try:
from gen.const import VERSION
gramps_str = VERSION
except:
gramps_str = 'not found'
if hasattr(os, "uname"):
kernel = os.uname()[2]
else:
kernel = None
lang_str = os.environ.get('LANG','not set')
#
# Python modules
#
#-------------------------------------------------------------------------
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import GObject
import cairo
import sys, os
import platform
try:
import bsddb3 as bsddb # ok, in try/except
BSDDB_STR = str(bsddb.__version__) + " " + str(bsddb.db.version())
except:
BSDDB_STR = 'not found'
try:
import sqlite3
sqlite3_py_version_str = sqlite3.version
sqlite3_version_str = sqlite3.sqlite_version
except:
sqlite3_version_str = 'not found'
sqlite3_py_version_str = 'not found'
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------