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
#!/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
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (c) 2008-2009 Pavol Rusnak <prusnak@suse.cz>
#
# 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
import configparser
else:
#python 2.x
- import ConfigParser as configparser
+ import configparser as configparser
import re
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' ]
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!
# 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
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
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))
# 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
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 *
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
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)
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.
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)
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)
-from __future__ import print_function
+
from tempfile import mkdtemp
import os
# 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.
# 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):
#---- 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")
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:
"${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
# 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)
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:
# 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
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
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'
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:
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))
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 ]
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:
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:
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)
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)
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)
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
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])
# 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
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:
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]
# 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 = []
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):
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
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:
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]
'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:
# 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
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
"""
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 = \
# 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'
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:
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
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>.*)$")
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'
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
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:
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])
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:
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']
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:
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':
# 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
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
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\''
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\''
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:
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()
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)
#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)
#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
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):
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))
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
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)])
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)
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,
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()
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)
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:
# 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:
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)
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:
func = builtins.input
except ImportError:
#python 2.7
- import __builtin__
- func = __builtin__.raw_input
+ import builtins
+ func = builtins.raw_input
try:
return func(*args)
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
# 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
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
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' %
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)
# 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
# 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
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
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)
""", 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")
# 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
#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
-from __future__ import print_function
+
import os.path
import re
# 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
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
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):
-from __future__ import print_function
+
from . import ar
import os.path
# (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
-from __future__ import print_function
+
class PackageError(Exception):
"""base class for all package related errors"""
-from __future__ import print_function
+
import os
import re
prof = hotshot.Profile(filename)
prof.runcall(commandline.main)
- print 'run complete. analyzing.'
+ print('run complete. analyzing.')
prof.close()
stats = hotshot.stats.load(filename)
-%{!?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
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
%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
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
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')
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')
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')
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)
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)