Checks for open network connection; get listing file in proper language
svn: r15724
This commit is contained in:
parent
e7c741a2a7
commit
f3fb0b9d2e
@ -201,6 +201,7 @@ UIDEFAULT = '''<ui>
|
||||
WIKI_HELP_PAGE_FAQ = '%s_-_FAQ' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE_KEY = '%s_-_Keybindings' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE_MAN = '%s' % const.URL_MANUAL_PAGE
|
||||
ADDONS_URL = "http://gramps-addons.svn.sourceforge.net/viewvc/gramps-addons/trunk"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -292,12 +293,35 @@ class ViewManager(CLIManager):
|
||||
elif howoften == 4: # always
|
||||
update = True
|
||||
if update:
|
||||
import urllib
|
||||
print("Checking for updated addons...")
|
||||
lang = 'en'
|
||||
SOURCEFORGE = "http://gramps-addons.svn.sourceforge.net/viewvc/gramps-addons/trunk/"
|
||||
URL = "%s/listings/addons-%s.txt" % (SOURCEFORGE, lang)
|
||||
import urllib, locale
|
||||
LOG.debug("Checking for updated addons...")
|
||||
lang = locale.getlocale()[0] or "en"
|
||||
if "_" in lang:
|
||||
lang, variation = lang.split("_", 1)
|
||||
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, lang)
|
||||
LOG.debug(" trying: %s" % URL)
|
||||
try:
|
||||
fp = urllib.urlopen(URL)
|
||||
except: # some error
|
||||
LOG.debug(" IOError!")
|
||||
fp = None
|
||||
count = 0
|
||||
while fp and fp.getcode() != 200: # 200 = ok
|
||||
count += 1
|
||||
fp.close()
|
||||
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, 'en')
|
||||
done = True
|
||||
LOG.debug(" trying: %s" % URL)
|
||||
try:
|
||||
fp = urllib.urlopen(URL)
|
||||
except: # some error
|
||||
LOG.debug(" IOError!")
|
||||
fp = None
|
||||
if count > 2: # perhaps wrong code?
|
||||
fp = None
|
||||
break
|
||||
if fp:
|
||||
addon_update_list = []
|
||||
for line in fp:
|
||||
try:
|
||||
plugin_dict = safe_eval(line)
|
||||
@ -308,17 +332,21 @@ class ViewManager(CLIManager):
|
||||
if plugin:
|
||||
if (version_str_to_tup(plugin_dict["v"], 3) >
|
||||
version_str_to_tup(plugin.version, 3)):
|
||||
print(" Downloading '%s'..." % plugin_dict["z"])
|
||||
#load_addon_file("%s/download/%s" %
|
||||
# (SOURCEFORGE, plugin_dict["z"]),
|
||||
# callback=print)
|
||||
LOG.debug(" Downloading '%s'..." % plugin_dict["z"])
|
||||
addon_update_list.append("%s/download/%s" %
|
||||
(SOURCEFORGE,
|
||||
plugin_dict["z"]))
|
||||
else:
|
||||
print(" '%s' is ok" % plugin_dict["n"])
|
||||
LOG.debug(" '%s' is ok" % plugin_dict["n"])
|
||||
else:
|
||||
print(" '%s' is not installed" % plugin_dict["n"])
|
||||
LOG.debug(" '%s' is not installed" % plugin_dict["n"])
|
||||
config.set("behavior.last-check-for-updates",
|
||||
datetime.date.today().strftime("%Y/%m/%d"))
|
||||
print("Done!")
|
||||
if fp:
|
||||
fp.close()
|
||||
#for plugin_url in addon_update_list:
|
||||
# load_addon_file(plugin_url, callback=print)
|
||||
LOG.debug("Done updating!")
|
||||
|
||||
def _errordialog(title, errormessage):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user