How to use the patchman.reports.models.Report.objects.filter 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
""" Delete old reports for all hosts, specify host for a single host.
        Reports with non existent hosts are only removed when no host is
        specified.
    """

    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
The --force option forces even processed reports to be reprocessed
        No reports are skipped in case some reports contain repo information
        and others only contain package information.
    """

    reports = []
    if host:
        try:
            reports = Report.objects.filter(
                processed=force, host=host).order_by('created')
            message = 'Processing reports for host {0!s}'.format(host)
        except:
            message = 'No reports exist for host {0!s}'.format(host)
    else:
        message = 'Processing reports for all hosts'
        reports = Report.objects.filter(processed=force).order_by('created')

    if verbose:
        print message

    for report in reports:
        report.process(False)
github furlongm / patchman / sbin / patchman.py View on Github external
def process_reports(host=None, force=False):
    """ Process all pending reports, specify host to process only a single host
        The --force option forces even processed reports to be reprocessed
        No reports are skipped in case some reports contain repo information
        and others only contain package information.
    """

    reports = []
    if host:
        try:
            reports = Report.objects.filter(
                processed=force, host=host).order_by('created')
            message = 'Processing reports for host {0!s}'.format(host)
        except:
            message = 'No reports exist for host {0!s}'.format(host)
    else:
        message = 'Processing reports for all hosts'
        reports = Report.objects.filter(processed=force).order_by('created')

    if verbose:
        print message

    for report in reports:
        report.process(False)