[packagedb-cli] Python 3 compatibility fixes
by Pierre-YvesChibon
commit 8ff898bba4fd645e9345f50b681bb520630c2aa6
Author: Ville Skyttä <ville.skytta(a)iki.fi>
Date: Sat Dec 5 20:04:31 2015 +0200
Python 3 compatibility fixes
pkgdb2client/__init__.py | 12 +++++-------
pkgdb2client/admin.py | 6 ++++--
setup.py | 2 +-
test.py | 3 ++-
4 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index d21b654..6dc374d 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -15,15 +15,13 @@
# license.
"""
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
import getpass
import logging
import os
import pkg_resources
+from six.moves import input, cPickle as pickle, xrange
+
import fedora_cert
from fedora.client import AuthError
import requests
@@ -95,7 +93,7 @@ def ask_password(username=None, bad_password=False):
username = fedora_cert.read_user_cert()
except fedora_cert.fedora_cert_error:
LOG.debug('Could not read Fedora cert, asking for username')
- username = raw_input("Username: ")
+ username = input("Username: ")
password = getpass.getpass("FAS password for user {0}: ".format(username))
return username, password
@@ -176,7 +174,7 @@ class PkgDB(object):
except:
data = {}
try:
- with open(self.sessionfile, 'wb', 0600) as sessionfo:
+ with open(self.sessionfile, 'wb', 0o600) as sessionfo:
sessionfo.seek(0)
data["cookies"] = self.session.cookies
pickle.dump(data, sessionfo)
@@ -218,7 +216,7 @@ class PkgDB(object):
raise PkgDBAuthException('Username or password missing')
import re
- from urlparse import urlparse, parse_qs
+ from six.moves.urllib.parse import urlparse, parse_qs
fedora_openid_api = r'https://id.fedoraproject.org/api/v1/'
fedora_openid = r'^http(s)?:\/\/id\.(|stg.|dev.)?fedoraproject'\
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 8f0673d..086d159 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -20,6 +20,8 @@ from fedora.client import (AppError, ServerError)
import argparse
import logging
+from six.moves import input
+
from pkgdb2client import PkgDB, PkgDBException, __version__
from pkgdb2client.cli import ActionError
import pkgdb2client
@@ -257,7 +259,7 @@ def _ask_what_to_do(messages):
print("==> " + "All checks were good")
print('\nWhat should we do about this requests?')
- action = raw_input('approve, deny, pass: ')
+ action = input('approve, deny, pass: ')
if action.lower() not in ['a', 'd', 'p', 'approve', 'deny', 'pass']:
print('No valid action specified, just ignoring for now')
action = 'pass'
@@ -312,7 +314,7 @@ def __handle_request_package(actionid, action):
)
elif decision in ('deny', 'd'):
- message = raw_input(
+ message = input(
'Could you explain why you declined this request? (this message '
'will be sent to the user)\n=>')
data = PKGDBCLIENT.handle_api_call(
diff --git a/setup.py b/setup.py
index cabfe5c..156bcf1 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ setup(
]
},
install_requires=[
- 'requests', 'python-bugzilla', 'python-fedora', 'setuptools',
+ 'requests', 'python-bugzilla', 'python-fedora', 'setuptools', 'six',
'beautifulsoup4'],
classifiers=[
'Development Status :: 5 - Production/Stable',
diff --git a/test.py b/test.py
index 9024664..9bb86b1 100644
--- a/test.py
+++ b/test.py
@@ -7,6 +7,7 @@ import unittest
import uuid
from functools import wraps
+from six.moves import input
import fedora_cert
@@ -20,7 +21,7 @@ if AUTH:
try:
USERNAME = fedora_cert.read_user_cert()
except:
- USERNAME = raw_input('FAS username: ')
+ USERNAME = input('FAS username: ')
PASSWORD = getpass.getpass('FAS password: ')
if not PASSWORD:
AUTH = False
8 years, 5 months
[packagedb-cli] Fix pkgdb-admin checks
by Pierre-YvesChibon
commit a9c8dd889a5641b5683583570ed08732e1786386
Author: Till Maas <opensource(a)till.name>
Date: Sat Dec 5 10:32:24 2015 +0100
Fix pkgdb-admin checks
- bug.comments[0].author is not a valid attribute
- Actually check for the assignee
- Always use datetime.datetime
pkgdb2client/utils.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index 4ca3f53..2b1e6cb 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -20,7 +20,7 @@ import json
import os
import tempfile
-from datetime import datetime
+import datetime
import requests
import fedora_cert
@@ -267,11 +267,11 @@ 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:
+ if flag_setter == bug.creator:
messages["bad"].append(
'Review approved by the person creating '
'the ticket {0}'.format(flag_setter))
- if flag_setter != bug.comments[0].author:
+ if flag_setter != bug.assigned_to:
messages["bad"].append(
'Review not approved by the assignee of '
'the ticket {0}'.format(flag_setter))
@@ -379,7 +379,7 @@ def get_rhel_cache(rhel_ver):
url = base_url % rhel_ver
output_filename = os.path.join(
tempfile.gettempdir(), '%s_%s' % (
- datetime.utcnow().date().strftime('%Y%m%d'),
+ datetime.datetime.utcnow().date().strftime('%Y%m%d'),
os.path.basename(url))
)
8 years, 5 months
[packagedb-cli] Fix SyntaxWarning
by Pierre-YvesChibon
commit c854e5dfd4bb4c784edb1c2d34f80b2ca7cbc0b5
Author: Till Maas <opensource(a)till.name>
Date: Sat Dec 5 10:17:31 2015 +0100
Fix SyntaxWarning
global should be used before BZCLIENT is accessed:
pkgdb2client/utils.py:51: SyntaxWarning: name 'BZCLIENT' is used prior
to global declaration
global BZCLIENT
pkgdb2client/utils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index 4b91dbe..4ca3f53 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -46,9 +46,9 @@ FASCLIENT = AccountSystem(
def _get_bz():
''' Return a bugzilla object. '''
+ global BZCLIENT
if not BZCLIENT:
try:
- global BZCLIENT
BZCLIENT = Bugzilla(url=RH_BZ_API)
BZCLIENT.logged_in
except xmlrpclib.Error:
8 years, 5 months
[packagedb-cli] Fix syntax error
by Pierre-YvesChibon
commit 66add6d2ccfa9b36577b40b0e868431a271e1745
Author: Till Maas <opensource(a)till.name>
Date: Sat Dec 5 10:15:19 2015 +0100
Fix syntax error
pkgdb2client/utils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index 5d47765..4b91dbe 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'].encode('utf-8')))
+ 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] Signal when a review was approved more than 60 days ago
by Pierre-YvesChibon
commit c6fd04316af2b7c49d3a50f8984fbbc5c64fdb95
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Dec 3 10:33:21 2015 +0100
Signal when a review was approved more than 60 days ago
Fixes https://github.com/fedora-infra/packagedb-cli/issues/65
pkgdb2client/utils.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index d69d2cd..5d47765 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -275,6 +275,15 @@ def check_package_creation(info, bugid, pkgdbclient):
messages["bad"].append(
'Review not approved by the assignee of '
'the ticket {0}'.format(flag_setter))
+ update_dt = flag.get('modification_date')
+ if update_dt:
+ dt = datetime.datetime.strptime(
+ update_dt.value, '%Y%m%dT%H:%M:%S')
+ delta = datetime.datetime.utcnow().date() - dt.date()
+ if delta.days > 60:
+ messages["bad"].append(
+ 'Review was approved more than 60 days ago, '
+ 'on {0}.'.format(dt.strftime('%Y-%m-%d %H:%M:%S')))
else:
messages["bad"].append(
'Review not approved, flag set to: {0}'.format(
8 years, 5 months
[packagedb-cli: 18/18] Merge pull request #64 from fedora-infra/avoid_none
by Pierre-YvesChibon
commit 405c7fc0ea1e3db963bb0996c02d440f74a20d25
Merge: 3012f56 c66ded0
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Dec 2 15:55:25 2015 +0100
Merge pull request #64 from fedora-infra/avoid_none
Make sure we never return None when we expect a dictionary
pkgdb2client/__init__.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
8 years, 5 months
[packagedb-cli: 17/18] Make sure we never return None when we expect a dictionary
by Pierre-YvesChibon
commit c66ded00c72eb3c310fb977400912f2c39114adf
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Dec 2 15:52:28 2015 +0100
Make sure we never return None when we expect a dictionary
Fixes https://github.com/fedora-infra/packagedb-cli/issues/34
pkgdb2client/__init__.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index a4743c9..d21b654 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -360,6 +360,9 @@ class PkgDB(object):
'No output returned by %s' % response.url)
else:
raise PkgDBException(output)
+ elif output is None:
+ raise PkgDBException(
+ 'No output returned by %s' % response.url)
return output
8 years, 5 months
[packagedb-cli: 16/18] Merge pull request #63 from fedora-infra/better_checks
by Pierre-YvesChibon
commit 3012f5622ab94c67c4d6c1633ae5d750738b4f58
Merge: aaa3075 9fb5bde
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Dec 2 15:10:10 2015 +0100
Merge pull request #63 from fedora-infra/better_checks
Improve the checks done when processing a new package request
pkgdb2client/utils.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
8 years, 5 months
[packagedb-cli: 15/18] Check the component and product of the review request
by Pierre-YvesChibon
commit 9fb5bde435ce954d65c98b65b915857f4d4ad5c2
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 12:17:23 2015 +0100
Check the component and product of the review request
Fixes https://github.com/fedora-infra/packagedb-cli/issues/57
pkgdb2client/utils.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index adb1b18..d69d2cd 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -239,6 +239,16 @@ def check_package_creation(info, bugid, pkgdbclient):
'The bug title does not fit the expected one\n'
' exp: "{0}" vs obs: "{1}"'.format(expected, bug.summary))
+ if bug.component != 'Package Review':
+ messages["bad"].append(
+ 'Wrong bug component \n'
+ ' exp: "Package Review" vs obs: "{0}"'.format(bug.component))
+
+ if bug.product != 'Fedora':
+ messages["bad"].append(
+ 'Wrong bug product \n'
+ ' exp: "Fedora" vs obs: "{0}"'.format(bug.product))
+
# Check if the participants are packagers
for user in get_users_in_bug(bugid):
if not is_packager(user):
8 years, 5 months
[packagedb-cli: 14/18] Check if the person who approved the review is the assignee or not
by Pierre-YvesChibon
commit a1b6edad1f86f046665762a2195c0f9a2c8e0016
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 1 12:14:06 2015 +0100
Check if the person who approved the review is the assignee or not
Fixes https://github.com/fedora-infra/packagedb-cli/issues/58
pkgdb2client/utils.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index c19dcf9..adb1b18 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -261,6 +261,10 @@ def check_package_creation(info, bugid, pkgdbclient):
messages["bad"].append(
'Review approved by the person creating '
'the ticket {0}'.format(flag_setter))
+ if flag_setter != bug.comments[0].author:
+ messages["bad"].append(
+ 'Review not approved by the assignee of '
+ 'the ticket {0}'.format(flag_setter))
else:
messages["bad"].append(
'Review not approved, flag set to: {0}'.format(
8 years, 5 months