How to use the patchman.util.create_pbar function in patchman

To help you get started, we’ve selected a few patchman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github furlongm / patchman / sbin / patchman.py View on Github external
def clean_package_names():
    """ Removes package names that are no longer in use
    """

    names = PackageName.objects.filter(package__isnull=True)
    nlen = names.count()

    if nlen == 0:
        if verbose:
            print 'No orphaned package names found.'
    else:
        create_pbar('Removing {0!s} unused package names:'.format(nlen), nlen)
        for i, packagename in enumerate(names):
            packagename.delete()
            update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
tagged_items = list(TaggedItem.objects.all())
    to_delete = []

    for t in tagged_items:
        hostid = t.object_id
        try:
            # tags are only used for hosts for now
            Host.objects.get(pk=hostid)
        except ObjectDoesNotExist:
            to_delete.append(t)

    tlen = len(to_delete)

    if tlen != 0:
        create_pbar('Removing {0!s} unused tagged items'.format(tlen), tlen)
        for i, t in enumerate(to_delete):
            t.delete()
            update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
hosts = get_hosts(s_host, 'Cleaning reports')
    timestamp = date.today()

    for host in hosts:
        if verbose:
            print host
        host.clean_reports(timestamp)

    if s_host is None:

        reports = Report.objects.filter(accessed__lt=timestamp)
        rlen = reports.count()

        if rlen != 0:
            create_pbar('Removing {0!s} extraneous reports:'.format(rlen), rlen)
            for i, report in enumerate(reports):
                report.delete()
                update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
def clean_repos():
    """ Removes repositories that contain no mirrors
    """

    repos = Repository.objects.filter(mirror__isnull=True)
    rlen = repos.count()

    if rlen == 0:
        if verbose:
            print 'No repositories with zero mirrors found.'
    else:
        create_pbar('Removing {0!s} empty repos:'.format(rlen), rlen)
        for i, repo in enumerate(repos):
            repo.delete()
            update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
def clean_packages():
    """ Removes packages that are no longer in use
    """

    packages = Package.objects.filter(mirror__isnull=True, host__isnull=True)
    plen = packages.count()
    if plen == 0:
        if verbose:
            print 'No orphaned packages found.'
    else:
        create_pbar('Removing {0!s} orphaned packages:'.format(plen), plen)
        for i, o in enumerate(packages):
            p = Package.objects.get(name=o.name,
                                    epoch=o.epoch,
                                    version=o.version,
                                    release=o.release,
                                    arch=o.arch,
                                    packagetype=o.packagetype)
            p.delete()
            update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
else:
        create_pbar('Removing {0!s} orphaned p arches:'.format(plen), plen)
        for i, p in enumerate(parches):
            a = PackageArchitecture.objects.get(name=p.name)
            a.delete()
            update_pbar(i + 1)

    marches = MachineArchitecture.objects.filter(host__isnull=True,
                                                 repository__isnull=True)
    mlen = marches.count()

    if mlen == 0:
        if verbose:
            print 'No orphaned machine architectures found.'
    else:
        create_pbar('Removing {0!s} orphaned m arches:'.format(mlen), mlen)
        for i, m in enumerate(marches):
            a = MachineArchitecture.objects.get(name=m.name)
            a.delete()
            update_pbar(i + 1)
github furlongm / patchman / sbin / patchman.py View on Github external
def clean_arches():
    """ Removes architectures that are no longer in use
    """

    parches = PackageArchitecture.objects.filter(package__isnull=True)
    plen = parches.count()

    if plen == 0:
        if verbose:
            print 'No orphaned package architectures found.'
    else:
        create_pbar('Removing {0!s} orphaned p arches:'.format(plen), plen)
        for i, p in enumerate(parches):
            a = PackageArchitecture.objects.get(name=p.name)
            a.delete()
            update_pbar(i + 1)

    marches = MachineArchitecture.objects.filter(host__isnull=True,
                                                 repository__isnull=True)
    mlen = marches.count()

    if mlen == 0:
        if verbose:
            print 'No orphaned machine architectures found.'
    else:
        create_pbar('Removing {0!s} orphaned m arches:'.format(mlen), mlen)
        for i, m in enumerate(marches):
            a = MachineArchitecture.objects.get(name=m.name)