8145: Some Addons provide an update even it was already done during the last start of Gramps
This commit is contained in:
parent
8fd456f604
commit
cd779d5163
@ -279,14 +279,14 @@ def load_addon_file(path, callback=None):
|
|||||||
except:
|
except:
|
||||||
if callback:
|
if callback:
|
||||||
callback(_("Unable to open '%s'") % path)
|
callback(_("Unable to open '%s'") % path)
|
||||||
return
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fp = open(path)
|
fp = open(path)
|
||||||
except:
|
except:
|
||||||
if callback:
|
if callback:
|
||||||
callback(_("Unable to open '%s'") % path)
|
callback(_("Unable to open '%s'") % path)
|
||||||
return
|
return False
|
||||||
try:
|
try:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
@ -296,7 +296,7 @@ def load_addon_file(path, callback=None):
|
|||||||
except:
|
except:
|
||||||
if callback:
|
if callback:
|
||||||
callback(_("Error in reading '%s'") % path)
|
callback(_("Error in reading '%s'") % path)
|
||||||
return
|
return False
|
||||||
fp.close()
|
fp.close()
|
||||||
# file_obj is either Zipfile or TarFile
|
# file_obj is either Zipfile or TarFile
|
||||||
if path.endswith(".zip") or path.endswith(".ZIP"):
|
if path.endswith(".zip") or path.endswith(".ZIP"):
|
||||||
@ -307,11 +307,11 @@ def load_addon_file(path, callback=None):
|
|||||||
except:
|
except:
|
||||||
if callback:
|
if callback:
|
||||||
callback(_("Error: cannot open '%s'") % path)
|
callback(_("Error: cannot open '%s'") % path)
|
||||||
return
|
return False
|
||||||
else:
|
else:
|
||||||
if callback:
|
if callback:
|
||||||
callback(_("Error: unknown file type: '%s'") % path)
|
callback(_("Error: unknown file type: '%s'") % path)
|
||||||
return
|
return False
|
||||||
# First, see what versions we have/are getting:
|
# First, see what versions we have/are getting:
|
||||||
good_gpr = set()
|
good_gpr = set()
|
||||||
for gpr_file in [name for name in file_obj.getnames() if name.endswith(".gpr.py")]:
|
for gpr_file in [name for name in file_obj.getnames() if name.endswith(".gpr.py")]:
|
||||||
@ -359,9 +359,16 @@ def load_addon_file(path, callback=None):
|
|||||||
s.remove(gpr_file)
|
s.remove(gpr_file)
|
||||||
if callback:
|
if callback:
|
||||||
callback(" " + (_("Error: missing gramps_target_version in '%s'...") % gpr_file) + "\n")
|
callback(" " + (_("Error: missing gramps_target_version in '%s'...") % gpr_file) + "\n")
|
||||||
|
registered_count = 0
|
||||||
if len(good_gpr) > 0:
|
if len(good_gpr) > 0:
|
||||||
# Now, install the ok ones
|
# Now, install the ok ones
|
||||||
file_obj.extractall(USER_PLUGINS)
|
try:
|
||||||
|
file_obj.extractall(USER_PLUGINS)
|
||||||
|
except OSError:
|
||||||
|
if callback:
|
||||||
|
callback("OSError installing '%s', skipped!" % path)
|
||||||
|
file_obj.close()
|
||||||
|
return False
|
||||||
if callback:
|
if callback:
|
||||||
callback((_("Installing '%s'...") % path) + "\n")
|
callback((_("Installing '%s'...") % path) + "\n")
|
||||||
gpr_files = set([os.path.split(os.path.join(USER_PLUGINS, name))[0]
|
gpr_files = set([os.path.split(os.path.join(USER_PLUGINS, name))[0]
|
||||||
@ -370,7 +377,12 @@ def load_addon_file(path, callback=None):
|
|||||||
u_gpr_file = conv_to_unicode(gpr_file)
|
u_gpr_file = conv_to_unicode(gpr_file)
|
||||||
if callback:
|
if callback:
|
||||||
callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n")
|
callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n")
|
||||||
|
registered_count += 1
|
||||||
file_obj.close()
|
file_obj.close()
|
||||||
|
if registered_count:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -395,6 +395,7 @@ class PluginStatus(ManagedWindow):
|
|||||||
from ..utils import ProgressMeter
|
from ..utils import ProgressMeter
|
||||||
pm = ProgressMeter(_("Install all Addons"), _("Installing..."), message_area=True)
|
pm = ProgressMeter(_("Install all Addons"), _("Installing..."), message_area=True)
|
||||||
pm.set_pass(total=len(self.addon_model))
|
pm.set_pass(total=len(self.addon_model))
|
||||||
|
errors = []
|
||||||
for row in self.addon_model:
|
for row in self.addon_model:
|
||||||
pm.step()
|
pm.step()
|
||||||
(help_name, name, ptype, image, desc, use, rating, contact,
|
(help_name, name, ptype, image, desc, use, rating, contact,
|
||||||
@ -1181,6 +1182,7 @@ class UpdateAddons(ManagedWindow):
|
|||||||
config.get('behavior.previously-seen-updates')[:] = []
|
config.get('behavior.previously-seen-updates')[:] = []
|
||||||
|
|
||||||
iter = model.get_iter_first()
|
iter = model.get_iter_first()
|
||||||
|
errors = []
|
||||||
while iter:
|
while iter:
|
||||||
for rowcnt in range(model.iter_n_children(iter)):
|
for rowcnt in range(model.iter_n_children(iter)):
|
||||||
child = model.iter_nth_child(iter, rowcnt)
|
child = model.iter_nth_child(iter, rowcnt)
|
||||||
@ -1188,8 +1190,11 @@ class UpdateAddons(ManagedWindow):
|
|||||||
if longop.should_cancel():
|
if longop.should_cancel():
|
||||||
break
|
break
|
||||||
elif row[0]: # toggle on
|
elif row[0]: # toggle on
|
||||||
load_addon_file(row[4], callback=LOG.debug)
|
ok = load_addon_file(row[4], callback=LOG.debug)
|
||||||
count += 1
|
if ok:
|
||||||
|
count += 1
|
||||||
|
else:
|
||||||
|
errors.append(row[2])
|
||||||
else: # add to list of previously seen, but not installed
|
else: # add to list of previously seen, but not installed
|
||||||
if row[5] not in config.get('behavior.previously-seen-updates'):
|
if row[5] not in config.get('behavior.previously-seen-updates'):
|
||||||
config.get('behavior.previously-seen-updates').append(row[5])
|
config.get('behavior.previously-seen-updates').append(row[5])
|
||||||
@ -1199,6 +1204,10 @@ class UpdateAddons(ManagedWindow):
|
|||||||
|
|
||||||
if not longop.was_cancelled():
|
if not longop.was_cancelled():
|
||||||
longop.end()
|
longop.end()
|
||||||
|
if errors:
|
||||||
|
OkDialog(_("Installation Errors"),
|
||||||
|
_("The following addons had errors: ") +
|
||||||
|
", ".join(errors))
|
||||||
if count:
|
if count:
|
||||||
OkDialog(_("Done downloading and installing addons"),
|
OkDialog(_("Done downloading and installing addons"),
|
||||||
# translators: leave all/any {...} untranslated
|
# translators: leave all/any {...} untranslated
|
||||||
|
Loading…
Reference in New Issue
Block a user