[packagedb-cli] Honor the --username and --password command line arguments
by Pierre-YvesChibon
commit b74b8f9a36cbe17350399094de2b4ba26830ae8f
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat May 24 17:11:41 2014 +0200
Honor the --username and --password command line arguments
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1100497
pkgdb2_cli.py | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index fd84fc0..e698dc7 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -61,14 +61,15 @@ def __do_login(username=None, password=None):
if pkgdbclient.is_logged_in:
return
else:
- if username is None:
+ if username is None and pkgdbclient.username is None:
try:
username = fedora_cert.read_user_cert()
except:
LOG.debug('Could not read Fedora cert, using login name')
username = raw_input('FAS username: ')
- password = getpass.getpass('FAS password: ')
- pkgdbclient.username = username
+ pkgdbclient.username = username
+ if password is None and pkgdbclient.password is None:
+ password = getpass.getpass('FAS password: ')
pkgdbclient.login(username, password)
@@ -672,6 +673,11 @@ def main():
return_code = 0
+ if arg.password:
+ pkgdbclient.password = arg.password
+ if arg.username:
+ pkgdbclient.username = arg.username
+
try:
arg.func(arg)
except KeyboardInterrupt:
9 years, 12 months
[packagedb-cli] Give the possibility to set the username and password outside of the login function
by Pierre-YvesChibon
commit e12281a5ae80fed1e0c47f50f4e6e2923a2b7f97
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat May 24 17:08:40 2014 +0200
Give the possibility to set the username and password outside of the login function
pkgdb2client.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 081a948..68739c2 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -86,6 +86,8 @@ class PkgDB(object):
self.session = requests.session()
self.insecure = insecure
self.__logged_in = False
+ self.username = None
+ self.password = None
def __send_request(self, url, method, params=None, data=None):
''' Send a http request to the provided URL with the provided
@@ -113,7 +115,7 @@ class PkgDB(object):
''' Return whether the user if logged in or not. '''
return self.__logged_in
- def login(self, username, password, openid_insecure=False):
+ def login(self, username=None, password=None, openid_insecure=False):
''' Login the user on pkgdb2.
:arg username: the FAS username of the user.
@@ -128,6 +130,14 @@ class PkgDB(object):
production.
:type openid_insecure: bool
'''
+ if not username:
+ username = self.username
+ if not password:
+ password = self.password
+
+ if not username or not password:
+ raise PkgDBAuthException('Username or password missing')
+
import re
from urlparse import urlparse, parse_qs
9 years, 12 months
[packagedb-cli] Add the missing beautifulsoup4 as a requirement
by Pierre-YvesChibon
commit 5fa9ed7f61ac02d74830680a2e47bef33df35b6e
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat May 24 17:06:33 2014 +0200
Add the missing beautifulsoup4 as a requirement
setup.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index d4f7438..cc14d3a 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,8 @@ setup(
]
},
install_requires=[
- 'requests', 'python-bugzilla', 'python-fedora', 'setuptools'],
+ 'requests', 'python-bugzilla', 'python-fedora', 'setuptools',
+ 'beautifulsoup4'],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
9 years, 12 months
[packagedb-cli] Add setuptools in the list of dependency
by Pierre-YvesChibon
commit 2576dc9a196a7dc17d1768dfb14565f316633a0f
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 14:31:21 2014 +0200
Add setuptools in the list of dependency
setup.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index c082246..d4f7438 100644
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,8 @@ setup(
"pkgdb-cli=pkgdb2_cli:main",
]
},
- install_requires=['requests', 'python-bugzilla', 'python-fedora'],
+ install_requires=[
+ 'requests', 'python-bugzilla', 'python-fedora', 'setuptools'],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
10 years
[packagedb-cli] Drop the pkgdb2version approach in favor of setup.py and relying on pkg_resources
by Pierre-YvesChibon
commit 000bf426b73bc3ddab79c2f92ed2845fcd381ffd
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 13:31:38 2014 +0200
Drop the pkgdb2version approach in favor of setup.py and relying on pkg_resources
pkgdb2client.py | 4 ++--
pkgdb2version.py | 18 ------------------
setup.py | 4 +---
3 files changed, 3 insertions(+), 23 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 975f2be..081a948 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -16,16 +16,16 @@
"""
import logging
+import pkg_resources
from fedora.client import AuthError
import requests
-import pkgdb2version
logging.basicConfig()
LOG = logging.getLogger("pkgdb2client")
-__version__ = pkgdb2version.__version__
+__version__ = pkg_resources.get_distribution('packagedb-cli').version
PKGDB_URL = r'https://admin.fedoraproject.org/pkgdb/'
diff --git a/setup.py b/setup.py
index 78f5e69..c082246 100644
--- a/setup.py
+++ b/setup.py
@@ -5,12 +5,10 @@ Setup script
from setuptools import setup
-from pkgdb2version import __version__
-
setup(
name='packagedb-cli',
description='A command line tool to access the Fedora Package Database.',
- version=__version__,
+ version='2.2',
license='GPLv2+',
download_url='https://fedorahosted.org/releases/p/a/packagedb-cli/',
url='https://fedorahosted.org/packagedb-cli/',
10 years
[packagedb-cli] Small pep8 clean up
by Pierre-YvesChibon
commit 11f73341e6cc81938fc2ae0d4217e81b1fad32ef
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 12:34:54 2014 +0200
Small pep8 clean up
pkgdb2_cli.py | 3 ++-
test.py | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index 2f9a742..fd84fc0 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -387,7 +387,8 @@ def do_acl(args):
'component': args.package})
print "{0} bugs open (new, assigned, needinfo)".format(len(bugbz))
- for pkg in sorted(output['packages'],
+ for pkg in sorted(
+ output['packages'],
key=lambda pkg: pkg['collection']['branchname'],
reverse=True):
if pkg['collection']['status'] == 'EOL':
diff --git a/test.py b/test.py
index 0648e85..421aff9 100644
--- a/test.py
+++ b/test.py
@@ -464,7 +464,6 @@ class TestPkgdDBAuth(unittest.TestCase):
def test_9_update_package_poc(self):
''' Test the update_package_poc function. '''
-
out = self.pkgdb.update_package_poc(
'guake', ['master', 'el6'], 'ralph')
10 years
[packagedb-cli] Remove un-used lines of code
by Pierre-YvesChibon
commit e627b73eb6c7ad7bfc2d5aa033ea2664335cdb11
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 12:34:02 2014 +0200
Remove un-used lines of code
test.py | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)
---
diff --git a/test.py b/test.py
index 0dfe8f5..0648e85 100644
--- a/test.py
+++ b/test.py
@@ -31,11 +31,9 @@ VERSION = time.mktime(datetime.datetime.utcnow().timetuple())
def auth_only(function):
""" Decorator to skip tests if AUTH is set to False """
- #global AUTH
@wraps(function)
def decorated_function(*args, **kwargs):
""" Decorated function, actually does the work. """
- #global AUTH
if AUTH:
return function(*args, **kwargs)
else:
@@ -100,9 +98,6 @@ class TestPkgdDB(unittest.TestCase):
out['packages'][0]['collection']['branchname'], 'f20')
self.assertEqual(
out['packages'][0]['package']['name'], 'guake')
- #self.assertEqual(
- #out['packages'][0]['point_of_contact'], 'pingou')
-
out = self.pkgdb.get_package('guake', ['f20', 'f19'])
self.assertEqual(
sorted(out.keys()),
@@ -117,8 +112,6 @@ class TestPkgdDB(unittest.TestCase):
out['packages'][0]['package']['name'], 'guake')
self.assertEqual(
out['packages'][1]['package']['name'], 'guake')
- #self.assertEqual(
- #out['packages'][0]['point_of_contact'], 'pingou')
def test_get_packager_acls(self):
''' Test the get_packager_acls function. '''
10 years
[packagedb-cli] Add a global boolean allowing to turn on/off the authenticated tests (saves time)
by Pierre-YvesChibon
commit 119b2c8a11e78cce2d2d1f8dbe1f967798940bd5
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 12:32:22 2014 +0200
Add a global boolean allowing to turn on/off the authenticated tests (saves time)
test.py | 40 +++++++++++++++++++++++++++++++++++-----
1 files changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/test.py b/test.py
index 9c81b92..0dfe8f5 100644
--- a/test.py
+++ b/test.py
@@ -7,24 +7,43 @@ import time
import unittest
import uuid
+from functools import wraps
+
import fedora_cert
from pkgdb2client import PkgDB, PkgDBException
PKGDB_URL = 'http://127.0.0.1:5000'
+AUTH = True
-try:
- USERNAME = fedora_cert.read_user_cert()
-except:
- USERNAME = raw_input('FAS username: ')
-PASSWORD = getpass.getpass('FAS password: ')
+if AUTH:
+ try:
+ USERNAME = fedora_cert.read_user_cert()
+ except:
+ USERNAME = raw_input('FAS username: ')
+ PASSWORD = getpass.getpass('FAS password: ')
COL_NAME = str(uuid.uuid1())[:30]
PKG_NAME = str(uuid.uuid1())[:30]
VERSION = time.mktime(datetime.datetime.utcnow().timetuple())
+def auth_only(function):
+ """ Decorator to skip tests if AUTH is set to False """
+ #global AUTH
+ @wraps(function)
+ def decorated_function(*args, **kwargs):
+ """ Decorated function, actually does the work. """
+ #global AUTH
+ if AUTH:
+ return function(*args, **kwargs)
+ else:
+ return 'Skipped'
+
+ return decorated_function
+
+
class TestPkgdDB(unittest.TestCase):
''' Un-authenticated pkgdb2 tests. '''
@@ -272,6 +291,7 @@ class TestPkgdDB(unittest.TestCase):
class TestPkgdDBAuth(unittest.TestCase):
''' Authenticated pkgdb2 tests. '''
+ @auth_only
def setUp(self):
""" set up data used in the tests.
setUp is called before each test function execution.
@@ -279,6 +299,7 @@ class TestPkgdDBAuth(unittest.TestCase):
self.pkgdb = PkgDB(PKGDB_URL, insecure=True)
self.pkgdb.login(USERNAME, PASSWORD)
+ @auth_only
def test_1_create_collection(self):
''' Test the create_collection function. '''
out = self.pkgdb.create_collection(
@@ -321,6 +342,7 @@ class TestPkgdDBAuth(unittest.TestCase):
out['messages'],
['Collection "%s" created' % COL_NAME])
+ @auth_only
def test_2_create_package(self):
''' Test the create_package function. '''
@@ -345,6 +367,7 @@ class TestPkgdDBAuth(unittest.TestCase):
out['messages'],
['Package created'])
+ @auth_only
def test_3_orphan_packages(self):
''' Test the orphan_packages function. '''
@@ -362,6 +385,7 @@ class TestPkgdDBAuth(unittest.TestCase):
'user: pingou changed point of contact of package: guake from: '
'pingou to: orphan on branch: el6'])
+ @auth_only
def test_4_unorphan_packages(self):
''' Test the unorphan_packages function. '''
@@ -378,6 +402,7 @@ class TestPkgdDBAuth(unittest.TestCase):
['Package guake has been unorphaned on master by pingou',
'Package guake has been unorphaned on el6 by pingou'])
+ @auth_only
def test_5_retire_packages(self):
''' Test the retire_packages function. '''
@@ -393,6 +418,7 @@ class TestPkgdDBAuth(unittest.TestCase):
['user: pingou updated package: guake status from: Approved to '
'Retired on branch: master'])
+ @auth_only
def test_6_unretire_packages(self):
''' Test the unretire_packages function. '''
@@ -408,6 +434,7 @@ class TestPkgdDBAuth(unittest.TestCase):
['user: pingou updated package: guake status from: Retired to '
'Approved on branch: master'])
+ @auth_only
def test_7_update_acl(self):
''' Test the update_acl function. '''
@@ -425,6 +452,7 @@ class TestPkgdDBAuth(unittest.TestCase):
['Nothing to update on branch: master for acl: commit',
'Nothing to update on branch: el6 for acl: commit'])
+ @auth_only
def test_8_update_collection_status(self):
''' Test the update_collection_status function. '''
@@ -439,9 +467,11 @@ class TestPkgdDBAuth(unittest.TestCase):
out['messages'],
['Collection updated from "Active" to "EOL"'])
+ @auth_only
def test_9_update_package_poc(self):
''' Test the update_package_poc function. '''
+
out = self.pkgdb.update_package_poc(
'guake', ['master', 'el6'], 'ralph')
10 years
[packagedb-cli] Fix the test and expand them to test get_package for multiple branches
by Pierre-YvesChibon
commit d2f6cc03b915b9fbd7fc65826f410b3e4f3ce19b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 12:31:56 2014 +0200
Fix the test and expand them to test get_package for multiple branches
test.py | 71 ++++++++++++++++++++++++++++++++-------------------------------
1 files changed, 36 insertions(+), 35 deletions(-)
---
diff --git a/test.py b/test.py
index 0d7ec61..9c81b92 100644
--- a/test.py
+++ b/test.py
@@ -81,20 +81,23 @@ class TestPkgdDB(unittest.TestCase):
out['packages'][0]['collection']['branchname'], 'f20')
self.assertEqual(
out['packages'][0]['package']['name'], 'guake')
- self.assertEqual(
- out['packages'][0]['point_of_contact'], 'pingou')
-
- ## We do not support multi-branches yet
- #out = self.pkgdb.get_package('guake', ['f20', 'f19'])
- #self.assertEqual(
- #sorted(out.keys()),
- #['output', 'packages'])
- #self.assertEqual(out['output'], 'ok')
- #self.assertEqual(len(out['packages']), 2)
- #self.assertEqual(
- #out['packages'][0]['collection']['branchname'], 'f20')
#self.assertEqual(
- #out['packages'][0]['package']['name'], 'guake')
+ #out['packages'][0]['point_of_contact'], 'pingou')
+
+ out = self.pkgdb.get_package('guake', ['f20', 'f19'])
+ self.assertEqual(
+ sorted(out.keys()),
+ ['output', 'packages'])
+ self.assertEqual(out['output'], 'ok')
+ self.assertEqual(len(out['packages']), 2)
+ self.assertEqual(
+ out['packages'][0]['collection']['branchname'], 'f19')
+ self.assertEqual(
+ out['packages'][1]['collection']['branchname'], 'f20')
+ self.assertEqual(
+ out['packages'][0]['package']['name'], 'guake')
+ self.assertEqual(
+ out['packages'][1]['package']['name'], 'guake')
#self.assertEqual(
#out['packages'][0]['point_of_contact'], 'pingou')
@@ -111,35 +114,35 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out.keys()),
['acls', 'output', 'page', 'page_total'])
- self.assertEqual(len(out['acls']), 239)
+ self.assertTrue(len(out['acls']) >= 239)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', page=3)
self.assertEqual(
sorted(out.keys()),
['acls', 'output', 'page', 'page_total'])
- self.assertEqual(len(out['acls']), 250)
+ self.assertTrue(len(out['acls']) >= 250)
self.assertEqual(out['page_total'], 5)
out = self.pkgdb.get_packager_acls('pingou', count=True)
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 1043)
+ self.assertTrue(out['acls_count'] >= 1043)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', poc=True, count=True)
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 804)
+ self.assertTrue(out['acls_count'] >= 804)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', poc=False, count=True)
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 239)
+ self.assertTrue(out['acls_count'] >= 239)
self.assertEqual(out['page_total'], 1)
def test_get_packager_stats(self):
@@ -261,7 +264,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out.keys()),
['output', 'packages', 'page', 'page_total'])
- self.assertTrue(out['packages'] >= 1351)
+ self.assertTrue(out['packages'] >= 1340)
self.assertEqual(out['page'], 1)
self.assertEqual(out['page_total'], 1)
@@ -354,10 +357,10 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(
out['messages'],
- ['user: pingou changed poc of package: guake from: pingou '
- 'to: orphan on branch: master',
- 'user: pingou changed poc of package: guake from: pingou '
- 'to: orphan on branch: el6'])
+ ['user: pingou changed point of contact of package: guake from: '
+ 'pingou to: orphan on branch: master',
+ 'user: pingou changed point of contact of package: guake from: '
+ 'pingou to: orphan on branch: el6'])
def test_4_unorphan_packages(self):
''' Test the unorphan_packages function. '''
@@ -419,10 +422,8 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(
out['messages'],
- ['user: pingou set acl: commit of package: guake from: '
- 'Awaiting Review to: Awaiting Review on branch: master',
- 'user: pingou set acl: commit of package: guake from: '
- 'Awaiting Review to: Awaiting Review on branch: el6'])
+ ['Nothing to update on branch: master for acl: commit',
+ 'Nothing to update on branch: el6 for acl: commit'])
def test_8_update_collection_status(self):
''' Test the update_collection_status function. '''
@@ -451,10 +452,10 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(
out['messages'],
- ['user: pingou changed poc of package: guake from: orphan to: '
- 'ralph on branch: master',
- 'user: pingou changed poc of package: guake from: pingou to: '
- 'ralph on branch: el6'])
+ ['user: pingou changed point of contact of package: guake from: '
+ 'orphan to: ralph on branch: master',
+ 'user: pingou changed point of contact of package: guake from: '
+ 'pingou to: ralph on branch: el6'])
out = self.pkgdb.update_package_poc(
'guake', ['master', 'el6'], 'pingou')
@@ -466,10 +467,10 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(
out['messages'],
- ['user: pingou changed poc of package: guake from: ralph to: '
- 'pingou on branch: master',
- 'user: pingou changed poc of package: guake from: ralph to: '
- 'pingou on branch: el6'])
+ ['user: pingou changed point of contact of package: guake from: '
+ 'ralph to: pingou on branch: master',
+ 'user: pingou changed point of contact of package: guake from: '
+ 'ralph to: pingou on branch: el6'])
def suite():
10 years
[packagedb-cli] Update the setup.py to rely on pkgdb2version to set its version
by Pierre-YvesChibon
commit 7fa5392c7839dfd33995fb080da00695c846165e
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 20 11:40:56 2014 +0200
Update the setup.py to rely on pkgdb2version to set its version
Fixes https://github.com/fedora-infra/packagedb-cli/issues/6
setup.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/setup.py b/setup.py
index 02b5bfa..78f5e69 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ Setup script
from setuptools import setup
-from pkgdb2client import __version__
+from pkgdb2version import __version__
setup(
name='packagedb-cli',
@@ -16,7 +16,7 @@ setup(
url='https://fedorahosted.org/packagedb-cli/',
author='Pierre-Yves Chibon',
author_email='pingou(a)pingoured.fr',
- py_modules=['pkgdb2client', 'pkgdb2_cli'],
+ py_modules=['pkgdb2client', 'pkgdb2_cli', 'pkgdb2version'],
entry_points={
'console_scripts': [
"pkgdb-cli=pkgdb2_cli:main",
10 years