print statement -> print function

This commit is contained in:
Tomas Kopecek 2016-12-05 12:41:48 +01:00 committed by Mike McLean
parent ef043e2c14
commit c143d0b88f
22 changed files with 600 additions and 600 deletions

View file

@ -432,8 +432,8 @@ class BuildRoot(object):
os.execvp(cmd[0],cmd)
except:
#diediedie
print "Failed to exec mock"
print ''.join(traceback.format_exception(*sys.exc_info()))
print("Failed to exec mock")
print(''.join(traceback.format_exception(*sys.exc_info())))
os._exit(1)
def getUploadPath(self):

View file

@ -154,7 +154,7 @@ class RepoMerge(object):
for r in self.repolist:
count +=1
rid = 'repo%s' % count
print >> sys.stderr, 'Adding repo: ' + r
sys.stderr.write('Adding repo: %s\n' % r)
n = self.yumbase.add_enable_repo(rid, baseurls=[r])
n._merge_rank = count
@ -231,8 +231,8 @@ class RepoMerge(object):
'%s < %s\n' % (pkg.sourcerpm, other_srpm))
# otherwise same, so we already have it
elif self.blocked.has_key(srpm_name):
print >> sys.stderr, 'Ignoring blocked package: %s\n' \
% pkg.sourcerpm
sys.stderr.write('Ignoring blocked package: %s\n\n' % \
pkg.sourcerpm)
continue
else:
include_srpms[srpm_name] = (pkg.sourcerpm, pkg.repoid)

893
cli/koji

File diff suppressed because it is too large Load diff

View file

@ -54,10 +54,10 @@ Print configuration::
ppc_koji = koji.get_profile_module("ppc-koji")
for i in (fedora_koji, ppc_koji):
print "PROFILE: %s" % i.config.profile
print("PROFILE: %s" % i.config.profile)
for key, value in sorted(i.config.__dict__.items()):
print " %s = %s" % (key, value)
print
print(" %s = %s" % (key, value))
print("")
Use ClientSession::
@ -66,7 +66,7 @@ Use ClientSession::
koji_module = koji.get_profile_module("koji")
client = koji_module.ClientSession(koji_module.config.server)
print client.listTags()
print(client.listTags())
TODO

View file

@ -630,7 +630,10 @@ Here are some guidelines on producing preferable pull requests.
While much of the older code in Koji does not, we try to stick to it
with new code
- Please maintain backward-compatibility up to RHEL 5 (which means
Python 2.4)
Python 2.4). On the other hand we are looking to migration to python 3, so
please use compatible constructs such as:
- Use ``print()`` function, not ``print`` statement
- Check, that unit tests are not broken. Simply run ``make test`` in main
directory of your branch.

View file

@ -2,8 +2,8 @@ PYTHON=python
PACKAGE = $(shell basename `pwd`)
LIBEXECFILES = rpmdiff
PYFILES = $(wildcard *.py)
PYVER := $(shell $(PYTHON) -c 'import sys; print "%.3s" %(sys.version)')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print sys.prefix')
PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" %(sys.version))')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')
PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

View file

@ -12338,24 +12338,24 @@ def handle_upload(environ):
if __name__ == "__main__":
# XXX - testing defaults
print "Connecting to DB"
print("Connecting to DB")
koji.db.setDBopts(database="test", user="test")
context.cnx = koji.db.connect()
context.req = {}
print "Creating a session"
print("Creating a session")
context.session = koji.auth.Session(None, hostip="127.0.0.1")
print context.session
print(context.session)
test_user = "host/1"
pw = "foobar"
print "Logging in as %s" % test_user
print("Logging in as %s" % test_user)
session_info = context.session.login(test_user, pw, {'hostip':'127.0.0.1'})
for k in session_info.keys():
session_info[k] = [session_info[k]]
s2 = koji.auth.Session(session_info, '127.0.0.1')
print s2
print s2.getHostId()
print(s2)
print(s2.getHostId())
context.session = s2
print "Associating host"
print("Associating host")
Host()
#context.cnx.commit()
context.session.perms['admin'] = 1 #XXX

View file

@ -212,12 +212,12 @@ class Rpmdiff:
return result
def _usage(exit=1):
print "Usage: %s [<options>] <old package> <new package>" % sys.argv[0]
print "Options:"
print " -h, --help Output this message and exit"
print " -i, --ignore Tag to ignore when calculating differences"
print " (may be used multiple times)"
print " Valid values are: SM5DNLVUGFT"
print("Usage: %s [<options>] <old package> <new package>" % sys.argv[0])
print("Options:")
print(" -h, --help Output this message and exit")
print(" -i, --ignore Tag to ignore when calculating differences")
print(" (may be used multiple times)")
print(" Valid values are: SM5DNLVUGFT")
sys.exit(exit)
def main():
@ -226,7 +226,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hi:", ["help", "ignore="])
except getopt.GetoptError, e:
print "Error: %s" % e
print("Error: %s" % e)
_usage()
for option, argument in opts:
@ -239,7 +239,7 @@ def main():
_usage()
d = Rpmdiff(args[0], args[1], ignore=ignore_tags)
print d.textdiff()
print(d.textdiff())
sys.exit(int(d.differs()))
if __name__ == '__main__':

View file

@ -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 %(%{__python} -c "from %distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%if 0%{?fedora} >= 21 || 0%{?redhat} >= 7
%global use_systemd 1

View file

@ -4,8 +4,8 @@ PYTHON=python
PACKAGE = $(shell basename `pwd`)
PYFILES = $(wildcard *.py)
PYSCRIPTS = context.py
PYVER := $(shell $(PYTHON) -c 'import sys; print "%.3s" %(sys.version)')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print sys.prefix')
PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" % (sys.version))')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')
PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

View file

@ -612,19 +612,19 @@ class RawHeader(object):
ofs = 16 + i*16 + j*4
data = [ord(x) for x in self.header[ofs:ofs+4]]
entry.append(multibyte(data))
#print "Tag: %d, Type: %d, Offset: %x, Count: %d" % tuple(entry)
#print("Tag: %d, Type: %d, Offset: %x, Count: %d" % tuple(entry))
index[entry[0]] = entry
self.datalen = dl
self.index = index
def dump(self):
print "HEADER DUMP:"
print("HEADER DUMP:")
#calculate start of store
il = len(self.index)
store = 16 + il * 16
#print "start is: %d" % start
#print "index length: %d" % il
print "Store at offset %d (%0x)" % (store, store)
#print("start is: %d" % start)
#print("index length: %d" % il)
print("Store at offset %d (%0x)" % (store, store))
#sort entries by offset, dtype
#also rearrange: tag, dtype, offset, count -> offset, dtype, tag, count
order = [(x[2], x[1], x[0], x[3]) for x in self.index.itervalues()]
@ -641,21 +641,21 @@ class RawHeader(object):
pos = store + offset
if next is not None:
if pos > next:
print "** HOLE between entries"
print "Hex: %s" % hex_string(self.header[next:pos])
print "Data: %r" % self.header[next:pos]
print("** HOLE between entries")
print("Hex: %s" % hex_string(self.header[next:pos]))
print("Data: %r" % self.header[next:pos])
elif pos < next:
print "** OVERLAPPING entries"
print "Tag: %d [%s], Type: %d, Offset: %x, Count: %d" \
% (tag, tags.get(tag, '?'), dtype, offset, count)
print("** OVERLAPPING entries")
print("Tag: %d [%s], Type: %d, Offset: %x, Count: %d" \
% (tag, tags.get(tag, '?'), dtype, offset, count))
if dtype == 0:
#null
print "[NULL entry]"
print("[NULL entry]")
next = pos
elif dtype == 1:
#char
for i in xrange(count):
print "Char: %r" % self.header[pos]
print("Char: %r" % self.header[pos])
pos += 1
next = pos
elif dtype >= 2 and dtype <= 5:
@ -663,44 +663,44 @@ class RawHeader(object):
n = 1 << (dtype - 2)
for i in xrange(count):
data = [ord(x) for x in self.header[pos:pos+n]]
print "%r" % data
print("%r" % data)
num = multibyte(data)
print "Int(%d): %d" % (n, num)
print("Int(%d): %d" % (n, num))
pos += n
next = pos
elif dtype == 6:
# string (null terminated)
end = self.header.find('\0', pos)
print "String(%d): %r" % (end-pos, self.header[pos:end])
print("String(%d): %r" % (end-pos, self.header[pos:end]))
next = end + 1
elif dtype == 7:
print "Data: %s" % hex_string(self.header[pos:pos+count])
print("Data: %s" % hex_string(self.header[pos:pos+count]))
next = pos+count
elif dtype == 8:
# string array
for i in xrange(count):
end = self.header.find('\0', pos)
print "String(%d): %r" % (end-pos, self.header[pos:end])
print("String(%d): %r" % (end-pos, self.header[pos:end]))
pos = end + 1
next = pos
elif dtype == 9:
# unicode string array
for i in xrange(count):
end = self.header.find('\0', pos)
print "i18n(%d): %r" % (end-pos, self.header[pos:end])
print("i18n(%d): %r" % (end-pos, self.header[pos:end]))
pos = end + 1
next = pos
else:
print "Skipping data type %x" % dtype
print("Skipping data type %x" % dtype)
next = None
if next is not None:
pos = store + self.datalen
if next < pos:
print "** HOLE at end of data block"
print "Hex: %s" % hex_string(self.header[next:pos])
print "Data: %r" % self.header[next:pos]
print("** HOLE at end of data block")
print("Hex: %s" % hex_string(self.header[next:pos]))
print("Data: %r" % self.header[next:pos])
elif pos > next:
print "** OVERFLOW in data block"
print("** OVERFLOW in data block")
def __getitem__(self, key):
tag, dtype, offset, count = self.index[key]
@ -2306,12 +2306,12 @@ class ClientSession(object):
if timeout:
callopts['timeout'] = timeout
if self.opts.get('debug_xmlrpc', False):
print "url: %s" % handler
print("url: %s" % handler)
for _key in callopts:
_val = callopts[_key]
if _key == 'data' and len(_val) > 1024:
_val = _val[:1024] + '...'
print "%s: %r" % (_key, _val)
print("%s: %r" % (_key, _val))
catcher = None
if hasattr(warnings, 'catch_warnings'):
# TODO: convert to a with statement when we drop 2.4.3 support
@ -2335,7 +2335,7 @@ class ClientSession(object):
p, u = xmlrpclib.getparser()
for chunk in response.iter_content(8192):
if self.opts.get('debug_xmlrpc', False):
print "body: %r" % chunk
print("body: %r" % chunk)
p.feed(chunk)
p.close()
result = u.close()

View file

@ -719,17 +719,17 @@ if __name__ == '__main__':
# XXX - testing defaults
import db
db.setDBopts(database="test", user="test")
print "Connecting to db"
print("Connecting to db")
context.cnx = db.connect()
print "starting session 1"
print("starting session 1")
sess = Session(None, hostip='127.0.0.1')
print "Session 1: %s" % sess
print "logging in with session 1"
print("Session 1: %s" % sess)
print("logging in with session 1")
session_info = sess.login('host/1', 'foobar', {'hostip':'127.0.0.1'})
#wrap values in lists
session_info = dict([[k, [v]] for k, v in session_info.iteritems()])
print "Session 1: %s" % sess
print "Session 1 info: %r" % session_info
print "Creating session 2"
print("Session 1: %s" % sess)
print("Session 1 info: %r" % session_info)
print("Creating session 2")
s2 = Session(session_info, '127.0.0.1')
print "Session 2: %s " % s2
print("Session 2: %s " % s2)

View file

@ -85,9 +85,9 @@ if __name__ == '__main__':
#context.foo = 1
#context.bar = 2
print context
print(context)
#del context.bar
print context
print(context)
import random
import time
@ -95,18 +95,18 @@ if __name__ == '__main__':
context.foo = random.random()
time.sleep(1.5+random.random())
context._threadclear()
print context
print(context)
for x in xrange(1, 10):
thread.start_new_thread(test, ())
time.sleep(4)
print
print context
print('')
print(context)
context.foo = 1
context.bar = 2
print context.foo, context.bar
print context
print(context.foo, context.bar)
print(context)
context._threadclear()
print context
print(context)

View file

@ -129,7 +129,7 @@ def log_output(session, path, args, outfile, uploadpath, cwd=None, logerror=0, a
os.close(fd)
except:
pass
print msg
print(msg)
os._exit(1)
else:
if chroot:
@ -147,8 +147,8 @@ def log_output(session, path, args, outfile, uploadpath, cwd=None, logerror=0, a
# will happen if the forked process has not created the logfile yet
continue
except:
print 'Error reading log file: %s' % outfile
print ''.join(traceback.format_exception(*sys.exc_info()))
print('Error reading log file: %s' % outfile)
print(''.join(traceback.format_exception(*sys.exc_info())))
incremental_upload(session, remotename, outfd, uploadpath)

View file

@ -190,4 +190,4 @@ def connect():
if __name__ == "__main__":
setDBopts(database="test", user="test")
print "This is a Python library"
print("This is a Python library")

View file

@ -21,7 +21,7 @@ import httplib
import socket
def our_verify(connection, x509, errNum, errDepth, preverifyOK):
# print "Verify: errNum = %s, errDepth = %s, preverifyOK = %s" % (errNum, errDepth, preverifyOK)
# print("Verify: errNum = %s, errDepth = %s, preverifyOK = %s" % (errNum, errDepth, preverifyOK))
# preverifyOK should tell us whether or not the client's certificate
# correctly authenticates against the CA chain
@ -67,10 +67,10 @@ class PlgHTTPSConnection(httplib.HTTPConnection):
self.sock.settimeout(self._timeout)
self.sock.connect(sa)
if self.debuglevel > 0:
print "connect: (%s, %s) [ssl]" % (self.host, self.port)
print("connect: (%s, %s) [ssl]" % (self.host, self.port))
except socket.error:
if self.debuglevel > 0:
print 'connect fail:', (self.host, self.port)
print('connect fail:', (self.host, self.port))
if self.sock:
self.sock.close()
self.sock = None

View file

@ -22,7 +22,7 @@ class ProfilesTestCase(unittest.TestCase):
for n in errors:
err = errors[n]
if err is not None:
print err
print(err)
assert False

View file

@ -123,7 +123,7 @@ def get_options():
if not os.access(cf, os.F_OK):
cf = None
if not cf:
print "no config file"
print("no config file")
config = None
else:
config.read(cf)
@ -160,7 +160,7 @@ def get_options():
alias = ('main', name)
if config.has_option(*alias):
if options.debug:
print "Using option %s from config file" % (alias,)
print("Using option %s from config file" % (alias,))
if type == 'integer':
setattr(defaults, name, config.getint(*alias))
elif type == 'boolean':
@ -197,7 +197,7 @@ def get_options():
continue
options.key_aliases[parts[0].upper()] = parts[1]
except ValueError, e:
print e
print(e)
parser.error(_("Invalid key alias data in config: %s") % config.get('main','key_aliases'))
#parse time intervals
@ -207,7 +207,7 @@ def get_options():
value = parse_duration(value)
setattr(options, key, value)
if options.debug:
print "%s: %s seconds" % (key, value)
print("%s: %s seconds" % (key, value))
except ValueError:
parser.error(_("Invalid time interval: %s") % value)
@ -379,13 +379,13 @@ def activate_session(session):
error(_("Error: unable to log in, no authentication methods available"))
ensure_connection(session)
if options.debug:
print "successfully connected to hub"
print("successfully connected to hub")
def send_warning_notice(owner_name, builds):
if not options.mail:
return
if not builds:
print "Warning: empty build list. No notice sent"
print("Warning: empty build list. No notice sent")
return
head = """\
The following build(s) are unreferenced and have been marked for
@ -413,12 +413,12 @@ refer to the document linked above for instructions."""
msg['X-Koji-Builder'] = owner_name
if options.test:
if options.debug:
print str(msg)
print(str(msg))
else:
print "Would have sent warning notice to %s" % msg['To']
print("Would have sent warning notice to %s" % msg['To'])
else:
if options.debug:
print "Sending warning notice to %s" % msg['To']
print("Sending warning notice to %s" % msg['To'])
try:
s = smtplib.SMTP(options.smtp_host)
s.sendmail(msg['From'], msg['To'], msg.as_string())
@ -434,9 +434,9 @@ def main(args):
def handle_trash():
print "Getting untagged builds..."
print("Getting untagged builds...")
untagged = session.untaggedBuilds()
print "...got %i builds" % len(untagged)
print("...got %i builds" % len(untagged))
min_age = options.delay
trashcan_tag = options.trashcan_tag
#Step 1: place unreferenced builds into trashcan
@ -448,27 +448,27 @@ def handle_trash():
nvr = "%(name)s-%(version)s-%(release)s" % binfo
if not check_package(binfo['name']):
if options.debug:
print "[%i/%i] Skipping package: %s" % (i, N, nvr)
print("[%i/%i] Skipping package: %s" % (i, N, nvr))
continue
try:
refs = session.buildReferences(binfo['id'], limit=10)
except xmlrpclib.Fault:
print "[%i/%i] Error checking references for %s. Skipping" % (i, N, nvr)
print("[%i/%i] Error checking references for %s. Skipping" % (i, N, nvr))
continue
#XXX - this is more data than we need
# also, this call takes waaaay longer than it should
if refs['tags']:
# must have been tagged just now
print "[%i/%i] Build is tagged [?]: %s" % (i, N, nvr)
print("[%i/%i] Build is tagged [?]: %s" % (i, N, nvr))
continue
if refs['rpms']:
if options.debug:
print "[%i/%i] Build has %i rpm references: %s" % (i, N, len(refs['rpms']), nvr)
print("[%i/%i] Build has %i rpm references: %s" % (i, N, len(refs['rpms']), nvr))
#pprint.pprint(refs['rpms'])
continue
if refs['archives']:
if options.debug:
print "[%i/%i] Build has %i archive references: %s" % (i, N, len(refs['archives']), nvr)
print("[%i/%i] Build has %i archive references: %s" % (i, N, len(refs['archives']), nvr))
#pprint.pprint(refs['archives'])
continue
ts = refs['last_used']
@ -478,8 +478,8 @@ def handle_trash():
ts = ts[0]
#XXX - should really check time server side
if options.debug:
print "[%i/%i] Build has been used in a buildroot: %s" % (i, N, nvr)
print "Last_used: %r" % ts
print("[%i/%i] Build has been used in a buildroot: %s" % (i, N, nvr))
print("Last_used: %r" % ts)
age = time.time() - ts
if age < min_age:
continue
@ -506,26 +506,26 @@ def handle_trash():
last = max(history)[1]
if not last['revoke_event']:
#this might happen if the build was tagged just now
print "[%i/%i] Warning: build not untagged: %s" % (i, N, nvr)
print("[%i/%i] Warning: build not untagged: %s" % (i, N, nvr))
continue
age = time.time() - last['revoke_ts']
if age is not None and age < min_age:
if options.debug:
print "[%i/%i] Build untagged only recently: %s" % (i, N, nvr)
print("[%i/%i] Build untagged only recently: %s" % (i, N, nvr))
continue
#check build signatures
keys = get_build_sigs(binfo['id'], cache=True)
if keys and options.debug:
print "Build: %s, Keys: %s" % (nvr, keys)
print("Build: %s, Keys: %s" % (nvr, keys))
if protected_sig(keys):
print "Skipping build %s. Keys: %s" % (nvr, keys)
print("Skipping build %s. Keys: %s" % (nvr, keys))
continue
#ok, go ahead add it to the list
if binfo2 is None:
binfo2 = session.getBuild(binfo['id'])
binfo2['nvr'] = nvr
print "[%i/%i] Adding build to trash list: %s" % (i, N, nvr)
print("[%i/%i] Adding build to trash list: %s" % (i, N, nvr))
to_trash.append(binfo2)
#process to_trash
@ -541,17 +541,17 @@ def handle_trash():
send_warning_notice(owner_name, [x[1] for x in builds])
for nvr, binfo in builds:
if options.test:
print "Would have moved to trashcan: %s" % nvr
print("Would have moved to trashcan: %s" % nvr)
else:
if options.debug:
print "Moving to trashcan: %s" % nvr
print("Moving to trashcan: %s" % nvr)
#figure out package owner
count = {}
for pkg in session.listPackages(pkgID=binfo['name']):
count.setdefault(pkg['owner_id'], 0)
count[pkg['owner_id']] += 1
if not count:
print "Warning: no owner for %s, using build owner" % nvr
print("Warning: no owner for %s, using build owner" % nvr)
#best we can do currently
owner = binfo['owner_id']
else:
@ -587,10 +587,10 @@ def handle_salvage():
def salvage_build(binfo):
"""Removes trashcan tag from a build and prints a message"""
if options.test:
print "Would have untagged from trashcan: %(nvr)s" % binfo
print("Would have untagged from trashcan: %(nvr)s" % binfo)
else:
if options.debug:
print "Untagging from trashcan: %(nvr)s" % binfo
print("Untagging from trashcan: %(nvr)s" % binfo)
session.untagBuildBypass(options.trashcan_tag, binfo['id'], force=True)
def handle_delete(just_salvage=False):
@ -600,30 +600,30 @@ def handle_delete(just_salvage=False):
reclaims referenced builds from the trashcan, it does not perform any
deletes
"""
print "Getting list of builds in trash..."
print("Getting list of builds in trash...")
trashcan_tag = options.trashcan_tag
trash = [(b['nvr'], b) for b in session.listTagged(trashcan_tag)]
trash.sort()
print "...got %i builds" % len(trash)
print("...got %i builds" % len(trash))
#XXX - it would be better if there were more appropriate server calls for this
grace_period = options.grace_period
for nvr, binfo in trash:
# see if build has been tagged elsewhere
if not check_package(binfo['name']):
if options.debug:
print "Skipping package: %s" % nvr
print("Skipping package: %s" % nvr)
continue
tags = [t['name'] for t in session.listTags(build=binfo['id']) if t['name'] != trashcan_tag]
if tags:
print "Build %s tagged elsewhere: %s" % (nvr, tags)
print("Build %s tagged elsewhere: %s" % (nvr, tags))
salvage_build(binfo)
continue
#check build signatures
keys = get_build_sigs(binfo['id'], cache=False)
if keys and options.debug:
print "Build: %s, Keys: %s" % (nvr, keys)
print("Build: %s, Keys: %s" % (nvr, keys))
if protected_sig(keys):
print "Salvaging signed build %s. Keys: %s" % (nvr, keys)
print("Salvaging signed build %s. Keys: %s" % (nvr, keys))
salvage_build(binfo)
continue
if just_salvage:
@ -634,7 +634,7 @@ def handle_delete(just_salvage=False):
current = [x for x in history if x['active']]
if not current:
#untagged just now?
print "Warning: history missing for %s" % nvr
print("Warning: history missing for %s" % nvr)
pprint.pprint(binfo)
pprint.pprint(history)
continue
@ -643,19 +643,19 @@ def handle_delete(just_salvage=False):
age = time.time() - current['create_ts']
if age < grace_period:
if options.debug:
print "Skipping build %s, age=%i" % (nvr, age)
print("Skipping build %s, age=%i" % (nvr, age))
continue
# go ahead and delete
if options.test:
print "Would have deleted build from trashcan: %s" % nvr
print("Would have deleted build from trashcan: %s" % nvr)
else:
print "Deleting build: %s" % nvr
print("Deleting build: %s" % nvr)
session.untagBuildBypass(trashcan_tag, binfo['id'])
try:
session.deleteBuild(binfo['id'])
except (xmlrpclib.Fault, koji.GenericError), e:
print "Warning: deletion failed: %s" % e
print("Warning: deletion failed: %s" % e)
#server issue
pass
#TODO - log details for delete failures
@ -778,7 +778,7 @@ def handle_prune():
"""
#read policy
if not options.config or not options.config.has_option('prune', 'policy'):
print "Skipping prune step. No policies available."
print("Skipping prune step. No policies available.")
return
#policies = read_policies(options.policy_file)
policies = scan_policies(options.config.get('prune', 'policy'))
@ -795,11 +795,11 @@ def handle_prune():
tagname = taginfo['name']
if tagname == options.trashcan_tag:
if options.debug:
print "Skipping trashcan tag: %s" % tagname
print("Skipping trashcan tag: %s" % tagname)
continue
if not check_tag(tagname):
#if options.debug:
# print "skipping tag due to filter: %s" % tagname
# print("skipping tag due to filter: %s" % tagname)
continue
bypass = False
if taginfo['locked']:
@ -809,18 +809,18 @@ def handle_prune():
bypass = True
break
if bypass:
print "Bypassing lock on tag: %s" % tagname
print("Bypassing lock on tag: %s" % tagname)
else:
if options.debug:
print "skipping locked tag: %s" % tagname
print("skipping locked tag: %s" % tagname)
continue
if options.debug:
print "Pruning tag: %s" % tagname
print("Pruning tag: %s" % tagname)
#get builds
history = session.tagHistory(tag=tagname, active=True, queryOpts={'order': '-create_ts'})
if not history:
if options.debug:
print "No history for %s" % tagname
print("No history for %s" % tagname)
continue
pkghist = {}
for h in history:
@ -833,10 +833,10 @@ def handle_prune():
for pkg in pkgs:
if not check_package(pkg):
#if options.debug:
# print "skipping package due to filter: %s" % pkg
# print("skipping package due to filter: %s" % pkg)
continue
if options.debug:
print pkg
print(pkg)
hist = pkghist[pkg]
#these are the *active* history entries for tag/pkg
skipped = 0
@ -858,27 +858,27 @@ def handle_prune():
action = policies.apply(data)
if action is None:
if options.debug:
print "No policy for %s (%s)" % (nvr, tagname)
print("No policy for %s (%s)" % (nvr, tagname))
if action == 'skip':
skipped += 1
if options.debug:
print policies.last_rule()
print "%s: %s (%s, %i)" % (action, nvr, tagname, order)
print(policies.last_rule())
print("%s: %s (%s, %i)" % (action, nvr, tagname, order))
if action == 'untag':
if options.test:
print "Would have untagged %s from %s" % (nvr, tagname)
print("Would have untagged %s from %s" % (nvr, tagname))
untagged.setdefault(nvr, {})[tagname] = 1
else:
print "Untagging build %s from %s" % (nvr, tagname)
print("Untagging build %s from %s" % (nvr, tagname))
try:
session.untagBuildBypass(taginfo['id'], entry['build_id'], force=bypass)
untagged.setdefault(nvr, {})[tagname] = 1
except (xmlrpclib.Fault, koji.GenericError), e:
print "Warning: untag operation failed: %s" % e
print("Warning: untag operation failed: %s" % e)
pass
# if action == 'keep' do nothing
if options.purge and untagged:
print "Attempting to purge %i builds" % len(untagged)
print("Attempting to purge %i builds" % len(untagged))
for nvr in untagged:
build_id = build_ids[nvr]
tags = [t['name'] for t in session.listTags(build_id)]
@ -887,28 +887,28 @@ def handle_prune():
tags = [t for t in tags if t not in untagged[nvr]]
if tags:
#still tagged somewhere
print "Skipping %s, still tagged: %s" % (nvr, tags)
print("Skipping %s, still tagged: %s" % (nvr, tags))
continue
#check cached sigs first to save a little time
if build_id in build_sig_cache:
keys = build_sig_cache[build_id]
if protected_sig(keys):
print "Skipping %s, signatures: %s" % (nvr, keys)
print("Skipping %s, signatures: %s" % (nvr, keys))
continue
#recheck signatures in case build was signed during run
keys = get_build_sigs(build_id, cache=False)
if protected_sig(keys):
print "Skipping %s, signatures: %s" % (nvr, keys)
print("Skipping %s, signatures: %s" % (nvr, keys))
continue
if options.test:
print "Would have deleted build: %s" % nvr
print("Would have deleted build: %s" % nvr)
else:
print "Deleting untagged build: %s" % nvr
print("Deleting untagged build: %s" % nvr)
try:
session.deleteBuild(build_id, strict=False)
except (xmlrpclib.Fault, koji.GenericError), e:
print "Warning: deletion failed: %s" % e
print("Warning: deletion failed: %s" % e)
#server issue
pass
@ -934,7 +934,7 @@ if __name__ == "__main__":
# else:
# exctype, value = sys.exc_info()[:2]
# rv = 1
# print "%s: %s" % (exctype, value)
# print("%s: %s" % (exctype, value))
try:
session.logout()
except:

View file

@ -66,7 +66,7 @@ def _(args):
def log(str):
global logfile
print "%s" % str
print("%s" % str)
if logfile is not None:
os.write(logfile, "%s\n" % str)
@ -519,7 +519,7 @@ class TrackedBuild(object):
unpack.append(('br_info', br_id))
#tags.setdefault(br_info['tag_name'], 0)
#tags[br_info['tag_name']] += 1
#print "."
#print(".")
remote.listRPMs(componentBuildrootID=br_id)
unpack.append(('rpmlist', br_id))
#for rinfo in remote.listRPMs(componentBuildrootID=br_id):

View file

@ -823,7 +823,7 @@ if __name__ == "__main__":
if not session.logged_in:
quit("Error: Unknown login error")
if not session.logged_in:
print "Error: unable to log in"
print("Error: unable to log in")
sys.exit(1)
if options.skip_main:
sys.exit()

View file

@ -700,18 +700,18 @@ def main():
'--desc', 'Runs Koji tasks assigned to a VM'],
log=False)
if ret:
print 'Error installing %s service, output was: %s' % (prog, output)
print('Error installing %s service, output was: %s' % (prog, output))
sys.exit(1)
else:
print 'Successfully installed the %s service' % prog
print('Successfully installed the %s service' % prog)
sys.exit(0)
elif opts.uninstall:
ret, output = run(['/bin/cygrunsrv', '--remove', prog], log=False)
if ret:
print 'Error removing the %s service, output was: %s' % (prog, output)
print('Error removing the %s service, output was: %s' % (prog, output))
sys.exit(1)
else:
print 'Successfully removed the %s service' % prog
print('Successfully removed the %s service' % prog)
sys.exit(0)
handler = setup_logging(opts)

View file

@ -1,8 +1,8 @@
PYTHON=python
PACKAGE = $(shell basename `pwd`)
PYFILES = $(wildcard *.py)
PYVER := $(shell $(PYTHON) -c 'import sys; print "%.3s" %(sys.version)')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print sys.prefix')
PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" % (sys.version))')
PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')
PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)