ralph commented on the pull-request: `Add a script that will get the packages that have
all the specified branches but are retired` that you are following:
``
It might also be nice to print a warning to `stderr` if there are no retired packages
found, like this:
diff --git a/scripts/pdc/get-retired-packages.py
b/scripts/pdc/get-retired-packages.py
index 0d160a9..05f702c 100644
--- a/scripts/pdc/get-retired-packages.py
+++ b/scripts/pdc/get-retired-packages.py
@@ -1,12 +1,16 @@
""" get-retired-packages.py - Gets all the packages that have the
specified
branches marked as inactive in PDC
"""
+from __future__ import print_function
+
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
+
import multiprocessing.pool
import argparse
+import sys
from math import ceil
from functools import partial
import requests
@@ -28,13 +32,13 @@ def get_component_branch_page(branch_name, page, page_size=100):
rv = requests.get(pdc_api_query_url, timeout=30)
except (requests.ConnectionError, requests.ConnectTimeout):
print('The connection to PDC failed')
- exit(1)
+ sys.exit(1)
try:
return rv.json()
except ValueError:
print('The data returned from PDC was not JSON')
- exit(1)
+ sys.exit(1)
def get_pkgs_from_page(branch_name, page):
@@ -61,7 +65,10 @@ def get_pkg_branch_status(branch_name):
pkg_sets = pool.map(partial_get_pkgs_from_page, range(1, num_pages + 1))
pool.close()
# Return a set of all the packages from the pages queried
- return set.union(*pkg_sets)
+ if pkg_sets:
+ return set.union(*pkg_sets)
+ else:
+ return set()
if __name__ == '__main__':
@@ -72,5 +79,9 @@ if __name__ == '__main__':
# Return only the packages that have all the specified branches and are
# retired
- for pkg in sorted(list(set.intersection(*pkg_sets))):
- print(pkg)
+ pkgs = list(set.intersection(*pkg_sets))
+ if pkgs:
+ for pkg in sorted(pkgs):
+ print(pkg)
+ else:
+ print("No retired packages on %r" % args.branches,
file=sys.stderr)
``
To reply, visit the link below or just reply to this email
https://pagure.io/releng/pull-request/6844