Fix retrieval of version metadata for python3 Gramps.py -L
svn: r21463
This commit is contained in:
parent
ad20c91b4f
commit
3872899ebc
@ -146,13 +146,31 @@ class CLIDbManager(object):
|
|||||||
else:
|
else:
|
||||||
from bsddb import dbshelve, db
|
from bsddb import dbshelve, db
|
||||||
from gramps.gen.db import META, PERSON_TBL
|
from gramps.gen.db import META, PERSON_TBL
|
||||||
|
from gramps.gen.db.dbconst import BDBVERSFN
|
||||||
|
|
||||||
|
bdbversion_name = os.path.join(file_name, BDBVERSFN)
|
||||||
|
if os.path.isfile(bdbversion_name):
|
||||||
|
vers_file = open(bdbversion_name)
|
||||||
|
bsddbversion = vers_file.readline().strip()
|
||||||
|
else:
|
||||||
|
bsddbversion = "Unknown"
|
||||||
|
current_bsddbversion = str(db.version())
|
||||||
|
|
||||||
|
if bsddbversion != current_bsddbversion:
|
||||||
|
return "Unknown", "Unknown"
|
||||||
|
|
||||||
|
print("trying to find version")
|
||||||
env = db.DBEnv()
|
env = db.DBEnv()
|
||||||
flags = db.DB_CREATE | db.DB_PRIVATE |\
|
flags = db.DB_CREATE | db.DB_PRIVATE |\
|
||||||
db.DB_INIT_MPOOL | db.DB_INIT_LOCK |\
|
db.DB_INIT_MPOOL | db.DB_INIT_LOCK |\
|
||||||
db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD
|
db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD
|
||||||
try:
|
try:
|
||||||
|
print(file_name, type(file_name))
|
||||||
env.open(file_name, flags)
|
env.open(file_name, flags)
|
||||||
except:
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
env.close()
|
||||||
return "Unknown", "Unknown"
|
return "Unknown", "Unknown"
|
||||||
dbmap1 = dbshelve.DBShelf(env)
|
dbmap1 = dbshelve.DBShelf(env)
|
||||||
fname = os.path.join(file_name, META + ".db")
|
fname = os.path.join(file_name, META + ".db")
|
||||||
@ -160,14 +178,18 @@ class CLIDbManager(object):
|
|||||||
dbmap1.open(fname, META, db.DB_HASH, db.DB_RDONLY)
|
dbmap1.open(fname, META, db.DB_HASH, db.DB_RDONLY)
|
||||||
except:
|
except:
|
||||||
env.close()
|
env.close()
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
return "Unknown", "Unknown"
|
return "Unknown", "Unknown"
|
||||||
version = dbmap1.get('version', default=None)
|
version = dbmap1.get(b'version', default=None)
|
||||||
dbmap1.close()
|
dbmap1.close()
|
||||||
dbmap2 = dbshelve.DBShelf(env)
|
dbmap2 = dbshelve.DBShelf(env)
|
||||||
fname = os.path.join(file_name, PERSON_TBL + ".db")
|
fname = os.path.join(file_name, PERSON_TBL + ".db")
|
||||||
try:
|
try:
|
||||||
dbmap2.open(fname, PERSON_TBL, db.DB_HASH, db.DB_RDONLY)
|
dbmap2.open(fname, PERSON_TBL, db.DB_HASH, db.DB_RDONLY)
|
||||||
except:
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
env.close()
|
env.close()
|
||||||
return "Unknown", "Unknown"
|
return "Unknown", "Unknown"
|
||||||
count = len(dbmap2)
|
count = len(dbmap2)
|
||||||
@ -182,8 +204,12 @@ class CLIDbManager(object):
|
|||||||
# make the default directory if it does not exist
|
# make the default directory if it does not exist
|
||||||
list = []
|
list = []
|
||||||
for item in self.current_names:
|
for item in self.current_names:
|
||||||
(name, dirpath, path_name, last,
|
if __debug__:
|
||||||
tval, enable, stock_id) = item
|
(name, dirpath, path_name, last,
|
||||||
|
tval, enable, stock_id, version) = item
|
||||||
|
else:
|
||||||
|
(name, dirpath, path_name, last,
|
||||||
|
tval, enable, stock_id) = item
|
||||||
count, version = self.get_dbdir_summary(dirpath)
|
count, version = self.get_dbdir_summary(dirpath)
|
||||||
retval = {}
|
retval = {}
|
||||||
retval["Number of people"] = count
|
retval["Number of people"] = count
|
||||||
@ -228,11 +254,29 @@ class CLIDbManager(object):
|
|||||||
if (stock_id == 'gramps-lock'):
|
if (stock_id == 'gramps-lock'):
|
||||||
last = find_locker_name(dirpath)
|
last = find_locker_name(dirpath)
|
||||||
|
|
||||||
self.current_names.append(
|
if __debug__:
|
||||||
(name, os.path.join(dbdir, dpath), path_name,
|
count, version = self.get_dbdir_summary(dirpath)
|
||||||
last, tval, enable, stock_id))
|
if version == "Unknown":
|
||||||
|
version = "0"
|
||||||
|
else:
|
||||||
|
version = str(version)
|
||||||
|
from gramps.gen.db.dbconst import BDBVERSFN
|
||||||
|
bdbversion_name = os.path.join(dirpath, BDBVERSFN)
|
||||||
|
if os.path.isfile(bdbversion_name):
|
||||||
|
vers_file = open(bdbversion_name)
|
||||||
|
version += " " + vers_file.readline().strip()
|
||||||
|
self.current_names.append(
|
||||||
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
|
last, tval, enable, stock_id, version))
|
||||||
|
else:
|
||||||
|
self.current_names.append(
|
||||||
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
|
last, tval, enable, stock_id))
|
||||||
|
|
||||||
self.current_names.sort()
|
if __debug__:
|
||||||
|
self.current_names.sort(key=lambda x: x[4], reverse=True)
|
||||||
|
else:
|
||||||
|
self.current_names.sort()
|
||||||
|
|
||||||
def get_family_tree_path(self, name):
|
def get_family_tree_path(self, name):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user