def api_critpath(): '''Return the list of package marked as critpath for all active release of fedora. :kwarg out_format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} active_collections = pkgdblib.search_collection( SESSION, '*', status='Under Development') active_collections.extend( pkgdblib.search_collection(SESSION, '*', status='Active')) for collection in active_collections: if collection.name != 'Fedora': continue pkgs = pkgdblib.get_critpath_packages( SESSION, branch=collection.branchname) if not pkgs: continue output[collection.branchname] = [pkg.package.name for pkg in pkgs] if out_format == 'json': output = {"pkgs": output} return flask.jsonify(output) else: output_str = "" keys = output.keys() keys.reverse() for key in keys: output_str += "== %s ==\n" % key for pkg in output[key]: output_str += "* %s\n" % pkg return flask.Response( output_str, content_type="text/plain;charset=UTF-8" )
def api_critpath(): '''Return the list of package marked as critpath for all active release of fedora. :kwarg out_format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} active_collections = pkgdblib.search_collection(SESSION, '*', status='Under Development') active_collections.extend( pkgdblib.search_collection(SESSION, '*', status='Active')) for collection in active_collections: if collection.name != 'Fedora': continue pkgs = pkgdblib.get_critpath_packages(SESSION, branch=collection.branchname) if not pkgs: continue output[collection.branchname] = [pkg.package.name for pkg in pkgs] if out_format == 'json': output = {"pkgs": output} return flask.jsonify(output) else: output_str = "" keys = output.keys() keys.reverse() for key in keys: output_str += "== %s ==\n" % key for pkg in output[key]: output_str += "* %s\n" % pkg return flask.Response(output_str, content_type="text/plain;charset=UTF-8")
def api_critpath(): ''' Critical path packages ---------------------- Return the list of package marked as critpath for some or all active releases of fedora. :: /api/critpath :kwarg branches: Return the list of packages marked as critpath in the specified branch(es). :kwarg format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') branches = flask.request.args.getlist('branches') if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} if not branches: active_collections = pkgdblib.search_collection( SESSION, '*', status='Under Development') active_collections.extend( pkgdblib.search_collection(SESSION, '*', status='Active')) else: active_collections = [] for branch in branches: active_collections.extend( pkgdblib.search_collection(SESSION, branch) ) for collection in active_collections: if collection.name != 'Fedora': continue pkgs = pkgdblib.get_critpath_packages( SESSION, branch=collection.branchname) if not pkgs: continue output[collection.branchname] = [pkg.package.name for pkg in pkgs] if out_format == 'json': output = {"pkgs": output} return flask.jsonify(output) else: output_str = [] keys = output.keys() keys.reverse() for key in keys: output_str.append("== %s ==\n" % key) for pkg in output[key]: output_str.append("* %s\n" % pkg) return flask.Response( ''.join(output_str), content_type="text/plain;charset=UTF-8" )
def api_critpath(): ''' Critical path packages ---------------------- Return the list of package marked as critpath for some or all active releases of fedora. :: /api/critpath :kwarg branches: Return the list of packages marked as critpath in the specified branch(es). :kwarg format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') branches = flask.request.args.getlist('branches') if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} if not branches: active_collections = pkgdblib.search_collection( SESSION, '*', status='Under Development') active_collections.extend( pkgdblib.search_collection(SESSION, '*', status='Active')) else: active_collections = [] for branch in branches: active_collections.extend( pkgdblib.search_collection(SESSION, branch)) for collection in active_collections: if collection.name != 'Fedora': continue pkgs = pkgdblib.get_critpath_packages(SESSION, branch=collection.branchname) if not pkgs: continue output[collection.branchname] = [pkg.package.name for pkg in pkgs] if out_format == 'json': output = {"pkgs": output} return flask.jsonify(output) else: output_str = [] keys = output.keys() keys.reverse() for key in keys: output_str.append("== %s ==\n" % key) for pkg in output[key]: output_str.append("* %s\n" % pkg) return flask.Response(''.join(output_str), content_type="text/plain;charset=UTF-8")