Esempio n. 1
0
def builds_rm_old_cmd(args):
    current = get_all_current()
    all_releases = get_releases()
    max_build = max(x.version for x in all_releases)
    for release in get_releases():
        if release.key in current:
            print("Skipping {} as it is a current version".format(release))
        else:
            age = max_build - release.version
            if age > args['age']:
                if args['dry_run']:
                    print("Would remove build {}".format(release))
                else:
                    print("Removing build {}".format(release))
                    remove_release(release)
            else:
                print("Keeping build {}".format(release))
Esempio n. 2
0
def builds_rm_old(dry_run: bool, max_age: int):
    """Remove all but the last MAX_AGE builds."""
    current = get_all_current()
    max_builds: Dict[str, int] = defaultdict(int)
    for release in get_releases():
        max_builds[release.version.source] = max(
            release.version.number, max_builds[release.version.source])
    for release in get_releases():
        if release.key in current:
            print("Skipping {} as it is a current version".format(release))
        else:
            age = max_builds[release.version.source] - release.version.number
            if age > max_age:
                if dry_run:
                    print("Would remove build {}".format(release))
                else:
                    print("Removing build {}".format(release))
                    remove_release(release)
            else:
                print("Keeping build {}".format(release))
Esempio n. 3
0
File: ce.py Progetto: iCodeIN/infra
def builds_rm_old_cmd(args):
    current = get_all_current()
    max_builds = {}
    for release in get_releases():
        if release.version not in max_builds:
            max_builds[release.version.source] = release.version
        else:
            max_builds[release.version.source] = max(
                release.version, max_builds[release.version.source])
    for release in get_releases():
        if release.key in current:
            print("Skipping {} as it is a current version".format(release))
        else:
            age = max_builds[
                release.version.source].number - release.version.number
            if age > args['age']:
                if args['dry_run']:
                    print("Would remove build {}".format(release))
                else:
                    print("Removing build {}".format(release))
                    remove_release(release)
            else:
                print("Keeping build {}".format(release))