More porting to python3
Travis changed default python to 3.6, which has impact on the way flake8 checks. So make sure we run fine under flake8 of python 3
This commit is contained in:
parent
0016e77e71
commit
595e84191e
@ -36,6 +36,12 @@ except ImportError:
|
||||
# python 2.x
|
||||
from urllib2 import HTTPError, URLError
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
input = getattr(__builtin__, 'raw_input')
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
from itertools import count
|
||||
|
||||
class PackageLookup(object):
|
||||
@ -867,7 +873,7 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
self.logger.info("sleeping %d minutes. Press enter to check now ..."%interval)
|
||||
signal.alarm(interval*60)
|
||||
try:
|
||||
raw_input()
|
||||
input()
|
||||
except ExTimeout:
|
||||
pass
|
||||
signal.alarm(0)
|
||||
|
10
ToolBase.py
10
ToolBase.py
@ -29,11 +29,17 @@ http_GET = osc.core.http_GET
|
||||
http_DELETE = osc.core.http_DELETE
|
||||
http_POST = osc.core.http_POST
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
input = getattr(__builtin__, 'raw_input')
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
# http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
|
||||
def chunks(l, n):
|
||||
""" Yield successive n-sized chunks from l.
|
||||
"""
|
||||
for i in xrange(0, len(l), n):
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i:i+n]
|
||||
|
||||
class ToolBase(object):
|
||||
@ -190,7 +196,7 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
logger.info("sleeping %d minutes. Press enter to check now ..."%interval)
|
||||
signal.alarm(interval*60)
|
||||
try:
|
||||
raw_input()
|
||||
input()
|
||||
except ExTimeout:
|
||||
pass
|
||||
signal.alarm(0)
|
||||
|
@ -138,13 +138,13 @@ class CompareList(object):
|
||||
return
|
||||
|
||||
# get souce packages from target
|
||||
print 'Gathering the package list from %s' % self.old_prj
|
||||
print('Gathering the package list from %s' % self.old_prj)
|
||||
source = self.get_source_packages(self.old_prj)
|
||||
print 'Gathering the package list from %s' % self.new_prj
|
||||
print('Gathering the package list from %s' % self.new_prj)
|
||||
target = self.get_source_packages(self.new_prj)
|
||||
removed_packages = self.removed_pkglist(self.old_prj)
|
||||
if self.existin:
|
||||
print 'Gathering the package list from %s' % self.existin
|
||||
print('Gathering the package list from %s' % self.existin)
|
||||
existin_packages = self.get_source_packages(self.existin)
|
||||
|
||||
if not self.removedonly:
|
||||
|
@ -88,7 +88,7 @@ class DepTool(cmdln.Cmdln):
|
||||
if parser.has_option(name, 'priority'):
|
||||
repo.priority = parser.getint(name, 'priority')
|
||||
logger.debug("add repo %s" % name)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
def _add_system_repo(self):
|
||||
|
@ -67,7 +67,7 @@ logging.basicConfig(level=logging.DEBUG if options.debug
|
||||
format='%(asctime)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s')
|
||||
|
||||
if options.dump_config:
|
||||
print yaml.dump(config_defaults, default_flow_style=False)
|
||||
print(yaml.dump(config_defaults, default_flow_style=False))
|
||||
sys.exit(0)
|
||||
|
||||
config = _load_config(options.config)
|
||||
@ -145,8 +145,8 @@ msg['Date'] = email.utils.formatdate(localtime=1)
|
||||
msg['Message-ID'] = email.utils.make_msgid()
|
||||
|
||||
if options.dry:
|
||||
print "sending ..."
|
||||
print msg.as_string()
|
||||
print("sending ...")
|
||||
print(msg.as_string())
|
||||
else:
|
||||
logger.info("announcing version {}".format(version))
|
||||
s = smtplib.SMTP(options.relay)
|
||||
|
@ -35,13 +35,13 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
h = None
|
||||
try:
|
||||
h = self.ts.hdrFromFdno(fd)
|
||||
except rpm.error, e:
|
||||
except rpm.error as e:
|
||||
if str(e) == "public key not available":
|
||||
print str(e)
|
||||
print(str(e))
|
||||
if str(e) == "public key not trusted":
|
||||
print str(e)
|
||||
print(str(e))
|
||||
if str(e) == "error reading package header":
|
||||
print str(e)
|
||||
print(str(e))
|
||||
h = None
|
||||
return h
|
||||
|
||||
@ -78,7 +78,7 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
):
|
||||
srpm = '%s-%s-%s.src.rpm'%('kernel-source', m.group('version'), m.group('release'))
|
||||
pkgdata[h['name']]['sourcerpm'] = srpm
|
||||
print "%s -> %s"%(h['sourcerpm'], srpm)
|
||||
print("%s -> %s"%(h['sourcerpm'], srpm))
|
||||
|
||||
if srpm in changelogs:
|
||||
changelogs[srpm]['packages'].append(h['name'])
|
||||
@ -204,7 +204,7 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
p1 = set(v1pkgs.keys())
|
||||
p2 = set(v2pkgs.keys())
|
||||
|
||||
print "Packages changed:"
|
||||
print('Packages changed:')
|
||||
group = self._get_packages_grouped(v2pkgs, p1&p2)
|
||||
# pprint(p1&p2)
|
||||
# pprint(group)
|
||||
@ -218,7 +218,7 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
try:
|
||||
t1 = v1changelogs[srpm1]['changelogtime'][0]
|
||||
except IndexError:
|
||||
print >>sys.stderr, srpm1, "doesn't have a changelog"
|
||||
print("{} doesn't have a changelog".format(srpm1), file=sys.stderr)
|
||||
continue
|
||||
m = SRPM_RE.match(srpm)
|
||||
if m:
|
||||
@ -226,17 +226,17 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
else:
|
||||
name = srpm
|
||||
if len(v2changelogs[srpm]['changelogtime']) == 0:
|
||||
print " %s ERROR: no changelog"%name
|
||||
print(' {} ERROR: no changelog'.format(name))
|
||||
continue
|
||||
if t1 == v2changelogs[srpm]['changelogtime'][0]:
|
||||
continue # no new changelog entry, probably just rebuilt
|
||||
pkgs = sorted(group[srpm])
|
||||
details += "\n==== %s ====\n"%name
|
||||
if v1pkgs[pkgs[0]]['version'] != v2pkgs[pkgs[0]]['version']:
|
||||
print " %s (%s -> %s)"%(name, v1pkgs[pkgs[0]]['version'], v2pkgs[pkgs[0]]['version'])
|
||||
print(" %s (%s -> %s)"%(name, v1pkgs[pkgs[0]]['version'], v2pkgs[pkgs[0]]['version']))
|
||||
details += "Version update (%s -> %s)\n" % (v1pkgs[pkgs[0]]['version'], v2pkgs[pkgs[0]]['version'])
|
||||
else:
|
||||
print " %s"%name
|
||||
print(" %s" % name)
|
||||
if len(pkgs) > 1:
|
||||
details += "Subpackages: %s\n"%" ".join([p for p in pkgs if p != name])
|
||||
for (i2, t2) in enumerate(v2changelogs[srpm]['changelogtime']):
|
||||
@ -245,8 +245,8 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
details += "\n" + v2changelogs[srpm]['changelogtext'][i2]
|
||||
details += '\n'
|
||||
|
||||
print "\n=== Details ==="
|
||||
print details
|
||||
print("\n=== Details ===")
|
||||
print(details)
|
||||
|
||||
def get_optparser(self):
|
||||
parser = cmdln.CmdlnOptionParser(self)
|
||||
@ -266,4 +266,3 @@ class ChangeLogger(cmdln.Cmdln):
|
||||
if __name__ == "__main__":
|
||||
app = ChangeLogger()
|
||||
sys.exit( app.main() )
|
||||
|
||||
|
@ -266,13 +266,13 @@ class FccSubmitter(object):
|
||||
logging.info('No build succeeded package in %s'%self.from_prj)
|
||||
return
|
||||
|
||||
print 'Build succeeded packages:'
|
||||
print '-------------------------------------'
|
||||
print('Build succeeded packages:')
|
||||
print('-------------------------------------')
|
||||
for pkg in succeeded_packages:
|
||||
print pkg
|
||||
print(pkg)
|
||||
|
||||
print '-------------------------------------'
|
||||
print "Found {} build succeded packages".format(len(succeeded_packages))
|
||||
print('-------------------------------------')
|
||||
print("Found {} build succeded packages".format(len(succeeded_packages)))
|
||||
|
||||
def get_deleted_packages(self, project):
|
||||
query = 'states=accepted&types=delete&project={}&view=collection'
|
||||
@ -403,9 +403,9 @@ class FccSubmitter(object):
|
||||
print("Multi-specfile packages:")
|
||||
if ms_packages:
|
||||
for pkg in ms_packages:
|
||||
print pkg
|
||||
print(pkg)
|
||||
else:
|
||||
print 'None'
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
@ -415,7 +415,7 @@ def main(args):
|
||||
osc.conf.config['debug'] = args.debug
|
||||
|
||||
if args.freeze:
|
||||
print "freezing {}".format(FCC)
|
||||
print('freezing {}'.format(FCC))
|
||||
freezer = FccFreezer()
|
||||
freezer.freeze()
|
||||
else:
|
||||
|
@ -26,6 +26,12 @@ from osclib.core import package_list
|
||||
from osclib.git import CACHE_DIR
|
||||
from osclib.git import sync
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
input = getattr(__builtin__, 'raw_input')
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
# Issue summary can contain unicode characters and therefore a string containing
|
||||
# either summary or one in which ISSUE_SUMMARY is then placed must be unicode.
|
||||
# For example, translation-update-upstream contains bsc#877707 which has a
|
||||
@ -106,7 +112,7 @@ def prompt_continue(change_count):
|
||||
else:
|
||||
print('No changes for which to create bug, continue? [y/b/s/n/?] (y): ', end='')
|
||||
|
||||
response = raw_input().lower()
|
||||
response = input().lower()
|
||||
if response == '?':
|
||||
print('b = break; file bug if applicable, record in db, and stop\ns = skip package')
|
||||
elif response in allowed:
|
||||
|
@ -7,6 +7,12 @@ from osclib.cache_manager import CacheManager
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
input = getattr(__builtin__, 'raw_input')
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
CACHE_DIR = CacheManager.directory('k8s-secret')
|
||||
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@ -15,10 +21,10 @@ def secret_create(cache_file):
|
||||
environment = {'OSCRC': cache_file}
|
||||
|
||||
print('Username: ', end='')
|
||||
environment['OBS_USER'] = raw_input()
|
||||
environment['OBS_USER'] = input()
|
||||
|
||||
print('Password: ', end='')
|
||||
environment['OBS_PASS'] = raw_input()
|
||||
environment['OBS_PASS'] = input()
|
||||
|
||||
osc_init = os.path.join(SCRIPT_PATH, 'dist/ci/osc-init')
|
||||
subprocess.Popen([osc_init], env=environment).wait()
|
||||
@ -37,7 +43,7 @@ def main(args):
|
||||
print(f.read())
|
||||
|
||||
print('Apply secret for {} [y/n] (y): '.format(args.prefix), end='')
|
||||
response = raw_input().lower()
|
||||
response = input().lower()
|
||||
if response != '' and response != 'y':
|
||||
return
|
||||
|
||||
|
@ -58,9 +58,9 @@ class LegalAuto(ReviewBot.ReviewBot):
|
||||
def retried_GET(self, url):
|
||||
try:
|
||||
return http_GET(url)
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
if 500 <= e.code <= 599:
|
||||
print 'Retrying {}'.format(url)
|
||||
print('Retrying {}'.format(url))
|
||||
time.sleep(1)
|
||||
return self.retried_GET(url)
|
||||
raise e
|
||||
@ -109,7 +109,7 @@ class LegalAuto(ReviewBot.ReviewBot):
|
||||
url = osc.core.makeurl(self.legaldb, ['package', str(pack)])
|
||||
report = REQ.get(url, headers=self.legaldb_headers).json()
|
||||
if report.get('priority', 0) != self.request_priority():
|
||||
print "Update priority %d" % self.request_priority()
|
||||
print('Update priority {}'.format(self.request_priority()))
|
||||
url = osc.core.makeurl(
|
||||
self.legaldb, ['package', str(pack)], {'priority': self.request_priority()})
|
||||
REQ.patch(url, headers=self.legaldb_headers)
|
||||
@ -249,7 +249,7 @@ class LegalAuto(ReviewBot.ReviewBot):
|
||||
if match and match.group(1) == package:
|
||||
lpackage = package
|
||||
if package != lpackage:
|
||||
print "SKIP", package, "it links to", lpackage
|
||||
print("SKIP", package, "it links to", lpackage)
|
||||
skip = True
|
||||
break
|
||||
if skip:
|
||||
@ -291,7 +291,7 @@ class LegalAuto(ReviewBot.ReviewBot):
|
||||
return None
|
||||
if not 'saved' in obj:
|
||||
return None
|
||||
print "PKG", tproject, sproject, package, revision, obj['saved']['id']
|
||||
print("PKG", tproject, sproject, package, revision, obj['saved']['id'])
|
||||
self.pkg_cache[hkey] = obj['saved']['id']
|
||||
return self.pkg_cache[hkey]
|
||||
|
||||
|
@ -39,6 +39,12 @@ from osclib.request_splitter import RequestSplitter
|
||||
from osclib.supersede_command import SupersedeCommand
|
||||
from osclib.prio_command import PrioCommand
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
input = getattr(__builtin__, 'raw_input')
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
|
||||
def _print_version(self):
|
||||
from osclib.common import VERSION
|
||||
@ -632,7 +638,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
if opts.non_interactive:
|
||||
print('y')
|
||||
else:
|
||||
response = raw_input().lower()
|
||||
response = input().lower()
|
||||
if response != '' and response != 'y':
|
||||
print('Quit')
|
||||
return
|
||||
|
@ -99,7 +99,7 @@ class StagingHelper(object):
|
||||
"""Main method"""
|
||||
rebuild_data = self.api.pseudometa_file_load('support_pkg_rebuild')
|
||||
if rebuild_data is None:
|
||||
print "There is no support_pkg_rebuild file!"
|
||||
print("There is no support_pkg_rebuild file!")
|
||||
return
|
||||
|
||||
logging.info('Gathering support package list from %s' % self.project)
|
||||
|
@ -7,15 +7,6 @@ from obs import OBS
|
||||
from osclib.conf import Config
|
||||
from osclib.stagingapi import StagingAPI
|
||||
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
string_types = str,
|
||||
else:
|
||||
string_types = basestring,
|
||||
|
||||
|
||||
class TestApiCalls(unittest.TestCase):
|
||||
"""
|
||||
Tests for various api calls to ensure we return expected content
|
||||
|
@ -19,8 +19,8 @@ class TestComment(unittest.TestCase):
|
||||
}
|
||||
|
||||
def test_truncate(self):
|
||||
comment = "string of text"
|
||||
for i in xrange(len(comment) + 1):
|
||||
comment = 'string of text'
|
||||
for i in range(len(comment) + 1):
|
||||
truncated = self.api.truncate(comment, length=i)
|
||||
print(truncated)
|
||||
self.assertEqual(len(truncated), i)
|
||||
@ -47,7 +47,7 @@ handle
|
||||
</pre>
|
||||
""".strip()
|
||||
|
||||
for i in xrange(len(comment) + len('...\n</pre>')):
|
||||
for i in range(len(comment) + len('...\n</pre>')):
|
||||
truncated = self.api.truncate(comment, length=i)
|
||||
print('=' * 80)
|
||||
print(truncated)
|
||||
|
@ -1,3 +1,5 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
@ -14,7 +16,7 @@ class TestPkgCache(unittest.TestCase):
|
||||
self.cache = PkgCache('/tmp/cache', force_clean=True)
|
||||
for fn in ('file_a', 'file_b', 'file_c'):
|
||||
with open(os.path.join('/tmp', fn), 'w') as f:
|
||||
print >>f, fn
|
||||
print(fn, file=f)
|
||||
|
||||
def tearDown(self):
|
||||
"""Clean the environment."""
|
||||
|
@ -37,7 +37,7 @@ http_GET = osc.core.http_GET
|
||||
def chunks(l, n):
|
||||
""" Yield successive n-sized chunks from l.
|
||||
"""
|
||||
for i in xrange(0, len(l), n):
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i:i+n]
|
||||
|
||||
class UpdateCrawler(object):
|
||||
@ -87,7 +87,7 @@ class UpdateCrawler(object):
|
||||
return http_GET(url)
|
||||
except HTTPError as e:
|
||||
if 500 <= e.code <= 599:
|
||||
print 'Retrying {}'.format(url)
|
||||
print('Retrying {}'.format(url))
|
||||
time.sleep(1)
|
||||
return self.retried_GET(url)
|
||||
raise e
|
||||
@ -169,7 +169,7 @@ class UpdateCrawler(object):
|
||||
def _submitrequest(self, src_project, src_package, rev, dst_project,
|
||||
dst_package, msg):
|
||||
res = 0
|
||||
print "creating submit request", src_project, src_package, rev, dst_project, dst_package
|
||||
print("creating submit request", src_project, src_package, rev, dst_project, dst_package)
|
||||
if not self.dryrun:
|
||||
res = osc.core.create_submit_request(self.apiurl,
|
||||
src_project,
|
||||
|
Loading…
x
Reference in New Issue
Block a user