From 656e9cd35691c5cc8c431db33e6bd0bca6b4fd9b Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 26 Feb 2015 18:33:21 +0200 Subject: [PATCH] Compatibility: unbreak urllib import for old distros 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 --- gbp/scripts/create_remote_repo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index 5b4c1dde..9b933e6f 100755 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -23,7 +23,6 @@ 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: