Allow lang_SUBTYPE formats; fixed an error when no network
svn: r15749
This commit is contained in:
parent
918b052ebb
commit
41931ba9c0
@ -305,33 +305,28 @@ 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 = []
|
||||||
if "_" in lang:
|
lang = locale.getlocale()[0] # not None
|
||||||
lang, variation = lang.split("_", 1)
|
if lang:
|
||||||
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, lang)
|
langs.append(lang)
|
||||||
LOG.debug(" trying: %s" % URL)
|
if "_" in lang:
|
||||||
try:
|
lang, variation = lang.split("_", 1)
|
||||||
fp = urllib.urlopen(URL)
|
langs.append(lang)
|
||||||
except: # some error
|
langs.append("en")
|
||||||
LOG.debug(" IOError!")
|
# now we have a list of languages to try:
|
||||||
fp = None
|
fp = None
|
||||||
count = 0
|
for lang in langs:
|
||||||
while fp and fp.getcode() != 200: # 200 = ok
|
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, lang)
|
||||||
count += 1
|
|
||||||
fp.close()
|
|
||||||
URL = "%s/listings/addons-%s.txt" % (ADDONS_URL, 'en')
|
|
||||||
done = True
|
|
||||||
LOG.debug(" trying: %s" % URL)
|
LOG.debug(" trying: %s" % URL)
|
||||||
try:
|
try:
|
||||||
fp = urllib.urlopen(URL)
|
fp = urllib.urlopen(URL)
|
||||||
except: # some error
|
except: # some error
|
||||||
LOG.debug(" IOError!")
|
LOG.debug(" IOError!")
|
||||||
fp = None
|
fp = None
|
||||||
if count > 2: # perhaps wrong code?
|
if fp and fp.getcode() == 200: # ok
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user