Allow lang_SUBTYPE formats; fixed an error when no network

svn: r15749
This commit is contained in:
Doug Blank 2010-08-16 04:30:17 +00:00
parent 918b052ebb
commit 41931ba9c0

View File

@ -305,9 +305,17 @@ class ViewManager(CLIManager):
if update: if update:
import urllib, locale import urllib, locale
LOG.debug("Checking for updated addons...") LOG.debug("Checking for updated addons...")
lang = locale.getlocale()[0] or "en" langs = []
lang = locale.getlocale()[0] # not None
if lang:
langs.append(lang)
if "_" in lang: if "_" in lang:
lang, variation = lang.split("_", 1) lang, variation = lang.split("_", 1)
langs.append(lang)
langs.append("en")
# now we have a list of languages to try:
fp = None
for lang in langs:
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, lang) URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, lang)
LOG.debug(" trying: %s" % URL) LOG.debug(" trying: %s" % URL)
try: try:
@ -315,23 +323,10 @@ class ViewManager(CLIManager):
except: # some error except: # some error
LOG.debug(" IOError!") LOG.debug(" IOError!")
fp = None fp = None
count = 0 if fp and fp.getcode() == 200: # ok
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 break
if fp:
addon_update_list = [] addon_update_list = []
if fp and fp.getcode() == 200:
for line in fp: for line in fp:
try: try:
plugin_dict = safe_eval(line) plugin_dict = safe_eval(line)