Fix retrieval of version metadata for python3 Gramps.py -L, reverting inadvertent changes in revision 21463
svn: r21465
This commit is contained in:
parent
3872899ebc
commit
57fcc67498
@ -146,31 +146,13 @@ 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")
|
||||||
@ -178,8 +160,6 @@ 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(b'version', default=None)
|
version = dbmap1.get(b'version', default=None)
|
||||||
dbmap1.close()
|
dbmap1.close()
|
||||||
@ -188,8 +168,6 @@ class CLIDbManager(object):
|
|||||||
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)
|
||||||
@ -204,12 +182,8 @@ 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:
|
||||||
if __debug__:
|
(name, dirpath, path_name, last,
|
||||||
(name, dirpath, path_name, last,
|
tval, enable, stock_id) = item
|
||||||
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
|
||||||
@ -254,29 +228,11 @@ class CLIDbManager(object):
|
|||||||
if (stock_id == 'gramps-lock'):
|
if (stock_id == 'gramps-lock'):
|
||||||
last = find_locker_name(dirpath)
|
last = find_locker_name(dirpath)
|
||||||
|
|
||||||
if __debug__:
|
self.current_names.append(
|
||||||
count, version = self.get_dbdir_summary(dirpath)
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
if version == "Unknown":
|
last, tval, enable, stock_id))
|
||||||
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))
|
|
||||||
|
|
||||||
if __debug__:
|
self.current_names.sort()
|
||||||
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