[packagedb-cli: 3/18] Merge pull request #54 from fedora-infra/more_py3
by Pierre-YvesChibon
commit 4a3929e2b23d4bebd3f3197ea03313d550dab2e5
Merge: 279d8f5 bc4075b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Fri Nov 27 18:59:33 2015 +0100
Merge pull request #54 from fedora-infra/more_py3
Improve support for python 3
pkgdb2client/__init__.py | 4 +-
pkgdb2client/admin.py | 64 +++++++++++++++++++++++-----------------------
pkgdb2client/cli.py | 8 +++---
pkgdb2client/utils.py | 4 +-
4 files changed, 40 insertions(+), 40 deletions(-)
---
8 years, 6 months
[packagedb-cli: 2/18] Adjust catching the exception to be both py2 and 3 compatible
by Pierre-YvesChibon
commit bc4075bd8b7cea0f609e26495bccaa6f3cdc7482
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 26 16:09:36 2015 +0100
Adjust catching the exception to be both py2 and 3 compatible
pkgdb2client/__init__.py | 2 +-
pkgdb2client/admin.py | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index 85405a4..a4743c9 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -347,7 +347,7 @@ class PkgDB(object):
output = None
try:
output = response.json()
- except Exception, err:
+ except Exception as err:
LOG.debug(response.text)
raise PkgDBException('Error while decoding JSON: {0}'.format(err))
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 348b7c8..8d62743 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -436,7 +436,7 @@ def main():
# Parse the commandline
try:
arg = parser.parse_args()
- except argparse.ArgumentTypeError, err:
+ except argparse.ArgumentTypeError as err:
print("\nError: {0}".format(err))
return 2
@@ -480,27 +480,27 @@ def main():
except KeyboardInterrupt:
print("\nInterrupted by user.")
return_code = 1
- except ServerError, err:
+ except ServerError as err:
LOG.debug('ServerError')
print('{0}'.format(err))
return_code = 3
- except ActionError, err:
+ except ActionError as err:
LOG.debug('ActionError')
print('{0}'.format(err.message))
return_code = 7
- except AppError, err:
+ except AppError as err:
LOG.debug('AppError')
print('{0}: {1}'.format(err.name, err.message))
return_code = 4
- except PkgDBException, err:
+ except PkgDBException as err:
LOG.debug('PkgDBException')
print('{0}'.format(err))
return_code = 8
- except ValueError, err:
+ except ValueError as err:
print('Error: {0}'.format(err))
print('Did you log in?')
return_code = 6
- except Exception, err:
+ except Exception as err:
print('Error: {0}'.format(err))
logging.exception("Generic error catched:")
return_code = 5
8 years, 6 months
[packagedb-cli: 1/18] Call the print function instead of the print statement to be py3 compatible
by Pierre-YvesChibon
commit 2afc7e6d2f14583ce97ed090ebcee4342757f7f3
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 26 16:07:18 2015 +0100
Call the print function instead of the print statement to be py3 compatible
pkgdb2client/__init__.py | 2 +-
pkgdb2client/admin.py | 50 +++++++++++++++++++++++-----------------------
pkgdb2client/cli.py | 8 +++---
pkgdb2client/utils.py | 4 +-
4 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index f229fec..85405a4 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -89,7 +89,7 @@ def ask_password(username=None, bad_password=False):
:rtype: tuple
"""
if bad_password:
- print "Bad password, please retry"
+ print("Bad password, please retry")
if not username:
try:
username = fedora_cert.read_user_cert()
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index f93ac93..348b7c8 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -192,7 +192,7 @@ def do_info(args):
LOG.info("action : {0}".format(actionid))
action = PKGDBCLIENT.handle_api_call('/admin/action/%s' % actionid)
- print _action2msg(action)
+ print(_action2msg(action))
def do_list(args):
@@ -218,10 +218,10 @@ def do_list(args):
ids = []
for action in data['actions']:
- print _action2msg(action)
+ print(_action2msg(action))
ids.append(action["id"])
- print 'Total: {0} actions'.format(len(ids))
+ print('Total: {0} actions'.format(len(ids)))
return ids
@@ -242,7 +242,7 @@ def do_update(args):
)
for msg in data.get('messages', []):
- print msg
+ print(msg)
def _ask_what_to_do(messages):
@@ -250,12 +250,12 @@ def _ask_what_to_do(messages):
what to do, ie: approve, deny, pass
'''
for message in messages:
- print message
+ print(message)
- print '\nWhat should we do about this requests?'
+ print('\nWhat should we do about this requests?')
action = raw_input('approve, deny, pass: ')
if action.lower() not in ['a', 'd', 'p', 'approve', 'deny', 'pass']:
- print 'No valid action specified, just ignoring for now'
+ print('No valid action specified, just ignoring for now')
action = 'pass'
return action.lower()
@@ -386,7 +386,7 @@ def do_process(args):
if not args.actionid:
args.status = "Awaiting Review"
- print 'Processing all requests with status: %s' % args.status
+ print('Processing all requests with status: %s' % args.status)
ids = do_list(args)
else:
ids = args.actionid
@@ -395,18 +395,18 @@ def do_process(args):
LOG.info("action : {0}".format(actionid))
action = PKGDBCLIENT.handle_api_call('/admin/action/%s' % actionid)
- print _action2msg(action)
+ print(_action2msg(action))
if action['status'] != 'Awaiting Review':
- print 'Action #%s is not Awaiting Review - Current status: %s' % (
- action['id'], action['status'])
+ print('Action #%s is not Awaiting Review - Current status: %s' % (
+ action['id'], action['status']))
return
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']}
@@ -421,12 +421,12 @@ def do_process(args):
elif action['action'] == 'request.branch':
data = __handle_request_branch(actionid, action)
else:
- print 'Action %s not supported by pkgdb-cli' % action['action']
+ print('Action %s not supported by pkgdb-cli' % action['action'])
continue
for msg in data.get('messages', []):
- print msg
- print ''
+ print(msg)
+ print('')
def main():
@@ -437,7 +437,7 @@ def main():
try:
arg = parser.parse_args()
except argparse.ArgumentTypeError, err:
- print "\nError: {0}".format(err)
+ print("\nError: {0}".format(err))
return 2
logging.basicConfig()
@@ -478,30 +478,30 @@ def main():
try:
arg.func(arg)
except KeyboardInterrupt:
- print "\nInterrupted by user."
+ print("\nInterrupted by user.")
return_code = 1
except ServerError, err:
LOG.debug('ServerError')
- print '{0}'.format(err)
+ print('{0}'.format(err))
return_code = 3
except ActionError, err:
LOG.debug('ActionError')
- print '{0}'.format(err.message)
+ print('{0}'.format(err.message))
return_code = 7
except AppError, err:
LOG.debug('AppError')
- print '{0}: {1}'.format(err.name, err.message)
+ print('{0}: {1}'.format(err.name, err.message))
return_code = 4
except PkgDBException, err:
LOG.debug('PkgDBException')
- print '{0}'.format(err)
+ print('{0}'.format(err))
return_code = 8
except ValueError, err:
- print 'Error: {0}'.format(err)
- print 'Did you log in?'
+ print('Error: {0}'.format(err))
+ print('Did you log in?')
return_code = 6
except Exception, err:
- print 'Error: {0}'.format(err)
+ print('Error: {0}'.format(err))
logging.exception("Generic error catched:")
return_code = 5
diff --git a/pkgdb2client/cli.py b/pkgdb2client/cli.py
index 0366ad2..645cd8a 100644
--- a/pkgdb2client/cli.py
+++ b/pkgdb2client/cli.py
@@ -832,12 +832,12 @@ def do_koschei(args):
pkg = pkgdbclient.get_package(
args.package, branches='master', acls=False
)['packages'][0]['package']
- print "Current koschei monitoring status of {0} is: {1}".format(
- pkg['name'], pkg['koschei_monitor'])
+ print("Current koschei monitoring status of {0} is: {1}".format(
+ pkg['name'], pkg['koschei_monitor']))
else:
output = pkgdbclient.set_koschei_status(args.package, args.koschei)
- print output.get(
- 'messages', 'Invalid output returned, please contact an admin')
+ print(output.get(
+ 'messages', 'Invalid output returned, please contact an admin'))
def main():
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index 9efb214..d764771 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, 6 months
[packagedb-cli] (18 commits) ...Merge pull request #64 from fedora-infra/avoid_none
by Pierre-YvesChibon
Summary of changes:
2afc7e6... Call the print function instead of the print statement to b
bc4075b... Adjust catching the exception to be both py2 and 3 compatib
4a3929e... Merge pull request #54 from fedora-infra/more_py3
a4ec118... Fix pep8 compliance
990bb26... Merge pull request #59 from tyll/pep8
15097d0... Show successful tests
dd52230... Merge pull request #55 from tyll/show_tests
e2fd959... Encode the summary retrieved to UTF-8
9d229c6... Some more encoding to UTF-8 in case we go through with it
9c670f6... Encode all the fields, this way we'll be sure to have consi
82d3734... Handle the situation where the description or the upstream
aaa3075... Merge pull request #61 from fedora-infra/fix_encoding
3d1dcac... Check if the person approving the review is the same as the
a1b6eda... Check if the person who approved the review is the assignee
9fb5bde... Check the component and product of the review request
3012f56... Merge pull request #63 from fedora-infra/better_checks
c66ded0... Make sure we never return None when we expect a dictionary
405c7fc... Merge pull request #64 from fedora-infra/avoid_none
8 years, 6 months