Exemplo n.º 1
0
def main():
    parser = create_parser(
        description="Export products from a muninn archive.", parallel=True)
    parser.add_argument(
        "-d",
        "--directory",
        type=directory,
        help="directory in which retrieved products will be"
        " stored; by default, retrieved products will be stored in the current working directory"
    )
    parser.add_argument(
        "-f",
        "--format",
        type=export_format,
        help="format in which to export the products; if left"
        " unspecified, the default export format for the product type will be used"
    )
    parser.add_argument("-l",
                        "--list-formats",
                        action="store_true",
                        help="list alternative (non-default) export"
                        " formats supported by the archive and exit")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument(
        "expression",
        metavar="EXPRESSION",
        help="expression used to search for products to export")
    return parse_args_and_run(parser, export)
Exemplo n.º 2
0
def main():
    parser = create_parser(description="Attach product to existing metadata entry in a muninn archive.", parallel=True)
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-s", "--path-is-stem", action="store_true", help="each product path is interpreted as a "
                       "stem; any file or directory of which the name starts with this stem is considered to be part "
                       "of the product")
    group.add_argument("-d", "--path-is-enclosing-directory", action="store_true", help="each product path is "
                       "interpreted as an enclosing directory; the actual product consists of any file or directory "
                       "found inside this enclosing directory; the enclosing directory itself is not considered part "
                       "of the product")
    parser.add_argument("-e", "--exclude", metavar="PATTERN", action="append", help="exclude any files or "
                        "directories whose basename matches PATTERN; *, ?, and [] can be used as wildcards; to match "
                        "a wildcard character literally, include it within brackets, e.g. [?] to match the character ? "
                        "literally")
    parser.add_argument("-t", "--product-type", help="force the product type of products to attach")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-l", "--link", action="store_true", help="attach symbolic links to each product")
    group.add_argument("-k", "--keep", action="store_true", help="attach product, using the current product path if it "
                                                                 "is in the muninn path, otherwise throws an error")
    parser.add_argument("-f", "--force", action="store_true", help="skip matching size check before attaching products")
    parser.add_argument("--verify-hash", action="store_true",
                        help="verify the hash of the product after it has been put in the archive")
    parser.add_argument("--verify-hash-before", action="store_true",
                        help="verify the hash of the product before it is put in the archive")
    parser.add_argument("archive", metavar="ARCHIVE", help="identifier of the archive to use")
    parser.add_argument("path", metavar="PATH", nargs="+", action=CheckProductListAction,
                        help="products to attach, or \"-\" to read the list of products from standard input")
    return parse_args_and_run(parser, attach)
Exemplo n.º 3
0
def main():
    parser = create_parser(description="Pull remote files into the archive.", parallel=True)
    parser.add_argument("--verify-hash", action="store_true",
                        help="verify the hash of the product after it has been put in the archive")
    parser.add_argument("--verify-hash-download", action="store_true",
                        help="verify the hash of the pulled product before it has been put in the archive")
    parser.add_argument("archive", metavar="ARCHIVE", help="identifier of the archive to use")
    parser.add_argument("expression", metavar="EXPRESSION", help="expression to filter products to pull")
    return parse_args_and_run(parser, pull)
Exemplo n.º 4
0
def main():
    parser = create_parser(
        description="List tags of products contained in a muninn archive")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument(
        "expression",
        metavar="EXPRESSION",
        help="expression used to search for products to list tags of")
    return parse_args_and_run(parser, list_tags)
Exemplo n.º 5
0
def main():
    parser = create_parser(
        description=
        "Set one or more tags on products contained in a muninn archive",
        parallel=True)
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument("expression",
                        metavar="EXPRESSION",
                        help="expression used to search for products to tag")
    parser.add_argument("tag", metavar="TAG", nargs="+", help="tags to set")
    return parse_args_and_run(parser, tag)
Exemplo n.º 6
0
def main():
    parser = create_parser(description="Muninn product hashing utilities")
    sub_parsers = parser.add_subparsers(dest='command',
                                        help='sub-command help')
    sub_parsers.required = True

    # calc
    calc = sub_parsers.add_parser('calc',
                                  help='calculate hash for local products')
    calc.add_argument(
        "path",
        metavar="PATH",
        nargs="+",
        action=CheckProductListAction,
        help=
        "list of paths, or \"-\" to read the list of paths from standard input"
    )
    calc.add_argument("--hash-type",
                      default='sha1',
                      help="hash algorithm to use (default sha1)")
    calc.add_argument(
        "-s",
        "--path-is-stem",
        action="store_true",
        help="each product path is interpreted as a "
        "stem; any file or directory of which the name starts with this stem is considered to be part "
        "of the product")

    # verify
    verify = sub_parsers.add_parser('verify',
                                    help='verify hash for given products')
    verify.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    verify.add_argument("expression",
                        metavar="EXPRESSION",
                        default="",
                        help="expression to select products")
    verify.add_argument("--parallel",
                        action="store_true",
                        help="use multi-processing to perform operation")
    verify.add_argument(
        "--processes",
        type=int,
        help="use a specific amount of processes for --parallel")

    return parse_args_and_run(parser, command)
Exemplo n.º 7
0
def main():
    parser = create_parser(
        description="Remove a muninn archive and its contents")
    parser.add_argument(
        "-c",
        "--catalogue-only",
        action="store_true",
        help="only remove the catalogue database, "
        "without touching (or removing anything from) the archive root path on disk"
    )
    parser.add_argument("-y",
                        "--yes",
                        action="store_true",
                        help="assume yes and do not prompt for confirmation")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    return parse_args_and_run(parser, destroy)
Exemplo n.º 8
0
def main():
    parser = create_parser(
        description=
        "Remove one or more tags from products contained in a muninn archive",
        parallel=True)
    parser.add_argument(
        "-a",
        "--all",
        action="store_true",
        help="ignore tags supplied on the command line; instead remove all tags"
    )
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument("expression",
                        metavar="EXPRESSION",
                        help="expression used to search for products to untag")
    parser.add_argument("tag", metavar="TAG", nargs="*", help="tags to remove")
    return parse_args_and_run(parser, untag)
Exemplo n.º 9
0
def main():
    parser = create_parser(
        description="Strip products contained in a muninn archive (i.e. remove "
        "products from disk, but don't remove the corresponding entries from the product "
        "catalogue)",
        parallel=True)
    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        help="also strip partially ingested products; note"
        " that this can cause product files to be removed while in the process of being ingested"
    )
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument(
        "expression",
        metavar="EXPRESSION",
        help="expression used to search for products to remove")
    return parse_args_and_run(parser, strip)
Exemplo n.º 10
0
def main():
    parser = create_parser(description="Search a muninn archive for products.")
    parser.add_argument("-f", "--output-format", choices=SUPPORTED_FORMATS, default=default_format,
                        help="output format")
    parser.add_argument("-l", "--limit", type=int, help="limit the maximum number of products")
    parser.add_argument("-o", "--order-by", action="append", type=order_by_list, default=[], help="white space "
                        "separated list of sort order specifiers; a \"+\" prefix denotes ascending order; no prefix "
                        "denotes descending order")
    parser.add_argument("-p", "--property", action="append", type=property_list, dest="properties",
                        help="white space separated list of properties to output; use `<namespace>.*` to include all "
                        "properties of a namespace, e.g. core.*; use `*` to include all namespaces")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-c", "--count", action="store_true", help="suppress normal output; instead print the "
                       "number of products matching the search expression")
    group.add_argument("-u", "--uuid", action="store_true", help="suppress normal output; instead print the uuid "
                       "of each product found")
    group.add_argument("--paths", action="store_true", help="suppress normal output; instead print the physical "
                       "path of each product found")
    parser.add_argument("archive", metavar="ARCHIVE", help="identifier of the archive to use")
    parser.add_argument("expression", metavar="EXPRESSION", help="expression used to search for products")

    return parse_args_and_run(parser, run)
Exemplo n.º 11
0
def main():
    parser = create_parser(
        description="Retrieve products from a muninn archive.", parallel=True)
    parser.add_argument(
        "-d",
        "--directory",
        type=directory,
        help="directory in which retrieved products will be"
        " stored; by default, retrieved products will be stored in the current working directory"
    )
    parser.add_argument("-l",
                        "--link",
                        action="store_true",
                        help="retrieve using symbolic links instead of copy")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument(
        "expression",
        metavar="EXPRESSION",
        help="expression used to search for products to retrieve")
    return parse_args_and_run(parser, retrieve)
Exemplo n.º 12
0
def main():
    parser = create_parser(
        description="Remove products from a muninn archive.", parallel=True)
    parser.add_argument("-c",
                        "--catalogue-only",
                        action="store_true",
                        help="remove the entry from the catalogue "
                        "without removing any product from the storage")
    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        help="also remove partially ingested products; note "
        "that this can cause products to be removed while in the process of being ingested"
    )
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument(
        "expression",
        metavar="EXPRESSION",
        help="expression used to search for products to remove")
    return parse_args_and_run(parser, remove)
Exemplo n.º 13
0
def main():
    parser = create_parser(
        description="Prepare a muninn archive for first use.")
    parser.add_argument(
        "-c",
        "--catalogue-only",
        action="store_true",
        help="only prepare the catalogue database, "
        "without creating (or removing anything from) the archive storage")
    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        help=
        "force preparation of an existing archive, completely removing all content"
    )
    parser.add_argument("--dry-run",
                        action="store_true",
                        help="dump the SQL statements without executing them")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    return parse_args_and_run(parser, prepare)
Exemplo n.º 14
0
def main():
    parser = create_parser(
        description="Summary of the products matching the search expression.",
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-f",
        "--output-format",
        choices=OUTPUT_FORMATS,
        default=DEFAULT_FORMAT,
        metavar="FORMAT",
        help="output format; choices (depending on installation of "
        "python-tabulate): {%(choices)s}; default: %(default)s")
    parser.add_argument(
        "-o",
        "--order-by",
        action="append",
        dest="order_by",
        help="white space "
        "separated list of sort order specifiers; a \"+\" prefix denotes ascending order; no prefix "
        "denotes descending order")
    parser.add_argument(
        "-g",
        "--group-by",
        action="append",
        dest="group_by",
        help=
        "list of property names whose values are used for grouping the aggregation results; "
        "there will be a separate result row for each combination of group_by property values; "
        "properties need to be of type long, integer, boolean, text or timestamp; "
        "timestamps require a binning subscript which can be 'year', 'month', 'yearmonth', 'day', "
        "'date', 'hour', 'minute', 'second' or 'time' (e.g. `validity_start.yearmonth`)"
    )
    parser.add_argument(
        "-t",
        "--group-by-tag",
        action="store_true",
        help="group result by tag value; "
        "note that products will be counted multiple times if they have multiple tags"
    )
    parser.add_argument(
        "-s",
        "--stats",
        action="append",
        dest="stats",
        help="list of property aggregates defined as "
        "`<property_name>.<reduce_fn>`; "
        "properties need to be of type long, integer, real, text or timestamp; "
        "the reduce function can be 'min', 'max', 'sum', or 'avg'; "
        "'sum' and 'avg' are not possible for text and timestamp properties; "
        "a special property 'validity_duration' (defined as validity_stop - validity_start) can also "
        "be used; default stats: %r" % ' '.join(DEFAULT_STATS))
    parser.add_argument("--stats-filter",
                        metavar='EXPRESSION',
                        help="expression used to filter on aggregates")
    parser.add_argument("-H",
                        "--human-readable",
                        action="store_true",
                        help="output human readable core.size")
    parser.add_argument("archive",
                        metavar="ARCHIVE",
                        help="identifier of the archive to use")
    parser.add_argument("expression",
                        metavar="EXPRESSION",
                        nargs='?',
                        help="expression used to search for products")

    return parse_args_and_run(parser, run)