1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-05 20:58:42 +02:00

python3 compatibility: urllib

fixes all renames in urllib, urllib2, urlparse modules in python3
This commit is contained in:
Michal Vyskocil
2013-04-09 14:03:17 +02:00
committed by Adrian Schröter
parent f6edc186c2
commit 419367fca3
7 changed files with 113 additions and 90 deletions

View File

@@ -9,11 +9,15 @@ import os
import re
import sys
import shutil
try:
from urllib.parse import urlsplit
from urllib.request import URLError, HTTPError
except ImportError:
#python 2.x
from urlparse import urlsplit
from urllib2 import URLError, HTTPError
from tempfile import NamedTemporaryFile, mkdtemp
from osc.fetch import *
from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir
@@ -100,7 +104,7 @@ class Buildinfo:
sys.exit(1)
if not (apiurl.startswith('https://') or apiurl.startswith('http://')):
raise urllib2.URLError('invalid protocol for the apiurl: \'%s\'' % apiurl)
raise URLError('invalid protocol for the apiurl: \'%s\'' % apiurl)
self.buildtype = buildtype
self.apiurl = apiurl
@@ -609,7 +613,7 @@ def main(apiurl, opts, argv):
bc_file = open(bc_filename, 'w')
bc_file.write(bc)
bc_file.flush()
except urllib2.HTTPError as e:
except HTTPError as e:
if e.code == 404:
# check what caused the 404
if meta_exists(metatype='prj', path_args=(quote_plus(prj), ),