Compatibility: unbreak urllib import for old distros test-devel
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 26 Feb 2015 16:33:21 +0000 (18:33 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:48 +0000 (10:07 +0200)
Old versions of python-six shipped on e.g. Debian 7, Ubuntu 12.04 and
openSUSE 12.3 do not contain urllib.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/create_remote_repo.py

index b24a59afd9f85372a1528f8eb5e632f561c359d9..3a29eb50a1907cf1ca24ee5bb7737a06d290c03a 100755 (executable)
@@ -23,7 +23,6 @@ from __future__ import print_function
 from six.moves import configparser
 import sys
 import os, os.path
-from six.moves import urllib
 import subprocess
 import tty, termios
 import re
@@ -108,7 +107,14 @@ def parse_url(remote_url, name, pkg, template_dir=None):
         ...
     GbpError: URL contains invalid ~username expansion.
     """
-    frags = urllib.parse.urlparse(remote_url)
+    # Fix for old distros like Debian 7, Ubuntu 12.04 and openSUSE 12.3 with old
+    # python-six that doesn't have urllib
+    try:
+        from six.moves import urllib
+        frags = urllib.parse.urlparse(remote_url)
+    except ImportError:
+        import urlparse
+        frags = urlparse.urlparse(remote_url)
     if frags.scheme in ['ssh', 'git+ssh', '']:
         scheme = frags.scheme
     else: