diff options
author | Ignacio RodrÃguez <ignacio@sugarlabs.org> | 2013-02-15 13:53:52 (GMT) |
---|---|---|
committer | Ignacio RodrÃguez <ignacio@sugarlabs.org> | 2013-02-15 13:53:52 (GMT) |
commit | 75252307b7b5880ae3f427cf43b0f4b3edae30e9 (patch) | |
tree | 80f12dd8043edebac199407c2b8bf9663f4d12a3 | |
parent | f64a289b8b7bff9ffbb373d9e62c1053c01c84fb (diff) |
Function for mirrors
-rw-r--r-- | utils.py | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -46,34 +46,34 @@ def get_logger(): return _logger +def _know(): + try: + remote_file = urllib.urlopen(LIST_DOWNLOAD) + return LIST_DOWNLOAD + except: + try: + remote_file = urllib.urlopen(LIST_DOWNLOAD_MIRROR1) + return LIST_DOWNLOAD_MIRROR1 + except: + try: + remote_file = urllib.urlopen(LIST_DOWNLOAD_MIRROR2) + return LIST_DOWNLOAD_MIRROR2 + except: + return "file://" + LIST_PATH + + def update_list(): """Download the latest list version""" global downloading try: downloading = True - remote_file = urllib.urlopen(LIST_DOWNLOAD) + remote_file = urllib.urlopen(_know()) _file = open(LIST_PATH, 'w') _file.write(remote_file.read()) _file.close() remote_file.close() except: - try: - downloading = True - remote_file = urllib.urlopen(LIST_DOWNLOAD_MIRROR1) - _file = open(LIST_PATH, 'w') - _file.write(remote_file.read()) - _file.close() - remote_file.close() - except: - try: - downloading = True - remote_file = urllib.urlopen(LIST_DOWNLOAD_MIRROR2) - _file = open(LIST_PATH, 'w') - _file.write(remote_file.read()) - _file.close() - remote_file.close() - except: - pass + pass downloading = False |