From 7719e995e07927d30c36341bacd0188987011486 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Thu, 10 Aug 2017 22:13:34 -0700 Subject: [PATCH] Gramps does not check [for] installed DB backend on DB selector Fixes #10148 --- gramps/plugins/db/dbapi/postgresql.gpr.py | 33 ++++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/gramps/plugins/db/dbapi/postgresql.gpr.py b/gramps/plugins/db/dbapi/postgresql.gpr.py index c881c0905..3bc2ad203 100644 --- a/gramps/plugins/db/dbapi/postgresql.gpr.py +++ b/gramps/plugins/db/dbapi/postgresql.gpr.py @@ -21,16 +21,23 @@ from gramps.gen.plug._pluginreg import register, STABLE, DATABASE from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext -register(DATABASE, - id='postgresql', - name=_('PostgreSQL'), - name_accell=_('_PostgreSQL Database'), - description=_('PostgreSQL Database'), - version='1.0.0', - gramps_target_version='5.0', - status=STABLE, - fname='postgresql.py', - databaseclass='PostgreSQL', - authors=['Doug Blank'], - authors_email=['doug.blank@gmail.com'] -) +try: + import psycopg2 + available = True +except (ImportError, ValueError): + available = False + +if available: + register(DATABASE, + id='postgresql', + name=_('PostgreSQL'), + name_accell=_('_PostgreSQL Database'), + description=_('PostgreSQL Database'), + version='1.0.0', + gramps_target_version='5.0', + status=STABLE, + fname='postgresql.py', + databaseclass='PostgreSQL', + authors=['Doug Blank'], + authors_email=['doug.blank@gmail.com'] + )