How to use the patchman.signals.info_message 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 / reports / models.py View on Github external
with transaction.atomic():
                process_repos(report=self, host=host)
            with transaction.atomic():
                process_packages(report=self, host=host)
            with transaction.atomic():
                process_updates(report=self, host=host)

            self.processed = True
            with transaction.atomic():
                self.save()

            if find_updates:
                if verbose:
                    text = 'Finding updates for report '
                    text += '{0!s} - {1!s}'.format(self.id, self.host)
                    info_message.send(sender=None, text=text)
                host.find_updates()
        else:
            if self.processed:
                text = 'Report {0!s} '.format(self.id)
                text += 'has already been processed'
                info_message.send(sender=None, text=text)
            else:
                text = 'Error: OS, kernel or arch not sent '
                text += 'with report {0!s}'.format(self.id)
                error_message.send(sender=None, text=text)
github furlongm / patchman / repos / utils.py View on Github external
elem.clear()
            while elem.getprevious() is not None:
                del elem.getparent()[0]

            if name != '' and version != '' and arch != '':
                if epoch == '0':
                    epoch = ''
                package = PackageString(name=name,
                                        epoch=epoch,
                                        version=version,
                                        release=release,
                                        arch=arch,
                                        packagetype='R')
                packages.add(package)
    else:
        info_message.send(sender=None, text='No packages found in repo')
    return packages
github furlongm / patchman / hosts / models.py View on Github external
with transaction.atomic():
                update, c = updates.get_or_create(
                    oldpackage=package,
                    newpackage=highest_package,
                    security=security)
        except IntegrityError as e:
            error_message.send(sender=None, text=e)
            update = updates.get(oldpackage=package,
                                 newpackage=highest_package,
                                 security=security)
        except DatabaseError as e:
            error_message.send(sender=None, text=e)
        try:
            with transaction.atomic():
                self.updates.add(update)
            info_message.send(sender=None, text='{0!s}'.format(update))
            return update.id
        except IntegrityError as e:
            error_message.send(sender=None, text=e)
        except DatabaseError as e:
            error_message.send(sender=None, text=e)
github furlongm / patchman / reports / utils.py View on Github external
plen=len(packages))
        for i, pkg_str in enumerate(packages):
            package = process_package(pkg_str, report.protocol)
            if package:
                package_ids.append(package.id)
                try:
                    with transaction.atomic():
                        host.packages.add(package)
                except IntegrityError as e:
                    error_message.send(sender=None, text=e)
                except DatabaseError as e:
                    error_message.send(sender=None, text=e)
            else:
                if pkg_str[0].lower() != 'gpg-pubkey':
                    text = 'No package returned for {0!s}'.format(pkg_str)
                    info_message.send(sender=None, text=text)
            progress_update_s.send(sender=None, index=i + 1)

        for package in host.packages.all():
            if package.id not in package_ids:
                host.packages.remove(package)
github furlongm / patchman / repos / models.py View on Github external
def show(self):
        """ Show info about this mirror
        """
        text = ' {0!s} : {1!s}\n'.format(self.id, self.url)
        text += ' last updated: '
        text += '{0!s}    checksum: {1!s}\n'.format(self.timestamp,
                                                    self.file_checksum)
        info_message.send(sender=None, text=text)
github furlongm / patchman / repos / utils.py View on Github external
if epoch is None:
                epoch = ''
            version = fullversion._BaseVersion__upstream_version
            release = fullversion._BaseVersion__debian_revision
            if release is None:
                release = ''
            progress_update_s.send(sender=None, index=i + 1)
            package = PackageString(name=name,
                                    epoch=epoch,
                                    version=version,
                                    release=release,
                                    arch=arch,
                                    packagetype='D')
            packages.add(package)
    else:
        info_message.send(sender=None, text='No packages found in repo')
    return packages
github furlongm / patchman / reports / models.py View on Github external
host.reboot_required = True
            else:
                host.reboot_required = False
            try:
                with transaction.atomic():
                    host.save()
            except IntegrityError as e:
                error_message.send(sender=None, text=e)
            except DatabaseError as e:
                error_message.send(sender=None, text=e)
            host.check_rdns()

            if verbose:
                text = 'Processing report '
                text += '{0!s} - {1!s}'.format(self.id, self.host)
                info_message.send(sender=None, text=text)

            from reports.utils import process_packages, \
                process_repos, process_updates
            with transaction.atomic():
                process_repos(report=self, host=host)
            with transaction.atomic():
                process_packages(report=self, host=host)
            with transaction.atomic():
                process_updates(report=self, host=host)

            self.processed = True
            with transaction.atomic():
                self.save()

            if find_updates:
                if verbose:
github furlongm / patchman / patchman / receivers.py View on Github external
@receiver(info_message)
def print_info_message(sender=None, **kwargs):
    """ Receiver to print an info message, no color
    """
    text = kwargs.get('text')
    if get_verbosity():
        print(Style.RESET_ALL + Fore.RESET + text)
github furlongm / patchman / hosts / models.py View on Github external
def check_rdns(self):
        if self.check_dns:
            update_rdns(self)
            if self.hostname.lower() == self.reversedns.lower():
                info_message.send(sender=None, text='Reverse DNS matches')
            else:
                text = 'Reverse DNS mismatch found: '
                text += '{0!s} != {1!s}'.format(self.hostname, self.reversedns)
                info_message.send(sender=None, text=text)
        else:
            info_message.send(sender=None,
                              text='Reverse DNS check disabled')