5934: How to fix invalid Database Path?
svn: r20456
This commit is contained in:
parent
d3ea18e297
commit
66a3d2c4d7
@ -197,26 +197,26 @@ class CLIDbManager(object):
|
|||||||
# make the default directory if it does not exist
|
# make the default directory if it does not exist
|
||||||
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
||||||
dbdir = dbdir.encode(sys.getfilesystemencoding())
|
dbdir = dbdir.encode(sys.getfilesystemencoding())
|
||||||
make_dbdir(dbdir)
|
db_ok = make_dbdir(dbdir)
|
||||||
|
|
||||||
self.current_names = []
|
self.current_names = []
|
||||||
|
if db_ok:
|
||||||
for dpath in os.listdir(dbdir):
|
for dpath in os.listdir(dbdir):
|
||||||
dirpath = os.path.join(dbdir, dpath)
|
dirpath = os.path.join(dbdir, dpath)
|
||||||
path_name = os.path.join(dirpath, NAME_FILE)
|
path_name = os.path.join(dirpath, NAME_FILE)
|
||||||
if os.path.isfile(path_name):
|
if os.path.isfile(path_name):
|
||||||
name = file(path_name).readline().strip()
|
name = file(path_name).readline().strip()
|
||||||
|
|
||||||
(tval, last) = time_val(dirpath)
|
(tval, last) = time_val(dirpath)
|
||||||
(enable, stock_id) = self.icon_values(dirpath, self.active,
|
(enable, stock_id) = self.icon_values(dirpath, self.active,
|
||||||
self.dbstate.db.is_open())
|
self.dbstate.db.is_open())
|
||||||
|
|
||||||
if (stock_id == 'gramps-lock'):
|
if (stock_id == 'gramps-lock'):
|
||||||
last = find_locker_name(dirpath)
|
last = find_locker_name(dirpath)
|
||||||
|
|
||||||
self.current_names.append(
|
self.current_names.append(
|
||||||
(name, os.path.join(dbdir, dpath), path_name,
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
last, tval, enable, stock_id))
|
last, tval, enable, stock_id))
|
||||||
|
|
||||||
self.current_names.sort()
|
self.current_names.sort()
|
||||||
|
|
||||||
@ -403,7 +403,11 @@ def make_dbdir(dbdir):
|
|||||||
os.makedirs(dbdir)
|
os.makedirs(dbdir)
|
||||||
except (IOError, OSError), msg:
|
except (IOError, OSError), msg:
|
||||||
msg = unicode(str(msg), sys.getfilesystemencoding())
|
msg = unicode(str(msg), sys.getfilesystemencoding())
|
||||||
LOG.error(_("Could not make database directory: ") + msg)
|
LOG.error(_("\nERROR: Wrong database path in Edit Menu->Preferences.\n"
|
||||||
|
"Open preferences and set correct database path.\n\n"
|
||||||
|
"Details: Could not make database directory:\n %s\n\n") % msg)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def find_next_db_name(name_list):
|
def find_next_db_name(name_list):
|
||||||
"""
|
"""
|
||||||
|
@ -1220,9 +1220,16 @@ class GrampsPreferences(ConfigureDialog):
|
|||||||
table.set_col_spacings(6)
|
table.set_col_spacings(6)
|
||||||
table.set_row_spacings(6)
|
table.set_row_spacings(6)
|
||||||
|
|
||||||
self.add_entry(table,
|
|
||||||
_('Family Tree Database path'),
|
self.dbpath_entry = Gtk.Entry()
|
||||||
0, 'behavior.database-path')
|
self.add_path_box(table,
|
||||||
|
_('Family Tree Database path'),
|
||||||
|
0, self.dbpath_entry, config.get('behavior.database-path'),
|
||||||
|
self.set_dbpath, self.select_dbpath)
|
||||||
|
|
||||||
|
#self.add_entry(table,
|
||||||
|
# _('Family Tree Database path'),
|
||||||
|
# 0, 'behavior.database-path')
|
||||||
self.add_checkbox(table,
|
self.add_checkbox(table,
|
||||||
_('Automatically load last family tree'),
|
_('Automatically load last family tree'),
|
||||||
1, 'behavior.autoload')
|
1, 'behavior.autoload')
|
||||||
@ -1255,6 +1262,30 @@ class GrampsPreferences(ConfigureDialog):
|
|||||||
self.path_entry.set_text(val)
|
self.path_entry.set_text(val)
|
||||||
f.destroy()
|
f.destroy()
|
||||||
|
|
||||||
|
def set_dbpath(self, *obj):
|
||||||
|
path = self.dbpath_entry.get_text().strip()
|
||||||
|
config.set('behavior.database-path', path)
|
||||||
|
|
||||||
|
def select_dbpath(self, *obj):
|
||||||
|
f = Gtk.FileChooserDialog(
|
||||||
|
_("Select database directory"),
|
||||||
|
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||||
|
buttons=(Gtk.STOCK_CANCEL,
|
||||||
|
Gtk.ResponseType.CANCEL,
|
||||||
|
Gtk.STOCK_APPLY,
|
||||||
|
Gtk.ResponseType.OK))
|
||||||
|
dbpath = config.get('behavior.database-path')
|
||||||
|
if not dbpath:
|
||||||
|
dbpath = os.path.join(os.environ['HOME'], '.gramps','grampsdb')
|
||||||
|
f.set_current_folder(os.path.dirname(dbpath))
|
||||||
|
|
||||||
|
status = f.run()
|
||||||
|
if status == Gtk.ResponseType.OK:
|
||||||
|
val = get_unicode_path_from_file_chooser(f.get_filename())
|
||||||
|
if val:
|
||||||
|
self.dbpath_entry.set_text(val)
|
||||||
|
f.destroy()
|
||||||
|
|
||||||
def update_idformat_entry(self, obj, constant):
|
def update_idformat_entry(self, obj, constant):
|
||||||
config.set(constant, unicode(obj.get_text()))
|
config.set(constant, unicode(obj.get_text()))
|
||||||
self.dbstate.db.set_prefixes(
|
self.dbstate.db.set_prefixes(
|
||||||
|
Loading…
Reference in New Issue
Block a user