Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Turn everything into py3 syntax
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
  • Loading branch information
puiterwijk committed Sep 28, 2017
1 parent a87f5a6 commit d776356
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion bodhi/server/consumers/masher.py
Expand Up @@ -715,7 +715,7 @@ def sanity_check_repo(self):
try:
repodata = os.path.join(mash_path, arch, 'repodata')
sanity_check_repodata(repodata)
except Exception, e:
except Exception as e:
self.log.error("Repodata sanity check failed!\n%s" % str(e))
raise

Expand Down
2 changes: 1 addition & 1 deletion bodhi/server/models.py
Expand Up @@ -2974,7 +2974,7 @@ def expire(self):
try:
koji_session.untagBuild(self.build.release.override_tag,
self.build.nvr, strict=True)
except Exception, e:
except Exception as e:
log.error('Unable to untag override %s: %s' % (self.build.nvr, e))
self.expired_date = datetime.utcnow()

Expand Down
4 changes: 2 additions & 2 deletions bodhi/server/scripts/clean_old_mashes.py
Expand Up @@ -59,8 +59,8 @@ def clean_up():
dirs_to_delete.extend(sorted(dirs, reverse=True)[NUM_TO_KEEP:])

if dirs_to_delete:
print 'Deleting the following directories:'
print('Deleting the following directories:')
for d in dirs_to_delete:
d = os.path.join(mash_dir, d)
shutil.rmtree(d)
print d
print(d)
2 changes: 1 addition & 1 deletion bodhi/server/validators.py
Expand Up @@ -385,7 +385,7 @@ def validate_acls(request):
release.branch, config)
committers, watchers = people
groups, notify_groups = groups
except Exception, e:
except Exception as e:
log.exception(e)
request.errors.add('body', 'builds',
"Unable to access the Package "
Expand Down
2 changes: 1 addition & 1 deletion bodhi/tests/server/__init__.py
Expand Up @@ -48,7 +48,7 @@ def create_update(session, build_nvrs, release_name=u'F17'):

update = Update(
title=', '.join(build_nvrs), builds=builds, user=user, request=UpdateRequest.testing,
notes=u'Useful details!', release=release, date_submitted=datetime(1984, 11, 02),
notes=u'Useful details!', release=release, date_submitted=datetime(1984, 11, 2),
requirements=u'rpmlint', stable_karma=3, unstable_karma=-3,
type=UpdateType.bugfix, test_gating_status=TestGatingStatus.passed)
session.add(update)
Expand Down
2 changes: 1 addition & 1 deletion bodhi/tests/server/consumers/test_masher.py
Expand Up @@ -131,7 +131,7 @@ def setUp(self):
req = requests.get('%s/new' % faitout)
if req.status_code == 200:
db_path = req.text
print 'Using faitout at: %s' % db_path
print('Using faitout at: %s' % db_path)
except:
pass
engine = initialize_db({'sqlalchemy.url': db_path})
Expand Down
4 changes: 2 additions & 2 deletions bodhi/tests/server/functional/test_comments.py
Expand Up @@ -41,7 +41,7 @@ def setUp(self, *args, **kwargs):
type=UpdateType.enhancement,
notes=u'Useful details!',
release=release,
date_submitted=datetime(1984, 11, 02),
date_submitted=datetime(1984, 11, 2),
requirements=u'rpmlint',
stable_karma=3,
unstable_karma=-3,
Expand Down Expand Up @@ -379,7 +379,7 @@ def test_list_comments_by_update_no_comments(self):
request=UpdateRequest.testing,
type=UpdateType.enhancement,
notes=u'Useful details!',
date_submitted=datetime(1984, 11, 02),
date_submitted=datetime(1984, 11, 2),
requirements=u'rpmlint',
stable_karma=3,
unstable_karma=-3,
Expand Down
2 changes: 1 addition & 1 deletion bodhi/tests/server/functional/test_generic.py
Expand Up @@ -459,7 +459,7 @@ def _add_updates(updateslist, user, release, packagesuffix):
type=j[0],
notes=u'Useful details!',
release=release,
date_submitted=datetime(1984, 11, 02),
date_submitted=datetime(1984, 11, 2),
requirements=u'rpmlint',
stable_karma=3,
unstable_karma=-3,
Expand Down
6 changes: 3 additions & 3 deletions bodhi/tests/server/test_models.py
Expand Up @@ -540,7 +540,7 @@ def setUp(self):
request=model.UpdateRequest.testing,
notes=u'Useless details!',
release=model.Release.query.filter_by(name=u'F17').one(),
date_submitted=datetime(1984, 11, 02),
date_submitted=datetime(1984, 11, 2),
requirements=u'rpmlint',
stable_karma=3,
unstable_karma=-3,
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def test_set_request_untested_stable(self):
try:
self.obj.set_request(self.db, UpdateRequest.stable, req.user.name)
assert False
except BodhiException, e:
except BodhiException as e:
pass
self.assertEqual(self.obj.request, UpdateRequest.testing)
self.assertEqual(self.obj.status, UpdateStatus.pending)
Expand Down Expand Up @@ -1462,7 +1462,7 @@ def test_set_request_stable_for_critpath_update_when_test_gating_enabled(self):
try:
self.obj.set_request(self.db, UpdateRequest.stable, req.user.name)
assert False
except BodhiException, e:
except BodhiException as e:
pass
expected_msg = (
'This critical path update has not yet been approved for pushing to the '
Expand Down
138 changes: 69 additions & 69 deletions tools/metrics.py
Expand Up @@ -60,7 +60,7 @@ def main(releases=None):
total = updates.count()
if not total:
continue
print header(release.long_name)
print(header(release.long_name))
stats[release.name] = {
'num_updates': total,
'num_tested': 0,
Expand Down Expand Up @@ -223,108 +223,108 @@ def main(releases=None):

data['deltas'].sort()

print " * %d updates" % data['num_updates']
print " * %d packages updated" % (len(data['packages']))
print(" * %d updates" % data['num_updates'])
print(" * %d packages updated" % (len(data['packages'])))
for status in statuses:
print " * %d %s updates" % (data['num_%s' % status], status)
print(" * %d %s updates" % (data['num_%s' % status], status))
for type in types:
print " * %d %s updates (%0.2f%%)" % (
print(" * %d %s updates (%0.2f%%)" % (
data['num_%s' % type], type,
float(data['num_%s' % type]) / data['num_updates'] * 100)
print " * %d bugs resolved" % len(data['bugs'])
print " * %d critical path updates (%0.2f%%)" % (
data['num_critpath'], float(data['num_critpath']) / data['num_updates'] * 100)
print " * %d approved critical path updates" % (
data['num_critpath_approved'])
print " * %d unapproved critical path updates" % (
data['num_critpath_unapproved'])
print " * %d updates received feedback (%0.2f%%)" % (
data['num_feedback'], (float(data['num_feedback']) / data['num_updates'] * 100))
print " * %d +0 comments" % data['0']
print " * %d +1 comments" % data['1']
print " * %d -1 comments" % data['-1']
print " * %d unique authenticated karma submitters" % (
len(data['karma']))
print " * %d proventesters" % len(data['proventesters'])
print " * %d +1's from proventesters" % data['proventesters_1']
print " * %d -1's from proventesters" % data['proventesters_-1']
float(data['num_%s' % type]) / data['num_updates'] * 100))
print(" * %d bugs resolved" % len(data['bugs']))
print(" * %d critical path updates (%0.2f%%)" % (
data['num_critpath'], float(data['num_critpath']) / data['num_updates'] * 100))
print(" * %d approved critical path updates" % (
data['num_critpath_approved']))
print(" * %d unapproved critical path updates" % (
data['num_critpath_unapproved']))
print(" * %d updates received feedback (%0.2f%%)" % (
data['num_feedback'], (float(data['num_feedback']) / data['num_updates'] * 100)))
print(" * %d +0 comments" % data['0'])
print(" * %d +1 comments" % data['1'])
print(" * %d -1 comments" % data['-1'])
print(" * %d unique authenticated karma submitters" % (
len(data['karma'])))
print(" * %d proventesters" % len(data['proventesters']))
print(" * %d +1's from proventesters" % data['proventesters_1'])
print(" * %d -1's from proventesters" % data['proventesters_-1'])
if data['num_critpath']:
print " * %d critpath updates with conflicting proventesters (%0.2f%% of critpath)" % (
print(" * %d critpath updates with conflicting proventesters (%0.2f%% of critpath)" % (
len(data['conflicted_proventesters']),
float(len(data['conflicted_proventesters'])) / data['num_critpath'] * 100)
float(len(data['conflicted_proventesters'])) / data['num_critpath'] * 100))
for u in sorted(data['conflicted_proventesters']):
print ' <li><a href="%s">%s</a></li>' % (u, u.split('/')[-1])
print(' <li><a href="%s">%s</a></li>' % (u, u.split('/')[-1]))
msg = (" * %d critpath updates with positive karma and negative proventester feedback "
"(%0.2f%% of critpath)")
print msg % (
print(msg % (
len(data['critpath_positive_karma_negative_proventesters']),
float(len(data['critpath_positive_karma_negative_proventesters'])) /
data['num_critpath'] * 100)
data['num_critpath'] * 100))
for u in sorted(data['critpath_positive_karma_negative_proventesters']):
print ' <li><a href="%s">%s</a></li>' % (u, u.split('/')[-1])
print(' <li><a href="%s">%s</a></li>' % (u, u.split('/')[-1]))
msg = (" * %d critpath updates with positive karma and positive proventester feedback "
"(%0.2f%% of critpath)")
print msg % (
print(msg % (
len(data['critpath_positive_karma_including_proventesters']),
float(len(data['critpath_positive_karma_including_proventesters'])) /
data['num_critpath'] * 100)
print " * %d anonymous users gave feedback (%0.2f%%)" % (
data['num_critpath'] * 100))
print(" * %d anonymous users gave feedback (%0.2f%%)" % (
data['num_anon_feedback'], float(data['num_anon_feedback']) /
(data['num_anon_feedback'] + sum(data['karma'].values())) * 100)
print " * %d stable updates reached the stable karma threshold (%0.2f%%)" % (
data['num_stablekarma'], float(data['num_stablekarma']) / data['num_stable'] * 100)
print " * %d stable updates reached the minimum time in testing threshold (%0.2f%%)" % (
data['num_testingtime'], float(data['num_testingtime']) / data['num_stable'] * 100)
print " * %d went from testing to stable *without* karma (%0.2f%%)" % (
(data['num_anon_feedback'] + sum(data['karma'].values())) * 100))
print(" * %d stable updates reached the stable karma threshold (%0.2f%%)" % (
data['num_stablekarma'], float(data['num_stablekarma']) / data['num_stable'] * 100))
print(" * %d stable updates reached the minimum time in testing threshold (%0.2f%%)" % (
data['num_testingtime'], float(data['num_testingtime']) / data['num_stable'] * 100))
print(" * %d went from testing to stable *without* karma (%0.2f%%)" % (
data['num_tested_without_karma'],
float(data['num_tested_without_karma']) / data['num_tested'] * 100)
print " * %d updates were pushed to stable with negative karma (%0.2f%%)" % (
float(data['num_tested_without_karma']) / data['num_tested'] * 100))
print(" * %d updates were pushed to stable with negative karma (%0.2f%%)" % (
data['stable_with_negative_karma'],
float(data['stable_with_negative_karma']) / data['num_stable'] * 100)
print " * %d critical path updates pushed to stable *without* karma" % (
len(data['critpath_without_karma']))
print " * Time spent in testing:"
print " * mean = %d days" % (
data['accumulative'].days / len(data['deltas']))
print " * median = %d days" % (
data['deltas'][len(data['deltas']) / 2].days)
print " * mode = %d days" % (
sorted(data['occurrences'].items(), key=itemgetter(1))[-1][0])

print "Out of %d packages updated, the top 50 were:" % (
len(data['packages']))
float(data['stable_with_negative_karma']) / data['num_stable'] * 100))
print(" * %d critical path updates pushed to stable *without* karma" % (
len(data['critpath_without_karma'])))
print(" * Time spent in testing:")
print(" * mean = %d days" % (
data['accumulative'].days / len(data['deltas'])))
print(" * median = %d days" % (
data['deltas'][len(data['deltas']) / 2].days))
print(" * mode = %d days" % (
sorted(data['occurrences'].items(), key=itemgetter(1))[-1][0]))

print("Out of %d packages updated, the top 50 were:" % (
len(data['packages'])))
for package in sorted(data['packages'].iteritems(), key=itemgetter(1), reverse=True)[:50]:
print " * %s (%d)" % (package[0], package[1])
print(" * %s (%d)" % (package[0], package[1]))

print "Out of %d update submitters, the top 50 were:" % (
len(data['submitters']))
print("Out of %d update submitters, the top 50 were:" % (
len(data['submitters'])))
for submitter in sorted(
data['submitters'].iteritems(), key=itemgetter(1), reverse=True)[:50]:
print " * %s (%d)" % (submitter[0], submitter[1])
print(" * %s (%d)" % (submitter[0], submitter[1]))

print "Out of %d critical path updates, the top 50 updated were:" % (
len(data['critpath_pkgs']))
print("Out of %d critical path updates, the top 50 updated were:" % (
len(data['critpath_pkgs'])))
for x in sorted(data['critpath_pkgs'].iteritems(), key=itemgetter(1), reverse=True)[:50]:
print " * %s (%d)" % (x[0], x[1])
print(" * %s (%d)" % (x[0], x[1]))

critpath_not_updated = set()
for pkg in critpath_pkgs:
if pkg not in data['critpath_pkgs']:
critpath_not_updated.add(pkg)
print "Out of %d critical path packages, %d were never updated:" % (
len(critpath_pkgs), len(critpath_not_updated))
print("Out of %d critical path packages, %d were never updated:" % (
len(critpath_pkgs), len(critpath_not_updated)))
for pkg in sorted(critpath_not_updated):
print(' * %s' % pkg)

print
print()

print
print "Out of %d total updates, %d received feedback (%0.2f%%)" % (
num_updates, feedback, (float(feedback) / num_updates * 100))
print "Out of %d total unique commenters, the top 50 were:" % (
len(karma))
print()
print("Out of %d total updates, %d received feedback (%0.2f%%)" % (
num_updates, feedback, (float(feedback) / num_updates * 100)))
print("Out of %d total unique commenters, the top 50 were:" % (
len(karma)))
for submitter in sorted(karma.iteritems(), key=itemgetter(1), reverse=True)[:50]:
print " * %s (%d)" % (submitter[0], submitter[1])
print(" * %s (%d)" % (submitter[0], submitter[1]))


if __name__ == '__main__':
Expand Down
10 changes: 5 additions & 5 deletions tools/perf-test.py
Expand Up @@ -50,22 +50,22 @@ def clock_url(url, tries=4):
def do_scan():
results = collections.OrderedDict()
for name, url in items.items():
print 'Crunching', name, url
print('Crunching', name, url)
duration = clock_url(url)
results[name] = duration
return results


def loop_over_refs(refs):
print "Checking %r" % refs
print("Checking %r" % refs)
response = raw_input("Is that okay? ")
if response != 'y':
sys.exit(0)
for ref in refs:
time.sleep(3)
ref = ref[:reflength]
commands.getstatus('git checkout %s' % ref)
print "Running on", ref
print("Running on", ref)
results[ref] = do_scan()
return results

Expand All @@ -82,7 +82,7 @@ def print_table(table):
)

for row in rows:
print "|" + "|".join(row) + "|"
print("|" + "|".join(row) + "|")


if __name__ == '__main__':
Expand All @@ -97,7 +97,7 @@ def print_table(table):
try:
results = loop_over_refs(refs)
finally:
print "Returning you to %s" % head
print("Returning you to %s" % head)
commands.getstatus('git checkout %s' % head)

print_table(results)
2 changes: 1 addition & 1 deletion tools/python-fedora-api-test.py
Expand Up @@ -130,7 +130,7 @@

print('Adding comment')
result = bodhi.comment(update=alias, comment='yay', karma=1)
print result
print(result)
comment = result['comment']
assert comment['author'] == username
assert comment['text'] == u'yay'
Expand Down

0 comments on commit d776356

Please sign in to comment.