[packagedb-cli: 13/18] Check if the person approving the review is the same as the one creating it
by Pierre-YvesChibon
commit 3d1dcaca50bceda1354cb397cd407d0c3089f24f
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 12:11:23 2015 +0100
Check if the person approving the review is the same as the one creating it
Fixes https://github.com/fedora-infra/packagedb-cli/issues/56
pkgdb2client/utils.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index e543336..c19dcf9 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -257,6 +257,10 @@ def check_package_creation(info, bugid, pkgdbclient):
messages["bad"].append(
'Review approved by non-packager {0}'.format(
flag_setter))
+ if flag_setter == bug.comments[0].author:
+ messages["bad"].append(
+ 'Review approved by the person creating '
+ 'the ticket {0}'.format(flag_setter))
else:
messages["bad"].append(
'Review not approved, flag set to: {0}'.format(
8 years, 5 months
[packagedb-cli: 12/18] Merge pull request #61 from fedora-infra/fix_encoding
by Pierre-YvesChibon
commit aaa3075818f0acb40c53d4efbcbc9413f754c7b2
Merge: dd52230 82d3734
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Dec 2 09:32:23 2015 +0100
Merge pull request #61 from fedora-infra/fix_encoding
Fix encoding to make things UTF-8
pkgdb2client/admin.py | 22 ++++++++++++++--------
pkgdb2client/utils.py | 2 +-
2 files changed, 15 insertions(+), 9 deletions(-)
---
8 years, 5 months
[packagedb-cli: 11/18] Handle the situation where the description or the upstream info are None
by Pierre-YvesChibon
commit 82d373471ffc895c52a12d52a1334983fe1140b6
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 17:15:52 2015 +0100
Handle the situation where the description or the upstream info are None
pkgdb2client/admin.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 77db223..8f0673d 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -278,16 +278,22 @@ def __handle_request_package(actionid, action):
decision = _ask_what_to_do(msgs)
if decision in ('a', 'approve'):
+ desc = action['info'].get('pkg_description', None)
+ if desc:
+ desc = desc.encode('utf-8')
+ upstream = action['info'].get('pkg_upstream_url', None)
+ if upstream:
+ upstream = upstream.encode('utf-8')
data = PKGDBCLIENT.create_package(
pkgname=action['info']['pkg_name'].encode('utf-8'),
summary=action['info']['pkg_summary'].encode('utf-8'),
- description=action['info']['pkg_description'].encode('utf-8'),
+ description=desc,
review_url=action['info']['pkg_review_url'].encode('utf-8'),
status=action['info']['pkg_status'].encode('utf-8'),
shouldopen=True,
branches=action['info']['pkg_collection'].encode('utf-8'),
poc=action['info']['pkg_poc'].encode('utf-8'),
- upstream_url=action['info']['pkg_upstream_url'].encode('utf-8'),
+ upstream_url=upstream,
critpath=action['info']['pkg_critpath'],
)
8 years, 5 months
[packagedb-cli: 10/18] Encode all the fields, this way we'll be sure to have consistent data types
by Pierre-YvesChibon
commit 9c670f6a575a3d918660585aab81446317aad96a
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 16:22:48 2015 +0100
Encode all the fields, this way we'll be sure to have consistent data types
pkgdb2client/admin.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 9f1d2a1..77db223 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -279,15 +279,15 @@ def __handle_request_package(actionid, action):
decision = _ask_what_to_do(msgs)
if decision in ('a', 'approve'):
data = PKGDBCLIENT.create_package(
- pkgname=action['info']['pkg_name'],
+ pkgname=action['info']['pkg_name'].encode('utf-8'),
summary=action['info']['pkg_summary'].encode('utf-8'),
description=action['info']['pkg_description'].encode('utf-8'),
- review_url=action['info']['pkg_review_url'],
- status=action['info']['pkg_status'],
+ review_url=action['info']['pkg_review_url'].encode('utf-8'),
+ status=action['info']['pkg_status'].encode('utf-8'),
shouldopen=True,
- branches=action['info']['pkg_collection'],
- poc=action['info']['pkg_poc'],
- upstream_url=action['info']['pkg_upstream_url'],
+ branches=action['info']['pkg_collection'].encode('utf-8'),
+ poc=action['info']['pkg_poc'].encode('utf-8'),
+ upstream_url=action['info']['pkg_upstream_url'].encode('utf-8'),
critpath=action['info']['pkg_critpath'],
)
8 years, 5 months
[packagedb-cli: 9/18] Some more encoding to UTF-8 in case we go through with it
by Pierre-YvesChibon
commit 9d229c627c1851db2177d17171a54826c81798ce
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 12:03:21 2015 +0100
Some more encoding to UTF-8 in case we go through with it
pkgdb2client/admin.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 93d94aa..9f1d2a1 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -280,8 +280,8 @@ def __handle_request_package(actionid, action):
if decision in ('a', 'approve'):
data = PKGDBCLIENT.create_package(
pkgname=action['info']['pkg_name'],
- summary=action['info']['pkg_summary'],
- description=action['info']['pkg_description'],
+ summary=action['info']['pkg_summary'].encode('utf-8'),
+ description=action['info']['pkg_description'].encode('utf-8'),
review_url=action['info']['pkg_review_url'],
status=action['info']['pkg_status'],
shouldopen=True,
8 years, 5 months
[packagedb-cli: 8/18] Encode the summary retrieved to UTF-8
by Pierre-YvesChibon
commit e2fd9599398d07b0ecda9a88e84848173021b3a7
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 11:59:21 2015 +0100
Encode the summary retrieved to UTF-8
Fixes https://github.com/fedora-infra/packagedb-cli/issues/60
pkgdb2client/utils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index dbb516a..e543336 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -229,7 +229,7 @@ def check_package_creation(info, bugid, pkgdbclient):
# Check if the title of the bug fits the expectations
expected = 'Review Request: {0} - {1}'.format(
- info['pkg_name'], info['pkg_summary'])
+ info['pkg_name'], info['pkg_summary'].encode('utf-8')))
if bug.summary == expected:
messages["good"].append("Summary of bug {0} is: {1}".format(
8 years, 5 months
[packagedb-cli: 7/18] Merge pull request #55 from tyll/show_tests
by Pierre-YvesChibon
commit dd522309cb2cd5a9ad6520ab77e9dd4713533026
Merge: 990bb26 15097d0
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 11:57:53 2015 +0100
Merge pull request #55 from tyll/show_tests
Show successful tests
pkgdb2client/admin.py | 8 ++++-
pkgdb2client/utils.py | 74 ++++++++++++++++++++++++++----------------------
2 files changed, 46 insertions(+), 36 deletions(-)
---
8 years, 5 months
[packagedb-cli: 6/18] Show successful tests
by Pierre-YvesChibon
commit 15097d0316a4fed9d4fadd8fefc6b669166ede23
Author: Till Maas <opensource(a)till.name>
Date: Thu Nov 26 22:39:05 2015 +0100
Show successful tests
This addresses #53
pkgdb2client/admin.py | 8 ++++-
pkgdb2client/utils.py | 74 ++++++++++++++++++++++++++----------------------
2 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 642b746..93d94aa 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -249,8 +249,12 @@ def _ask_what_to_do(messages):
''' Print the given list of information messages and ask the user
what to do, ie: approve, deny, pass
'''
- for message in messages:
- print(message)
+ for message in messages["good"]:
+ print("[+] " + message)
+ for message in messages["bad"]:
+ print("[-] " + message)
+ if not messages["bad"]:
+ print("==> " + "All checks were good")
print('\nWhat should we do about this requests?')
action = raw_input('approve, deny, pass: ')
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index b2b7ecb..dbb516a 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -223,34 +223,44 @@ def check_package_creation(info, bugid, pkgdbclient):
a packager
- ...
'''
- messages = []
+ messages = dict(good=[], bad=[])
bug = get_bug(bugid)
# Check if the title of the bug fits the expectations
expected = 'Review Request: {0} - {1}'.format(
info['pkg_name'], info['pkg_summary'])
- if bug.summary != expected:
- messages.append(
- ' ! The bug title does not fit the expected one\n'
+
+ if bug.summary == expected:
+ messages["good"].append("Summary of bug {0} is: {1}".format(
+ bugid, bug.summary))
+ else:
+ messages["bad"].append(
+ 'The bug title does not fit the expected one\n'
' exp: "{0}" vs obs: "{1}"'.format(expected, bug.summary))
# Check if the participants are packagers
for user in get_users_in_bug(bugid):
if not is_packager(user):
- messages.append(' ! User {0} is not a packager'.format(user))
+ messages["bad"].append(
+ 'Non-packager {0} commented on review bug'.format(user))
# Check who updated the fedora-review flag to +
for flag in bug.flags:
- if flag['name'] == 'fedora-review' and flag['status'] == '+':
- if not is_packager(flag['setter']):
- messages.append(
- ' ! User {0} is not a packager but set the '
- 'fedora-review flag to `+`'.format(flag['setter']))
- elif flag['name'] == 'fedora-review' and flag['status'] != '+':
- messages.append(
- ' ! fedora-review flag is no `+` but is still `%s`' %
- flag['status'])
+ if flag['name'] == 'fedora-review':
+ if flag['status'] == '+':
+ flag_setter = flag['setter']
+ if is_packager(flag_setter):
+ messages["good"].append(
+ 'Review approved by packager {0}'.format(flag_setter))
+ else:
+ messages["bad"].append(
+ 'Review approved by non-packager {0}'.format(
+ flag_setter))
+ else:
+ messages["bad"].append(
+ 'Review not approved, flag set to: {0}'.format(
+ flag['status']))
msgs2 = check_branch_creation(
pkgdbclient,
@@ -260,10 +270,8 @@ def check_package_creation(info, bugid, pkgdbclient):
new_pkg=True,
)
- if not messages and msgs2[0].startswith(' + All checks cleared'):
- messages.append(
- ' + All checks cleared for review {0}: {1}'.format(
- bugid, info['pkg_name']))
+ messages["bad"].extend(msgs2["bad"])
+ messages["good"].extend(msgs2["good"])
return messages
@@ -279,15 +287,16 @@ def check_branch_creation(pkgdbclient, pkg_name, clt_name, user,
- If the person asking for the branch is a packager
- ...
'''
- messages = []
+
+ messages = dict(good=[], bad=[])
# check if the package already exists
if not new_pkg:
try:
pkginfo = pkgdbclient.get_package(pkg_name)
except pkgdb2client.PkgDBException:
- messages.append(
- ' ! Packages {0} not found in pkgdb'.format(pkg_name)
+ messages["bad"].append(
+ 'Package {0} not found in pkgdb'.format(pkg_name)
)
return messages
@@ -298,21 +307,23 @@ def check_branch_creation(pkgdbclient, pkg_name, clt_name, user,
]
if clt_name in branches:
- messages.append(
- ' ! Packages {0} already has the requested branch '
+ messages["bad"].append(
+ 'Packages {0} already has the requested branch '
'`{1}`'.format(pkg_name, clt_name)
)
# Check if user is a packager
- if not is_packager(user):
- messages.append(' ! User {0} is not a packager'.format(user))
+ if is_packager(user):
+ messages["good"].append('Requester {0} is a packager'.format(user))
+ else:
+ messages["bad"].append('Requester {0} is not a packager'.format(user))
# EPEL checks
if clt_name.lower().startswith(('el', 'epel')):
rhel_data = get_rhel_cache(clt_name[-1])
if pkg_name in rhel_data['packages']:
- messages.append(
- ' ! `%s` is present in RHEL %s with version: %s on arch: %s'
+ messages["bad"].append(
+ '`%s` is present in RHEL %s with version: %s on arch: %s'
% (
pkg_name, clt_name[-1],
rhel_data['packages'][pkg_name]['version'],
@@ -320,16 +331,11 @@ def check_branch_creation(pkgdbclient, pkg_name, clt_name, user,
)
)
else:
- messages.append(
- ' + `%s` is *not* present in RHEL %s' % (
+ messages["good"].append(
+ '`%s` is *not* present in RHEL %s' % (
pkg_name, clt_name[-1])
)
- if not messages:
- messages.append(
- ' + All checks cleared for branch {0} for package {1}'.format(
- clt_name, pkg_name))
-
return messages
8 years, 5 months
[packagedb-cli: 5/18] Merge pull request #59 from tyll/pep8
by Pierre-YvesChibon
commit 990bb266579c7b7f627e91a9e3b4db50bf2ae5a3
Merge: 4a3929e a4ec118
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sun Nov 29 11:12:32 2015 +0100
Merge pull request #59 from tyll/pep8
Fix pep8 compliance
pkgdb2client/admin.py | 4 ++--
pkgdb2client/utils.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
---
8 years, 5 months
[packagedb-cli: 4/18] Fix pep8 compliance
by Pierre-YvesChibon
commit a4ec118259b38199577aace559aa353cf5f8572f
Author: Till Maas <opensource(a)till.name>
Date: Sat Nov 28 23:10:29 2015 +0100
Fix pep8 compliance
pkgdb2client/admin.py | 4 ++--
pkgdb2client/utils.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 8d62743..642b746 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -405,8 +405,8 @@ def do_process(args):
if action['action'] == 'request.package':
try:
PKGDBCLIENT.get_package(action['info']['pkg_name'])
- print('Package {0} found, requalifying request.package ' \
- 'in request.branch'.format(action['info']['pkg_name']))
+ print('Package {0} found, requalifying request.package '
+ 'in request.branch'.format(action['info']['pkg_name']))
# Adjusting the input format
action['action'] = 'request.branch'
action['package'] = {'name': action['info']['pkg_name']}
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index d764771..b2b7ecb 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -59,8 +59,8 @@ def _get_bz():
def bz_login():
''' Login on bugzilla. '''
- print('To keep going, we need to authenticate against bugzilla' \
- ' at {0}'.format(RH_BZ_API))
+ print('To keep going, we need to authenticate against bugzilla'
+ ' at {0}'.format(RH_BZ_API))
username = raw_input("Bugzilla user: ")
password = getpass.getpass("Bugzilla password: ")
8 years, 5 months