def main(): cnf = Config() Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), ('c', "component", "Ls::Options::Component", "HasArg"), ('f', "format", "Ls::Options::Format", "HasArg"), ('g', "greaterorequal", "Ls::Options::GreaterOrEqual"), ('G', "greaterthan", "Ls::Options::GreaterThan"), ('r', "regex", "Ls::Options::Regex"), ('s', "suite", "Ls::Options::Suite", "HasArg"), ('S', "source-and-binary", "Ls::Options::Source-And-Binary"), ('h', "help", "Ls::Options::Help")] for i in ["architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help"]: key = "Ls::Options::%s" % i if key not in cnf: cnf[key] = "" packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Ls::Options") if Options["Help"]: usage() if not packages: utils.fubar("need at least one package name as an argument.") # Handle buildd maintenance helper options if Options["GreaterOrEqual"] or Options["GreaterThan"]: if Options["GreaterOrEqual"] and Options["GreaterThan"]: utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") if not Options["Suite"]: Options["Suite"] = "unstable" kwargs = dict() if Options["Regex"]: kwargs['regex'] = True if Options["Source-And-Binary"]: kwargs['source_and_binary'] = True if Options["Suite"]: kwargs['suites'] = utils.split_args(Options['Suite']) if Options["Architecture"]: kwargs['architectures'] = utils.split_args(Options['Architecture']) if Options['BinaryType']: kwargs['binary_types'] = utils.split_args(Options['BinaryType']) if Options['Component']: kwargs['components'] = utils.split_args(Options['Component']) if Options['Format']: kwargs['format'] = Options['Format'] if Options['GreaterOrEqual']: kwargs['highest'] = '>=' elif Options['GreaterThan']: kwargs['highest'] = '>>' for line in list_packages(packages, **kwargs): print(line)
def madison(): """ Display information about B{package(s)}. @since: December 2014 @keyword package: Space separated list of packages. @keyword a: only show info for specified architectures. @keyword b: only show info for a binary type. I{deb/udeb/dsc} @keyword c: only show info for specified component(s). I{main/contrib/non-free} @keyword s: only show info for this suite. @keyword S: show info for the binary children of source pkgs. I{true/false} @keyword f: output json format. I{json} @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites. @rtype: text/plain or application/json @return: Text or Json format of the data """ r = bottle.request packages = r.query.get('package', '').split() kwargs = dict() architectures = r.query.get('a', None) if architectures is not None: kwargs['architectures'] = architectures.split(",") binary_type = r.query.get('b', None) if binary_type is not None: kwargs['binary_types'] = [binary_type] component = r.query.get('c', None) if component is not None: kwargs['components'] = component.split(",") suite = r.query.get('s', None) if suite is not None: kwargs['suites'] = suite.split(",") if 'S' in r.query: kwargs['source_and_binary'] = True #if 'r' in r.query: # kwargs['regex'] = True format = r.query.get('f', None) if format is not None: kwargs['format'] = 'python' result = list_packages(packages, **kwargs) if format is None: bottle.response.content_type = 'text/plain; charset=UTF-8' for row in result: yield row yield "\n" else: bottle.response.content_type = 'application/json; charset=UTF-8' yield json.dumps(list(result))
def main (): cnf = Config() Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), ('c', "component", "Ls::Options::Component", "HasArg"), ('f', "format", "Ls::Options::Format", "HasArg"), ('g', "greaterorequal", "Ls::Options::GreaterOrEqual"), ('G', "greaterthan", "Ls::Options::GreaterThan"), ('r', "regex", "Ls::Options::Regex"), ('s', "suite", "Ls::Options::Suite", "HasArg"), ('S', "source-and-binary", "Ls::Options::Source-And-Binary"), ('h', "help", "Ls::Options::Help")] for i in [ "architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help" ]: if not cnf.has_key("Ls::Options::%s" % (i)): cnf["Ls::Options::%s" % (i)] = "" packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Ls::Options") if Options["Help"]: usage() if not packages: utils.fubar("need at least one package name as an argument.") # If cron.daily is running; warn the user that our output might seem strange if os.path.exists(os.path.join(cnf["Dir::Lock"], "daily.lock")): utils.warn("Archive maintenance is in progress; database inconsistencies are possible.") # Handle buildd maintenance helper options if Options["GreaterOrEqual"] or Options["GreaterThan"]: if Options["GreaterOrEqual"] and Options["GreaterThan"]: utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") if not Options["Suite"]: Options["Suite"] = "unstable" kwargs = dict() if Options["Regex"]: kwargs['regex'] = True if Options["Source-And-Binary"]: kwargs['source_and_binary'] = True if Options["Suite"]: kwargs['suites'] = utils.split_args(Options['Suite']) if Options["Architecture"]: kwargs['architectures'] = utils.split_args(Options['Architecture']) if Options['BinaryType']: kwargs['binary_types'] = utils.split_args(Options['BinaryType']) if Options['Component']: kwargs['components'] = utils.split_args(Options['Component']) if Options['Format']: kwargs['format'] = Options['Format'] if Options['GreaterOrEqual']: kwargs['highest'] = '>=' elif Options['GreaterThan']: kwargs['highest'] = '>>' for line in list_packages(packages, **kwargs): print(line)
def main (): cnf = Config() Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), ('c', "component", "Ls::Options::Component", "HasArg"), ('f', "format", "Ls::Options::Format", "HasArg"), ('g', "greaterorequal", "Ls::Options::GreaterOrEqual"), ('G', "greaterthan", "Ls::Options::GreaterThan"), ('r', "regex", "Ls::Options::Regex"), ('s', "suite", "Ls::Options::Suite", "HasArg"), ('S', "source-and-binary", "Ls::Options::Source-And-Binary"), ('h', "help", "Ls::Options::Help")] for i in [ "architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help" ]: if not cnf.has_key("Ls::Options::%s" % (i)): cnf["Ls::Options::%s" % (i)] = "" packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Ls::Options") if Options["Help"]: usage() if not packages: utils.fubar("need at least one package name as an argument.") # If cron.daily is running; warn the user that our output might seem strange if os.path.exists(os.path.join(cnf["Dir::Lock"], "daily.lock")): utils.warn("Archive maintenance is in progress; database inconsistencies are possible.") # Handle buildd maintenance helper options if Options["GreaterOrEqual"] or Options["GreaterThan"]: if Options["GreaterOrEqual"] and Options["GreaterThan"]: utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") if not Options["Suite"]: Options["Suite"] = "unstable" kwargs = dict() if Options["Regex"]: kwargs['regex'] = True if Options["Source-And-Binary"]: kwargs['source_and_binary'] = True if Options["Suite"]: kwargs['suites'] = utils.split_args(Options['Suite']) if Options["Architecture"]: kwargs['architectures'] = utils.split_args(Options['Architecture']) if Options['BinaryType']: kwargs['binary_types'] = utils.split_args(Options['BinaryType']) if Options['Component']: kwargs['components'] = utils.split_args(Options['Component']) if Options['Format']: kwargs['format'] = Options['Format'] if Options['GreaterOrEqual']: kwargs['highest'] = '>=' elif Options['GreaterThan']: kwargs['highest'] = '>>' for line in list_packages(packages, **kwargs): print line
def main(): cnf = Config() Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), ('c', "component", "Ls::Options::Component", "HasArg"), ('f', "format", "Ls::Options::Format", "HasArg"), ('g', "greaterorequal", "Ls::Options::GreaterOrEqual"), ('G', "greaterthan", "Ls::Options::GreaterThan"), ('r', "regex", "Ls::Options::Regex"), ('s', "suite", "Ls::Options::Suite", "HasArg"), ('S', "source-and-binary", "Ls::Options::Source-And-Binary"), ('h', "help", "Ls::Options::Help")] for i in [ "architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help" ]: key = "Ls::Options::%s" % i if key not in cnf: cnf[key] = "" packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Ls::Options") if Options["Help"]: usage() if not packages: utils.fubar("need at least one package name as an argument.") # Handle buildd maintenance helper options if Options["GreaterOrEqual"] or Options["GreaterThan"]: if Options["GreaterOrEqual"] and Options["GreaterThan"]: utils.fubar( "-g/--greaterorequal and -G/--greaterthan are mutually exclusive." ) if not Options["Suite"]: Options["Suite"] = "unstable" kwargs = dict() if Options["Regex"]: kwargs['regex'] = True if Options["Source-And-Binary"]: kwargs['source_and_binary'] = True if Options["Suite"]: kwargs['suites'] = utils.split_args(Options['Suite']) if Options["Architecture"]: kwargs['architectures'] = utils.split_args(Options['Architecture']) if Options['BinaryType']: kwargs['binary_types'] = utils.split_args(Options['BinaryType']) if Options['Component']: kwargs['components'] = utils.split_args(Options['Component']) if Options['Format']: kwargs['format'] = Options['Format'] if Options['GreaterOrEqual']: kwargs['highest'] = '>=' elif Options['GreaterThan']: kwargs['highest'] = '>>' for line in list_packages(packages, **kwargs): print(line)