Пример #1
0
def share(*argv):
    usage = """
    Install privately-stored images into the global images repo
    Destination name is derived from the radical provided at save-time
      i.e. trailing part after saving__<date>__

    With the -a option, it is possible to make the new image
    **also** visible under that alias name.

    If your account is enabled in /etc/sudoers.d/rhubarbe-share,
    the command will actually perform the mv operation
    Requires to be run through 'sudo rhubarbe-share'
    """
    parser = ArgumentParser(usage=usage,
                            formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument("-a",
                        "--alias-name",
                        dest='alias',
                        action='store',
                        default=None,
                        help="also create a symlink of that name")
    # default=None so that imagesrepo.share can compute a default
    parser.add_argument("-n",
                        "--dry-run",
                        default=None,
                        action='store_true',
                        help="Only show what would be done "
                        "(default unless running under sudo")
    parser.add_argument("-f",
                        "--force",
                        default=False,
                        action='store_true',
                        help="Will move files even if destination exists")
    parser.add_argument("-c",
                        "--clean",
                        default=False,
                        action='store_true',
                        help="""Will remove other matches than the one that
                        gets promoted. In other words, useful when one name
                        has several matches and only the last one is desired.
                        Typically after a successful rsave""")
    parser.add_argument("image", type=str)
    args = parser.parse_args(argv)

    imagesrepo = ImagesRepo()
    return imagesrepo.share(args.image, args.alias, args.dry_run, args.force,
                            args.clean)
Пример #2
0
def share(*argv):
    usage = """
    Install privately-stored images into the global images repo
    Destination name is derived from the radical provided at save-time
      i.e. trailing part after saving__<date>__
    When only one image is provided it is possible to specify
      another destination name with -o

    If your account is enabled in /etc/sudoers.d/rhubarbe-share,
    the command will actually perform the mv operation
    Requires to be run through 'sudo rhubarbe-share'
    """
    the_config = Config()

    parser = ArgumentParser(usage=usage)
    parser.add_argument("-a", "--alias-name", dest='alias',
                        action='store', default=None,
                        help="create a symlink of that name "
                        "(ignored with more than one image)")
    # default=None so that imagesrepo.share can compute a default
    parser.add_argument("-n", "--dry-run",
                        default=None, action='store_true',
                        help="Only show what would be done "
                        "(default unless running under sudo")
    parser.add_argument("-f", "--force",
                        default=False, action='store_true',
                        help="Will move files even if destination exists")
    parser.add_argument("-c", "--clean",
                        default=False, action='store_true',
                        help="""Will remove other matches than the one that
                        gets promoted. In other words, useful when one name
                        has several matches and only the last one is desired.
                        Typically after a successful (re)save""")
    parser.add_argument("images", nargs="+", type=str)
    args = parser.parse_args(argv)

    the_imagesrepo = ImagesRepo()
    return the_imagesrepo.share(args.images, args.alias,
                                args.dry_run, args.force, args.clean)