From 41931ba9c0561a40f4fd3f04dd98972492a34487 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 16 Aug 2010 04:30:17 +0000 Subject: [PATCH] Allow lang_SUBTYPE formats; fixed an error when no network svn: r15749 --- src/gui/viewmanager.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index ef49a020e..2e250f718 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -305,33 +305,28 @@ class ViewManager(CLIManager): if update: 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 + langs = [] + lang = locale.getlocale()[0] # not None + if lang: + langs.append(lang) + if "_" in lang: + 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) 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 + if fp and fp.getcode() == 200: # ok break - if fp: - addon_update_list = [] + addon_update_list = [] + if fp and fp.getcode() == 200: for line in fp: try: plugin_dict = safe_eval(line)