How to use the patchman.util.update_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
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
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
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
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
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
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)