[game-data-packager] 01/01: also obey GDP_MIRROR when folowing direct url

Alexandre Detiste detiste-guest at moszumanska.debian.org
Thu Apr 2 10:19:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 492602837d7d3c7a8ddecf3ef37d77916f78106d
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Thu Apr 2 12:18:54 2015 +0200

    also obey GDP_MIRROR when folowing direct url
---
 game_data_packager/__init__.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index b13ca55..14d658e 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1215,8 +1215,22 @@ class GameData(object):
 
     def choose_mirror(self, wanted):
         mirrors = []
+        mirror = os.environ.get('GDP_MIRROR')
+        if mirror:
+            if mirror.startswith('/'):
+                mirror = 'file://' + mirror
+            elif mirror.split(':')[0] not in ('http', 'https', 'ftp', 'file'):
+                mirror = 'http://' + mirror
+            if not mirror.endswith('/'):
+                mirror = mirror + '/'
+
         if type(wanted.download) is str:
-            return [wanted.download]
+            if mirror:
+                return list(set([mirror + wanted.name,
+                   mirror + os.path.basename(wanted.download)])) + [wanted.download]
+            else:
+                return [wanted.download]
+
         for mirror_list, details in wanted.download.items():
             try:
                 f = open(os.path.join(ETCDIR, mirror_list), encoding='utf-8')
@@ -1238,16 +1252,8 @@ class GameData(object):
                 logger.warning('Could not open mirror list "%s"', mirror_list,
                         exc_info=True)
         random.shuffle(mirrors)
-        if 'GDP_MIRROR' in os.environ:
-            url = os.environ.get('GDP_MIRROR')
-            if url.startswith('/'):
-                url = 'file://' + url
-            elif url.split(':')[0] not in ('http', 'https', 'ftp', 'file'):
-                url = 'http://' + url
-            if not url.endswith('/'):
-                url = url + '/'
-            url = url + details.get('name', wanted.name)
-            mirrors.insert(0, url)
+        if mirror:
+            mirrors.insert(0, mirror + wanted.name)
         if not mirrors:
             logger.error('Could not select a mirror for "%s"', wanted.name)
             return []

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list