summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/control6
-rwxr-xr-xdebian/rules8
-rwxr-xr-xfuse/fuseosc2
-rw-r--r--osc/OscConfigParser.py8
-rw-r--r--osc/babysitter.py8
-rw-r--r--osc/build.py18
-rw-r--r--osc/checker.py2
-rw-r--r--osc/cmdln.py26
-rw-r--r--osc/commandline.py48
-rw-r--r--osc/conf.py17
-rw-r--r--osc/core.py100
-rw-r--r--osc/fetch.py11
-rw-r--r--osc/meter.py2
-rw-r--r--osc/oscssl.py12
-rw-r--r--osc/util/ar.py4
-rw-r--r--osc/util/archquery.py2
-rw-r--r--osc/util/cpio.py6
-rw-r--r--osc/util/debquery.py4
-rw-r--r--osc/util/packagequery.py2
-rw-r--r--osc/util/rpmquery.py2
-rwxr-xr-xosc_hotshot.py2
-rw-r--r--packaging/osc.spec26
-rw-r--r--tests/common.py6
-rw-r--r--tests/test_commit.py4
-rw-r--r--tests/test_repairwc.py4
-rw-r--r--tests/test_setlinkrev.py2
26 files changed, 165 insertions, 167 deletions
diff --git a/debian/control b/debian/control
index 180213a..71823c2 100644
--- a/debian/control
+++ b/debian/control
@@ -2,15 +2,15 @@ Source: osc
Section: devel
Priority: extra
Maintainer: Adrian Schroeter <adrian@suse.de>
-Build-Depends: debhelper (>= 4.0.0), dpatch, python, python-dev, python-urlgrabber
+Build-Depends: debhelper (>= 7.0.15), dpatch, dh-python, python3, python3-dev, python3-urlgrabber
Standards-Version: 3.8.3
Homepage: http://en.opensuse.org/Build_Service/CLI
Package: osc
Section: devel
Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python (>= 2.5), python-urlgrabber, python-rpm, python-keyring, python-gobject, python-m2crypto (>= 0.20) | python3-m2crypto
-Suggests: python-gnomekeyring, gnome-keyring, build (> 2010.04.24)
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, python3-urlgrabber, python3-rpm, python3-keyring, python3-gobject, python3-m2crypto
+Suggests: build (> 2010.04.24)
Description: openSUSE (buildsystem) commander
Commandline client for the openSUSE Build Service, which allows to access
repositories in the openSUSE Build Service in similar way as Subversion
diff --git a/debian/rules b/debian/rules
index 5f27b9c..06e65f8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,13 +1,7 @@
#!/usr/bin/make -f
%:
- dh $@
-
-build: build-stamp
-build-stamp:
- dh_testdir
- touch build-stamp
- python setup.py build --force
+ dh $@ --with python3 --buildsystem=pybuild
override_dh_installchangelogs:
dh_installchangelogs NEWS
diff --git a/fuse/fuseosc b/fuse/fuseosc
index 08489ea..5230441 100755
--- a/fuse/fuseosc
+++ b/fuse/fuseosc
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (c) 2008-2009 Pavol Rusnak <prusnak@suse.cz>
#
diff --git a/osc/OscConfigParser.py b/osc/OscConfigParser.py
index bf154b1..f552887 100644
--- a/osc/OscConfigParser.py
+++ b/osc/OscConfigParser.py
@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-from __future__ import print_function
+
import sys
@@ -21,7 +21,7 @@ if sys.version_info >= ( 3, ):
import configparser
else:
#python 2.x
- import ConfigParser as configparser
+ import configparser as configparser
import re
@@ -130,7 +130,7 @@ class SectionLine(Line):
self._lines.append(CommentLine(line))
def copy(self):
- return dict(self.items())
+ return dict(list(self.items()))
def items(self):
return [ (i.name, i.value) for i in self._lines if i.type == 'option' ]
@@ -330,7 +330,7 @@ class OscConfigParser(configparser.SafeConfigParser):
this section and not "inherited" from the default.
"""
if proper:
- return self.optionxform(option) in self._sections[section].keys()
+ return self.optionxform(option) in list(self._sections[section].keys())
return configparser.SafeConfigParser.has_option(self, section, option, **kwargs)
# XXX: simplify!
diff --git a/osc/babysitter.py b/osc/babysitter.py
index 272aabd..db794aa 100644
--- a/osc/babysitter.py
+++ b/osc/babysitter.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
-from __future__ import print_function
+
import errno
import os.path
@@ -37,8 +37,8 @@ try:
from urllib.error import URLError, HTTPError
except ImportError:
#python 2.x
- from httplib import HTTPException, BadStatusLine
- from urllib2 import URLError, HTTPError
+ from http.client import HTTPException, BadStatusLine
+ from urllib.error import URLError, HTTPError
# the good things are stolen from Matt Mackall's mercurial
@@ -126,7 +126,7 @@ def run(prg, argv=None):
if e.code >= 500 and e.code <= 599:
print('\nRequest: %s' % e.filename)
print('Headers:')
- for h, v in e.hdrs.items():
+ for h, v in list(e.hdrs.items()):
if h != 'Set-Cookie':
print("%s: %s" % (h, v))
diff --git a/osc/build.py b/osc/build.py
index 218d354..7a87370 100644
--- a/osc/build.py
+++ b/osc/build.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
-from __future__ import print_function
+
import os
import re
@@ -15,8 +15,8 @@ try:
from urllib.request import URLError, HTTPError
except ImportError:
#python 2.x
- from urlparse import urlsplit
- from urllib2 import URLError, HTTPError
+ from urllib.parse import urlsplit
+ from urllib.error import URLError, HTTPError
from tempfile import NamedTemporaryFile, mkdtemp
from osc.fetch import *
@@ -358,9 +358,9 @@ def get_prefer_pkgs(dirs, wanted_arch, type, cpio=None):
packageQueries.add(packageQuery)
prefer_pkgs = dict((name, packageQuery.path())
- for name, packageQuery in packageQueries.items())
+ for name, packageQuery in list(packageQueries.items()))
- depfile = create_deps(packageQueries.values())
+ depfile = create_deps(list(packageQueries.values()))
cpio.add('deps', '\n'.join(depfile))
return prefer_pkgs
@@ -397,7 +397,7 @@ def check_trusted_projects(apiurl, projects):
if not prj in trusted:
print("\nThe build root needs packages from project '%s'." % prj)
print("Note that malicious packages can compromise the build result or even your system.")
- r = raw_input(trustprompt % { 'project': prj })
+ r = input(trustprompt % { 'project': prj })
if r == '1':
print("adding '%s' to ~/.oscrc: ['%s']['trusted_prj']" % (prj, apiurl))
trusted.append(prj)
@@ -730,7 +730,7 @@ def main(apiurl, opts, argv):
rpmlist_prefers = []
if prefer_pkgs:
print('Evaluating preferred packages')
- for name, path in prefer_pkgs.items():
+ for name, path in list(prefer_pkgs.items()):
if bi.has_dep(name):
# We remove a preferred package from the buildinfo, so that the
# fetcher doesn't take care about them.
@@ -769,7 +769,7 @@ def main(apiurl, opts, argv):
if not opts.trust_all_projects:
# implicitly trust the project we are building for
- check_trusted_projects(apiurl, [ i for i in bi.projects.keys() if not i == prj ])
+ check_trusted_projects(apiurl, [ i for i in list(bi.projects.keys()) if not i == prj ])
# now update the package cache
fetcher.run(bi)
@@ -874,7 +874,7 @@ def main(apiurl, opts, argv):
else:
os.symlink(sffn, tffn)
if prefer_pkgs:
- for name, path in prefer_pkgs.items():
+ for name, path in list(prefer_pkgs.items()):
if name == filename:
print("Using prefered package: " + path + "/" + filename)
os.unlink(tffn)
diff --git a/osc/checker.py b/osc/checker.py
index f80a0da..50643d9 100644
--- a/osc/checker.py
+++ b/osc/checker.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
from tempfile import mkdtemp
import os
diff --git a/osc/cmdln.py b/osc/cmdln.py
index c407095..ef69942 100644
--- a/osc/cmdln.py
+++ b/osc/cmdln.py
@@ -3,7 +3,7 @@
# Author: Trent Mick (TrentM@ActiveState.com)
# Home: http://trentm.com/projects/cmdln/
-from __future__ import print_function
+
"""An improvement on Python's standard cmd.py module.
@@ -51,16 +51,16 @@ from datetime import date
# this is python 2.x style
def introspect_handler_2(handler):
# Extract the introspection bits we need.
- func = handler.im_func
- if func.func_defaults:
- func_defaults = func.func_defaults
+ func = handler.__func__
+ if func.__defaults__:
+ func_defaults = func.__defaults__
else:
func_defaults = []
return \
func_defaults, \
- func.func_code.co_argcount, \
- func.func_code.co_varnames, \
- func.func_code.co_flags, \
+ func.__code__.co_argcount, \
+ func.__code__.co_varnames, \
+ func.__code__.co_flags, \
func
def introspect_handler_3(handler):
@@ -85,7 +85,7 @@ else:
#---- globals
-LOOP_ALWAYS, LOOP_NEVER, LOOP_IF_EMPTY = range(3)
+LOOP_ALWAYS, LOOP_NEVER, LOOP_IF_EMPTY = list(range(3))
# An unspecified optional argument when None is a meaningful value.
_NOT_SPECIFIED = ("Not", "Specified")
@@ -419,9 +419,9 @@ class RawCmdln(cmd.Cmd):
try:
try:
#python 2.x
- line = raw_input(self._prompt_str)
- except NameError:
line = input(self._prompt_str)
+ except NameError:
+ line = eval(input(self._prompt_str))
except EOFError:
line = 'EOF'
else:
@@ -723,7 +723,7 @@ class RawCmdln(cmd.Cmd):
"${cmd_option_list}": self._help_preprocess_cmd_option_list,
}
- for marker, preprocessor in preprocessors.items():
+ for marker, preprocessor in list(preprocessors.items()):
if marker in help:
help = preprocessor(help, cmdname)
return help
@@ -754,7 +754,7 @@ class RawCmdln(cmd.Cmd):
# Find any aliases for commands.
token2canonical = self._get_canonical_map()
aliases = {}
- for token, cmdname in token2canonical.items():
+ for token, cmdname in list(token2canonical.items()):
if token == cmdname:
continue
aliases.setdefault(cmdname, []).append(token)
@@ -961,7 +961,7 @@ class RawCmdln(cmd.Cmd):
continue
cmd2funcname[cmdname] = attr
token2canonical[cmdname] = cmdname
- for cmdname, funcname in cmd2funcname.items(): # add aliases
+ for cmdname, funcname in list(cmd2funcname.items()): # add aliases
func = getattr(self, funcname)
aliases = getattr(func, "aliases", [])
for alias in aliases:
diff --git a/osc/commandline.py b/osc/commandline.py
index d7710b2..0dcbd94 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or version 3 (at your option).
-from __future__ import print_function
+
from . import cmdln
from . import conf
@@ -18,8 +18,8 @@ try:
ET_ENCODING = "unicode"
except ImportError:
#python 2.x
- from urlparse import urlsplit
- from urllib2 import HTTPError
+ from urllib.parse import urlsplit
+ from urllib.error import HTTPError
ET_ENCODING = "utf-8"
from optparse import SUPPRESS_HELP
@@ -139,7 +139,7 @@ class Osc(cmdln.Cmdln):
print('Creating osc configuration file %s ...' % e.file, file=sys.stderr)
import getpass
config = {}
- config['user'] = raw_input('Username: ')
+ config['user'] = input('Username: ')
config['pass'] = getpass.getpass()
if self.options.no_keyring:
config['use_keyring'] = '0'
@@ -155,7 +155,7 @@ class Osc(cmdln.Cmdln):
except oscerr.ConfigMissingApiurl as e:
print(e.msg, file=sys.stderr)
import getpass
- user = raw_input('Username: ')
+ user = input('Username: ')
passwd = getpass.getpass()
conf.add_section(e.file, e.url, user, passwd)
if try_again:
@@ -705,7 +705,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args)
- if not args or args[0] not in metatypes.keys():
+ if not args or args[0] not in list(metatypes.keys()):
raise oscerr.WrongArgs('Unknown meta type. Choose one of %s.' \
% ', '.join(metatypes))
@@ -1111,7 +1111,7 @@ class Osc(cmdln.Cmdln):
repl = ''
print('\n\nThere are already following submit request: %s.' % \
', '.join([str(i) for i in myreqs ]))
- repl = raw_input('\nSupersede the old requests? (y/n) ')
+ repl = input('\nSupersede the old requests? (y/n) ')
if repl.lower() == 'y':
myreqs += [ value ]
@@ -1147,7 +1147,7 @@ class Osc(cmdln.Cmdln):
modified = [i for i in p.filenamelist if not p.status(i) in (' ', '?', 'S')]
if len(modified) > 0 and not opts.yes:
print('Your working copy has local modifications.')
- repl = raw_input('Proceed without committing the local changes? (y|N) ')
+ repl = input('Proceed without committing the local changes? (y|N) ')
if repl != 'y':
raise oscerr.UserAbort()
elif len(args) >= 3:
@@ -1360,7 +1360,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
modified = [i for i in p.filenamelist if p.status(i) != ' ' and p.status(i) != '?']
if len(modified) > 0:
print('Your working copy has local modifications.')
- repl = raw_input('Proceed without committing the local changes? (y|N) ')
+ repl = input('Proceed without committing the local changes? (y|N) ')
if repl != 'y':
sys.exit(1)
elif len(args) >= 3:
@@ -1400,7 +1400,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(myreqs) > 0 and not opts.yes:
print('You already created the following submit request: %s.' % \
', '.join([i.reqid for i in myreqs ]))
- repl = raw_input('Supersede the old requests? (y/n/c) ')
+ repl = input('Supersede the old requests? (y/n/c) ')
if repl.lower() == 'c':
print('Aborting', file=sys.stderr)
sys.exit(1)
@@ -2298,7 +2298,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif rq.state.name != "new" and rq.state.name != "review":
return 0
if rq.state.name == state_map[cmd]:
- repl = raw_input("\n *** The state of the request (#%s) is already '%s'. Change state anyway? [y/n] *** " % \
+ repl = input("\n *** The state of the request (#%s) is already '%s'. Change state anyway? [y/n] *** " % \
(reqid, rq.state.name))
if repl.lower() != 'y':
print('Aborted...', file=sys.stderr)
@@ -2364,7 +2364,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print(project, end=' ')
if package != action.tgt_package:
print("/", package, end=' ')
- repl = raw_input('\nForward this submit to it? ([y]/n)')
+ repl = input('\nForward this submit to it? ([y]/n)')
if repl.lower() == 'y' or repl == '':
(supersede, reqs) = check_existing_requests(apiurl, action.tgt_project, action.tgt_package,
project, package)
@@ -4403,7 +4403,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for pac in prj.pacs_have if prj.get_state(pac) == ' ')
can_branch = False
if any(pac.is_link_to_different_project() for pac in pacs):
- repl = raw_input('Some of the packages are links to a different project!\n' \
+ repl = input('Some of the packages are links to a different project!\n' \
'Create a local branch before commit? (y|N) ')
if repl in('y', 'Y'):
can_branch = True
@@ -4436,7 +4436,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not pac.todo:
pac.todo = pac.filenamelist + pac.filenamelist_unvers
pac.todo.sort()
- for prj_path, packages in prj_paths.items():
+ for prj_path, packages in list(prj_paths.items()):
prj = Project(prj_path)
if not msg and not opts.no_message:
msg = get_commit_msg(prj.absdir, pac_objs[prj_path])
@@ -4444,7 +4444,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# check any of the packages is a link, if so, as for branching
can_branch = False
if any(pac.is_link_to_different_project() for pac in pacs):
- repl = raw_input('Some of the packages are links to a different project!\n' \
+ repl = input('Some of the packages are links to a different project!\n' \
'Create a local branch before commit? (y|N) ')
if repl in('y', 'Y'):
can_branch = True
@@ -4745,7 +4745,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for filename in files:
if not opts.force:
- resp = raw_input("rm: remove source file `%s' from `%s/%s'? (yY|nN) " % (filename, project, package))
+ resp = input("rm: remove source file `%s' from `%s/%s'? (yY|nN) " % (filename, project, package))
if resp not in ('y', 'Y'):
continue
try:
@@ -6706,7 +6706,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
request_todo = {}
roles = {}
- if len(what.keys()) == 2:
+ if len(list(what.keys())) == 2:
for i in res.get('project_id', res.get('project', {})).findall('project'):
request_todo[i.get('name')] = []
roles[i.get('name')] = [p.get('role') for p in i.findall('person') if p.get('userid') == user]
@@ -6904,13 +6904,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# backward compatibility: local role filtering
if opts.limit_to_attribute:
role_filter_xpath = xpath_join(role_filter_xpath, 'attribute/@name=\'%s\'' % opts.limit_to_attribute, op='and')
- what = dict([[kind, role_filter_xpath] for kind in what.keys()])
+ what = dict([[kind, role_filter_xpath] for kind in list(what.keys())])
res = search(apiurl, **what)
filter_role(res, search_term, role_filter)
if role_filter:
role_filter = '%s (%s)' % (search_term, role_filter)
kind_map = {'published/binary/id': 'binary'}
- for kind, root in res.items():
+ for kind, root in list(res.items()):
results = []
for node in root.findall(kind_map.get(kind, kind)):
result = []
@@ -6983,7 +6983,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.binary:
headline.append('# filepath')
if not opts.csv:
- if len(what.keys()) > 1:
+ if len(list(what.keys())) > 1:
print('#' * 68)
print('matches for \'%s\' in %ss:\n' % (role_filter or search_term, kind))
for row in build_table(len(headline), results, headline, 2, csv = opts.csv):
@@ -7268,7 +7268,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if package:
print("/", package, end=' ')
print()
- repl = raw_input('\nCreating a request instead? (y/n) ')
+ repl = input('\nCreating a request instead? (y/n) ')
if repl.lower() == 'y':
opts.set_bugowner_request = bugowner
opts.set_bugowner = None
@@ -7328,7 +7328,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print("This is: " + result.get('project'), end=' ')
if result.get('package'):
print (" / " + result.get('package'))
- repl = raw_input('\nUse this container? (y/n) ')
+ repl = input('\nUse this container? (y/n) ')
if repl.lower() != 'y':
searchresult = None
else:
@@ -8191,7 +8191,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
import getpass
inp = getpass.getpass('Value: ').strip()
else:
- inp = raw_input('Value: ').strip()
+ inp = input('Value: ').strip()
if not inp:
raise oscerr.WrongArgs('error: no value was entered')
val = [inp]
@@ -8250,7 +8250,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
'Please choose one from the following list (enter the number):')
for i in range(len(apiurls)):
print(' %d) %s' % (i, apiurls[i]))
- num = raw_input('> ')
+ num = input('> ')
try:
num = int(num)
except ValueError:
diff --git a/osc/conf.py b/osc/conf.py
index 3ca6afb..3861f93 100644
--- a/osc/conf.py
+++ b/osc/conf.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or version 3 (at your option).
-from __future__ import print_function
+
"""Read osc configuration and store it in a dictionary
@@ -52,12 +52,13 @@ try:
from urllib.request import AbstractHTTPHandler, build_opener, proxy_bypass
except ImportError:
#python 2.x
- from cookielib import LWPCookieJar, CookieJar
- from httplib import HTTPConnection, HTTPResponse
- from StringIO import StringIO
- from urlparse import urlsplit
- from urllib2 import URLError, HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPPasswordMgrWithDefaultRealm, ProxyHandler
- from urllib2 import AbstractHTTPHandler, build_opener, proxy_bypass
+ from http.cookiejar import LWPCookieJar, CookieJar
+ from http.client import HTTPConnection, HTTPResponse
+ from io import StringIO
+ from urllib.parse import urlsplit
+ from urllib.error import URLError
+ from urllib.request import HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPPasswordMgrWithDefaultRealm, ProxyHandler
+ from urllib.request import build_opener
from . import OscConfigParser
from osc import oscerr
@@ -641,7 +642,7 @@ def config_set_option(section, opt, val=None, delete=False, update=True, **kwarg
"""
cp = get_configParser(config['conffile'])
# don't allow "internal" options
- general_opts = [i for i in DEFAULTS.keys() if not i in ['user', 'pass', 'passx']]
+ general_opts = [i for i in list(DEFAULTS.keys()) if not i in ['user', 'pass', 'passx']]
if section != 'general':
section = config['apiurl_aliases'].get(section, section)
scheme, host = \
diff --git a/osc/core.py b/osc/core.py
index bc714b3..692d9ae 100644
--- a/osc/core.py
+++ b/osc/core.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or version 3 (at your option).
-from __future__ import print_function
+
__version__ = '0.168'
@@ -31,11 +31,13 @@ try:
from io import StringIO
except ImportError:
#python 2.x
- from urlparse import urlsplit, urlunsplit, urlparse
- from urllib import pathname2url, quote_plus, urlencode, unquote
- from urllib2 import HTTPError, install_opener, urlopen
- from urllib2 import Request as URLRequest
- from cStringIO import StringIO
+ from urllib.parse import urlsplit, urlunsplit, urlparse
+ from urllib.request import pathname2url
+ from urllib.parse import quote_plus, urlencode, unquote
+ from urllib.error import HTTPError
+ from urllib.request import install_opener, urlopen
+ from urllib.request import Request as URLRequest
+ from io import StringIO
try:
@@ -48,7 +50,7 @@ from . import conf
try:
# python 2.6 and python 2.7
- unicode
+ str
ET_ENCODING = "utf-8"
# python 2.6 does not have bytes and python 2.7 reimplements it as alias to
# str, but in incompatible way as it does not accept the same arguments
@@ -56,7 +58,7 @@ try:
except:
#python3 does not have unicode, so lets reimplement it
#as void function as it already gets unicode strings
- unicode = lambda x, *args: x
+ str = lambda x, *args: x
ET_ENCODING = "unicode"
DISTURL_RE = re.compile(r"^(?P<bs>.*)://(?P<apiurl>.*?)/(?P<project>.*?)/(?P<repository>.*?)/(?P<revision>.*)-(?P<source>.*)$")
@@ -2017,7 +2019,7 @@ rev: %s
print('*' * 36, 'new', '*' * 36)
print(ET.tostring(root, encoding=ET_ENCODING))
print('*' * 72)
- repl = raw_input('Write? (y/N/e) ')
+ repl = input('Write? (y/N/e) ')
else:
repl = 'y'
@@ -2523,10 +2525,10 @@ class Action:
prefix_to_elm = {'src': 'source', 'tgt': 'target', 'opt': 'options'}
def __init__(self, type, **kwargs):
- if not type in Action.type_args.keys():
+ if not type in list(Action.type_args.keys()):
raise oscerr.WrongArgs('invalid action type: \'%s\'' % type)
self.type = type
- for i in kwargs.keys():
+ for i in list(kwargs.keys()):
if not i in Action.type_args[type]:
raise oscerr.WrongArgs('invalid argument: \'%s\'' % i)
# set all type specific attributes
@@ -2577,17 +2579,17 @@ class Action:
def from_xml(action_node):
"""create action from XML"""
if action_node is None or \
- not action_node.get('type') in Action.type_args.keys() or \
+ not action_node.get('type') in list(Action.type_args.keys()) or \
not action_node.tag in ('action', 'submit'):
raise oscerr.WrongArgs('invalid argument')
- elm_to_prefix = dict([(i[1], i[0]) for i in Action.prefix_to_elm.items()])
+ elm_to_prefix = dict([(i[1], i[0]) for i in list(Action.prefix_to_elm.items())])
kwargs = {}
for node in action_node:
prefix = elm_to_prefix.get(node.tag, node.tag)
if prefix == 'opt':
data = [('opt_%s' % opt.tag, opt.text.strip()) for opt in node if opt.text]
else:
- data = [('%s_%s' % (prefix, k), v) for k, v in node.items()]
+ data = [('%s_%s' % (prefix, k), v) for k, v in list(node.items())]
# it would be easier to store everything in a list but in
# this case we would lose some "structure" (see to_xml)
for k, v in data:
@@ -3160,7 +3162,7 @@ def http_request(method, url, headers={}, data=None, file=None):
req.add_header('Content-Type', 'application/octet-stream')
if isinstance(headers, type({})):
- for i in headers.keys():
+ for i in list(headers.keys()):
print(headers[i])
req.add_header(i, headers[i])
@@ -3478,7 +3480,7 @@ class metafile:
data = e.read()
if '<summary>' in data:
print(data.split('<summary>')[1].split('</summary>')[0], file=sys.stderr)
- ri = raw_input('Try again? ([y/N]): ')
+ ri = input('Try again? ([y/N]): ')
if ri not in ['y', 'Y']:
break
finally:
@@ -3540,7 +3542,7 @@ def meta_exists(metatype,
def make_meta_url(metatype, path_args=None, apiurl=None, force=False, remove_linking_repositories=False):
if not apiurl:
apiurl = conf.config['apiurl']
- if metatype not in metatypes.keys():
+ if metatype not in list(metatypes.keys()):
raise AttributeError('make_meta_url(): Unknown meta type \'%s\'' % metatype)
path = metatypes[metatype]['path']
@@ -3662,7 +3664,7 @@ def show_project_sourceinfo(apiurl, project, nofilename, *packages):
def get_project_sourceinfo(apiurl, project, nofilename, *packages):
try:
si = show_project_sourceinfo(apiurl, project, nofilename, *packages)
- except HTTPError, e:
+ except HTTPError as e:
if e.code != 414:
raise
if len(packages) == 1:
@@ -3863,7 +3865,7 @@ def edit_text(data='', delim=None, suffix='.txt', template=''):
reason = 'Log message not specified'
if template == msg:
reason = 'Default log message was not changed. Press \'c\' to continue.'
- ri = raw_input('%s\na)bort, c)ontinue, e)dit: ' % reason)
+ ri = input('%s\na)bort, c)ontinue, e)dit: ' % reason)
if ri in 'aA':
raise oscerr.UserAbort()
elif ri in 'cC':
@@ -3894,7 +3896,7 @@ def create_release_request(apiurl, src_project, message=''):
# api will complete the request
r.add_action('maintenance_release', src_project=src_project)
# XXX: clarify why we need the unicode(...) stuff
- r.description = cgi.escape(unicode(message, 'utf8'))
+ r.description = cgi.escape(str(message, 'utf8'))
r.create(apiurl)
return r
@@ -3908,7 +3910,7 @@ def create_maintenance_request(apiurl, src_project, src_packages, tgt_project, t
else:
r.add_action('maintenance_incident', src_project=src_project, tgt_project=tgt_project, tgt_releaseproject=tgt_releaseproject, opt_sourceupdate = opt_sourceupdate)
# XXX: clarify why we need the unicode(...) stuff
- r.description = cgi.escape(unicode(message, 'utf8'))
+ r.description = cgi.escape(str(message, 'utf8'))
r.create(apiurl, addrevision=True)
return r
@@ -4088,7 +4090,7 @@ def get_review_list(apiurl, project='', package='', byuser='', bygroup='', bypro
todo['project'] = project
if package:
todo['package'] = package
- for kind, val in todo.items():
+ for kind, val in list(todo.items()):
xpath_base = 'action/target/@%(kind)s=\'%(val)s\' or ' \
'submit/target/@%(kind)s=\'%(val)s\''
@@ -4154,7 +4156,7 @@ def get_request_list(apiurl, project='', package='', req_who='', req_state=('new
todo['project'] = project
if package:
todo['package'] = package
- for kind, val in todo.items():
+ for kind, val in list(todo.items()):
xpath_base = 'action/target/@%(kind)s=\'%(val)s\' or ' \
'submit/target/@%(kind)s=\'%(val)s\''
@@ -4194,7 +4196,7 @@ def get_user_projpkgs_request_list(apiurl, user, req_state=('new', 'review', ),
if not i.get('project') in projects:
projpkgs.setdefault(i.get('project'), []).append(i.get('name'))
xpath = ''
- for prj, pacs in projpkgs.items():
+ for prj, pacs in list(projpkgs.items()):
if not len(pacs):
xpath = xpath_join(xpath, 'action/target/@project=\'%s\'' % prj, inner=True)
else:
@@ -4244,7 +4246,7 @@ def check_existing_requests(apiurl, src_project, src_package, dst_project,
if reqs:
print('There are already the following submit request: %s.' % \
', '.join([i.reqid for i in reqs]))
- repl = raw_input('Supersede the old requests? (y/n/c) ')
+ repl = input('Supersede the old requests? (y/n/c) ')
if repl.lower() == 'c':
print('Aborting', file=sys.stderr)
raise oscerr.UserAbort()
@@ -4860,7 +4862,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
aggregate_template += """\
<nosources />
"""
- for src, tgt in repo_map.items():
+ for src, tgt in list(repo_map.items()):
aggregate_template += """\
<repository target="%s" source="%s" />
""" % (tgt, src)
@@ -5404,17 +5406,17 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
#filtering for Package Status
if status_filter:
- if status_filter in buildstatus_symbols.values():
+ if status_filter in list(buildstatus_symbols.values()):
# a list is needed because if status_filter == "U"
# we have to filter either an "expansion error" (obsolete)
# or an "unresolvable" state
filters = []
- for txt, sym in buildstatus_symbols.items():
+ for txt, sym in list(buildstatus_symbols.items()):
if sym == status_filter:
filters.append(txt)
for filt_txt in filters:
- for pkg in status.keys():
- for repo in status[pkg].keys():
+ for pkg in list(status.keys()):
+ for repo in list(status[pkg].keys()):
if status[pkg][repo] == filt_txt:
if not name_filter:
pacs_to_show.append(pkg)
@@ -5431,9 +5433,9 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
#filter non building states
elif not show_excluded:
enabled = {}
- for pkg in status.keys():
+ for pkg in list(status.keys()):
showpkg = False
- for repo in status[pkg].keys():
+ for repo in list(status[pkg].keys()):
if status[pkg][repo] != "excluded":
enabled[repo] = 1
showpkg = True
@@ -5441,7 +5443,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
if showpkg:
pacs_to_show.append(pkg)
- targets_to_show = enabled.keys()
+ targets_to_show = list(enabled.keys())
pacs = [ i for i in pacs if i in pacs_to_show ]
if len(targets_to_show):
@@ -5525,7 +5527,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
if not hide_legend and len(pacs):
r.append(' Legend:')
legend = []
- for i, j in buildstatus_symbols.items():
+ for i, j in list(buildstatus_symbols.items()):
if i == "expansion error":
continue
legend.append('%3s %-20s' % (j, i))
@@ -5701,7 +5703,7 @@ def get_source_rev(apiurl, project, package, revision=None):
if not ent:
return { 'version': None, 'error': 'empty revisionlist: no such package?' }
e = {}
- for k in ent.keys():
+ for k in list(ent.keys()):
e[k] = ent.get(k)
for k in list(ent):
e[k.tag] = k.text
@@ -6155,7 +6157,7 @@ def search(apiurl, **kwargs):
GET /search/kindN?match=xpathN
"""
res = {}
- for urlpath, xpath in kwargs.items():
+ for urlpath, xpath in list(kwargs.items()):
path = [ 'search' ]
path += urlpath.split('_') # FIXME: take underscores as path seperators. I see no other way atm to fix OBS api calls and not breaking osc api
u = makeurl(apiurl, path, ['match=%s' % quote_plus(xpath)])
@@ -6216,9 +6218,9 @@ def _set_link_rev(apiurl, project, package, root, revision='', expand=False):
src_package = root.get('package', package)
vrev = None
if revision is None:
- if 'rev' in root.keys():
+ if 'rev' in list(root.keys()):
del root.attrib['rev']
- if 'vrev' in root.keys():
+ if 'vrev' in list(root.keys()):
del root.attrib['vrev']
elif not revision or expand:
revision, vrev = show_upstream_rev_vrev(apiurl, src_project, src_package, revision=revision, expand=expand)
@@ -6415,12 +6417,12 @@ def setDevelProject(apiurl, prj, pac, dprj, dpkg=None):
if dprj:
elem.set('project', dprj)
else:
- if 'project' in elem.keys():
+ if 'project' in list(elem.keys()):
del elem.attrib['project']
if dpkg:
elem.set('package', dpkg)
else:
- if 'package' in elem.keys():
+ if 'package' in list(elem.keys()):
del elem.attrib['package']
edit_meta(metatype='pkg',
path_args=path,
@@ -6730,7 +6732,7 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None, igno
repl = initial_cmd
initial_cmd = ''
else:
- repl = raw_input(prompt).strip()
+ repl = input(prompt).strip()
if repl == 'i' and src_actions:
if not orequest is None and tmpfile:
tmpfile.close()
@@ -6805,7 +6807,7 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None, igno
if not safe_change_request_state(apiurl, request.reqid, 'accepted', msg, force=force):
# an error occured
continue
- repl = raw_input('Supersede original request? (y|N) ')
+ repl = input('Supersede original request? (y|N) ')
if repl in ('y', 'Y'):
safe_change_request_state(apiurl, orequest.reqid, 'superseded',
'superseded by %s' % request.reqid, request.reqid, force=force)
@@ -6828,7 +6830,7 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None, igno
for i in range(len(reviews)):
fmt = Request.format_review(reviews[i])
print('(%i)' % i, 'by %(type)-10s %(by)s' % fmt)
- num = raw_input('> ')
+ num = input('> ')
try:
num = int(num)
except ValueError:
@@ -6861,7 +6863,7 @@ def edit_submitrequest(apiurl, project, orequest, new_request=None):
# of a submit action does not need instance specific data
fmt = orequest.format_action(actions[i])
print('(%i)' % i, '%(source)s %(target)s' % fmt)
- num = raw_input('> ')
+ num = input('> ')
try:
num = int(num)
except ValueError:
@@ -6893,7 +6895,7 @@ def edit_submitrequest(apiurl, project, orequest, new_request=None):
if modified:
print('Your working copy has the following modifications:')
print('\n'.join([statfrmt(st, filename) for st, filename in modified]))
- repl = raw_input('Do you want to commit the local changes first? (y|N) ')
+ repl = input('Do you want to commit the local changes first? (y|N) ')
if repl in ('y', 'Y'):
msg = get_commit_msg(p.absdir, [p])
p.commit(msg=msg)
@@ -6949,7 +6951,7 @@ def get_user_projpkgs(apiurl, user, role=None, exclude_projects=[], proj=True, p
if e.code != 400 or not role_filter_xpath:
raise e
# backward compatibility: local role filtering
- what = dict([[kind, role_filter_xpath] for kind in what.keys()])
+ what = dict([[kind, role_filter_xpath] for kind in list(what.keys())])
if 'package' in what:
what['package'] = xpath_join(role_filter_xpath, excl_pkg, op='and')
if 'project' in what:
@@ -6964,8 +6966,8 @@ def raw_input(*args):
func = builtins.input
except ImportError:
#python 2.7
- import __builtin__
- func = __builtin__.raw_input
+ import builtins
+ func = builtins.raw_input
try:
return func(*args)
@@ -7004,7 +7006,7 @@ def filter_role(meta, user, role):
remove all project/package nodes if no person node exists
where @userid=user and @role=role
"""
- for kind, root in meta.items():
+ for kind, root in list(meta.items()):
delete = []
for node in root.findall(kind):
found = False
diff --git a/osc/fetch.py b/osc/fetch.py
index d9ea365..d6dea61 100644
--- a/osc/fetch.py
+++ b/osc/fetch.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
-from __future__ import print_function
+
import sys, os
@@ -12,8 +12,9 @@ try:
from urllib.request import HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPPasswordMgrWithDefaultRealm, HTTPError
except ImportError:
#python 2.x
- from urllib import quote_plus
- from urllib2 import HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPPasswordMgrWithDefaultRealm, HTTPError
+ from urllib.parse import quote_plus
+ from urllib.request import HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPPasswordMgrWithDefaultRealm
+ from urllib.error import HTTPError
from urlgrabber.grabber import URLGrabber, URLGrabError
from urlgrabber.mirror import MirrorGroup
@@ -146,7 +147,7 @@ class Fetcher:
if os.path.exists(tmpfile):
os.unlink(tmpfile)
- for pac in pkgs.values():
+ for pac in list(pkgs.values()):
if not os.path.isfile(pac.fullfilename):
raise oscerr.APIError('failed to fetch file \'%s\': '
'missing in CPIO archive' %
@@ -168,7 +169,7 @@ class Fetcher:
package, **new_pkgs)
def __fetch_cpio(self, apiurl):
- for prpap, pkgs in self.cpio.items():
+ for prpap, pkgs in list(self.cpio.items()):
project, repo, arch, package = prpap.split('/', 3)
self.__download_cpio_archive(apiurl, project, repo, arch, package, **pkgs)
diff --git a/osc/meter.py b/osc/meter.py
index f24b18d..e98f648 100644
--- a/osc/meter.py
+++ b/osc/meter.py
@@ -19,7 +19,7 @@
# it uses getScreenWidth() scrapped from smart.
# 2007-04-24, poeml
-from __future__ import print_function
+
from urlgrabber.progress import BaseMeter, format_time, format_number
import sys, os
diff --git a/osc/oscssl.py b/osc/oscssl.py
index 325e1ab..7681092 100644
--- a/osc/oscssl.py
+++ b/osc/oscssl.py
@@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
-from __future__ import print_function
+
import M2Crypto.httpslib
from M2Crypto.SSL.Checker import SSLVerificationError
@@ -18,9 +18,9 @@ try:
from http.client import HTTPSConnection
except ImportError:
#python 2.x
- from urlparse import urlparse
- from urllib import addinfourl, splithost, splitport, splittype
- from httplib import HTTPSConnection
+ from urllib.parse import urlparse
+ from urllib.parse import splithost, splitport, splittype
+ from http.client import HTTPSConnection
from .core import raw_input
@@ -117,7 +117,7 @@ class ValidationErrors:
self.failures[depth].errs.append(err)
def show(self, out):
- for depth in self.failures.keys():
+ for depth in list(self.failures.keys()):
cert = self.failures[depth].cert
print("*** certificate verify failed at depth %d" % depth, file=out)
print("Subject: ", cert.get_subject(), file=out)
@@ -351,7 +351,7 @@ Would you like to
""", file=out)
print("Enter choice [0129]: ", end='', file=out)
- r = raw_input()
+ r = input()
if not r or r == '0':
connection.close()
raise SSLVerificationError("Untrusted Certificate")
diff --git a/osc/util/ar.py b/osc/util/ar.py
index 6eeb05f..a99eb3d 100644
--- a/osc/util/ar.py
+++ b/osc/util/ar.py
@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-from __future__ import print_function
+
import os
import re
@@ -23,7 +23,7 @@ import stat
#XXX: python 2.7 contains io.StringIO, which needs unicode instead of str
#therefor try to import old stuff before new one here
try:
- from StringIO import StringIO
+ from io import StringIO
except ImportError:
from io import StringIO
diff --git a/osc/util/archquery.py b/osc/util/archquery.py
index 2af87de..d89903e 100644
--- a/osc/util/archquery.py
+++ b/osc/util/archquery.py
@@ -1,5 +1,5 @@
-from __future__ import print_function
+
import os.path
import re
diff --git a/osc/util/cpio.py b/osc/util/cpio.py
index cd3c406..795e01a 100644
--- a/osc/util/cpio.py
+++ b/osc/util/cpio.py
@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-from __future__ import print_function
+
import mmap
import os
@@ -64,7 +64,7 @@ class CpioHdr:
self.namesize = namesize
# != 0 indicates CRC format (which we do not support atm)
self.checksum = checksum
- for k, v in self.__dict__.items():
+ for k, v in list(self.__dict__.items()):
self.__dict__[k] = int(v, 16)
self.filename = filename
# data starts at dataoff and ends at dataoff+filesize
@@ -162,7 +162,7 @@ class CpioRead:
self._init_datastructs()
data = self.__file.read(6)
self.format = data
- if not self.format in self.sfmt.values():
+ if not self.format in list(self.sfmt.values()):
raise CpioError(self.filename, '\'%s\' is not a supported cpio format' % self.format)
pos = 0
while (len(data) != 0):
diff --git a/osc/util/debquery.py b/osc/util/debquery.py
index 4b1a823..0c63983 100644
--- a/osc/util/debquery.py
+++ b/osc/util/debquery.py
@@ -1,5 +1,5 @@
-from __future__ import print_function
+
from . import ar
import os.path
@@ -144,7 +144,7 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
# (found this nice approach in Build/Deb.pm (build package))
ver1 = re.sub('(\d+)', lambda m: (32 * '0' + m.group(1))[-32:], ver1)
ver2 = re.sub('(\d+)', lambda m: (32 * '0' + m.group(1))[-32:], ver2)
- vers = map(lambda x, y: (x or '', y or ''), ver1, ver2)
+ vers = list(map(lambda x, y: (x or '', y or ''), ver1, ver2))
for v1, v2 in vers:
if v1 == v2:
continue
diff --git a/osc/util/packagequery.py b/osc/util/packagequery.py
index e8e0c98..3db72cc 100644
--- a/osc/util/packagequery.py
+++ b/osc/util/packagequery.py
@@ -1,5 +1,5 @@
-from __future__ import print_function
+
class PackageError(Exception):
"""base class for all package related errors"""
diff --git a/osc/util/rpmquery.py b/osc/util/rpmquery.py
index f1dc06b..3543b6e 100644
--- a/osc/util/rpmquery.py
+++ b/osc/util/rpmquery.py
@@ -1,5 +1,5 @@
-from __future__ import print_function
+
import os
import re
diff --git a/osc_hotshot.py b/osc_hotshot.py
index 54ac40f..8200d7b 100755
--- a/osc_hotshot.py
+++ b/osc_hotshot.py
@@ -17,7 +17,7 @@ if __name__ == '__main__':
prof = hotshot.Profile(filename)
prof.runcall(commandline.main)
- print 'run complete. analyzing.'
+ print('run complete. analyzing.')
prof.close()
stats = hotshot.stats.load(filename)
diff --git a/packaging/osc.spec b/packaging/osc.spec
index 7ed12b2..02242d3 100644
--- a/packaging/osc.spec
+++ b/packaging/osc.spec
@@ -1,4 +1,4 @@
-%{!?python_sitelib: %define python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%{!?python_sitelib: %define python_sitelib %(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')}
Name: osc
Summary: OpenSUSE Build Service Commander
@@ -10,18 +10,18 @@ Url: http://www.gitorious.org/opensuse/osc
Source: osc-%{version}.tar.gz
BuildArch: noarch
-BuildRequires: python-devel
-BuildRequires: python-urlgrabber
-Requires: python-urlgrabber
-Requires: python-keyring
-Requires: python-gobject
-Requires: python-rpm
+BuildRequires: python3-devel
+BuildRequires: python3-urlgrabber
+Requires: python3-urlgrabber
+Requires: python3-keyring
+Requires: python3-gobject
+Requires: python3-rpm
%if 0%{?suse_version} || "0%{?tizen_version}" != "0"
-BuildRequires: python-m2crypto
-Requires: python-m2crypto > 0.19
-BuildRequires: python-xml
-Requires: python-xml
+BuildRequires: python3-m2crypto
+Requires: python3-m2crypto > 0.19
+BuildRequires: python3-xml
+Requires: python3-xml
%else
BuildRequires: m2crypto
Requires: m2crypto > 0.19
@@ -45,10 +45,10 @@ introduction.
%build
CFLAGS="%{optflags}" \
-%{__python} setup.py build
+python3 setup.py build
%install
-%{__python} setup.py install --prefix=%{_prefix} --root %{buildroot}
+python3 setup.py install --prefix=%{_prefix} --root %{buildroot}
ln -s osc-wrapper.py %{buildroot}/%{_bindir}/osc
mkdir -p %{buildroot}/var/lib/osc-plugins
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
diff --git a/tests/common.py b/tests/common.py
index 7ed9bc8..869b154 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -12,9 +12,9 @@ if sys.version_info[0:2] in ((2, 6), (2, 7)):
try:
#python 2.x
- from cStringIO import StringIO
- from urllib2 import HTTPHandler, addinfourl, build_opener
- from urlparse import urlparse, parse_qs
+ from io import StringIO
+ from urllib.request import HTTPHandler, build_opener
+ from urllib.parse import urlparse, parse_qs
except ImportError:
from io import StringIO
from urllib.request import HTTPHandler, addinfourl, build_opener #pylint: disable=no-name-in-module,import-error
diff --git a/tests/test_commit.py b/tests/test_commit.py
index 2636fca..325994b 100644
--- a/tests/test_commit.py
+++ b/tests/test_commit.py
@@ -2,7 +2,7 @@ import osc.core
import osc.oscerr
import os
import sys
-import urllib2
+import urllib.request, urllib.error, urllib.parse
from common import GET, PUT, POST, DELETE, OscTestCase
from xml.etree import cElementTree as ET
#FIXTURES_DIR = os.path.join(os.getcwd(), 'commit_fixtures')
@@ -303,7 +303,7 @@ class TestCommit(OscTestCase):
self._change_to_pkg('simple')
p = osc.core.Package('.')
self._check_status(p, 'nochange', 'M')
- self.assertRaises(urllib2.HTTPError, p.commit)
+ self.assertRaises(urllib.error.HTTPError, p.commit)
exp = 'Sending nochange\nTransmitting file data .'
self.assertEqual(sys.stdout.getvalue(), exp)
self._check_status(p, 'nochange', 'M')
diff --git a/tests/test_repairwc.py b/tests/test_repairwc.py
index a7735c0..db4b331 100644
--- a/tests/test_repairwc.py
+++ b/tests/test_repairwc.py
@@ -206,7 +206,7 @@ class TestRepairWC(OscTestCase):
try:
from urllib.error import URLError
except ImportError:
- from urllib2 import URLError
+ from urllib.error import URLError
self._change_to_pkg('invalid_apiurl')
p = osc.core.Package('.', wc_check=False)
self.assertRaises(URLError, p.wc_repair, 'http:/localhost')
@@ -252,7 +252,7 @@ class TestRepairWC(OscTestCase):
try:
from urllib.error import URLError
except ImportError:
- from urllib2 import URLError
+ from urllib.error import URLError
prj_dir = os.path.join(self.tmpdir, 'prj_invalidapiurl')
shutil.copytree(os.path.join(self._get_fixtures_dir(), 'prj_invalidapiurl'), prj_dir)
storedir = os.path.join(prj_dir, osc.core.store)
diff --git a/tests/test_setlinkrev.py b/tests/test_setlinkrev.py
index da699e0..7f56151 100644
--- a/tests/test_setlinkrev.py
+++ b/tests/test_setlinkrev.py
@@ -64,7 +64,7 @@ class TestSetLinkRev(OscTestCase):
try:
from urllib.error import HTTPError
except ImportError:
- from urllib2 import HTTPError
+ from urllib.error import HTTPError
# the backend returns status 400 if we try to expand a broken _link
self.assertRaises(HTTPError, osc.core.set_link_rev, 'http://localhost', 'osctest', 'simple', expand=True)