How to use the patchman.arch.models.PackageArchitecture.objects.get 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_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)
            a.delete()
            update_pbar(i + 1)
github furlongm / patchman / scripts / import-pakiti2-data.py View on Github external
pbar.update(i+1)
        i += 1

    cursor = conn.cursor(MySQLdb.cursors.DictCursor)
    cursor.execute('SELECT pkgs.name, act_version.arch, act_version.act_version, act_version.act_rel, repositories.id FROM (act_version inner join repositories on act_version.repo_id = repositories.id) inner join pkgs on act_version.pkg_id = pkgs.id')
    rows = cursor.fetchall()

    plength = len(rows)
    pbar = progress_bar('Creating Package<->Repo Links', plength)
    i = 0

    for row in rows:
        repo = Repository.objects.get(id=row['id'])
        p_name = PackageName.objects.get(name=row['name'])
        try:
            package = Package.objects.get(name=p_name,release=row['act_rel'], version=row['act_version'], arch=PackageArchitecture.objects.get(name=row['arch']))
            repo.packages.add(package)
        except Package.DoesNotExist:
            print 'Package does not exist: %s %s %s %s %s %s %s' % (row['name'], p_name, p_name.id, row['act_rel'], row['act_version'], row['arch'], PackageArchitecture.objects.get(name=row['arch']).id)
        repo.save()
        pbar.update(i+1)
        i += 1

    cursor.close()
github furlongm / patchman / scripts / import-pakiti2-data.py View on Github external
def import_available_packages(conn):

    cursor = conn.cursor(MySQLdb.cursors.DictCursor)

    cursor.execute('SELECT * FROM act_version')
    rows = cursor.fetchall()

    plength = len(rows)
    pbar = progress_bar('Available Packages', plength)
    i = 0

    for row in rows:
        package, c = Package.objects.get_or_create(name=PackageName.objects.get(id=row['pkg_id']), version=row['act_version'], release=row['act_rel'], arch=PackageArchitecture.objects.get(name=row['arch']))
#        print PackageName.objects.get(id=row['pkg_id'])
#        print package.name
#        print row['pkg_id']
#        print row['act_version']
#        print '\n\n'
        pbar.update(i+1)
        i += 1
    cursor.close()
github furlongm / patchman / scripts / import-pakiti2-data.py View on Github external
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
    cursor.execute('SELECT pkgs.name, act_version.arch, act_version.act_version, act_version.act_rel, repositories.id FROM (act_version inner join repositories on act_version.repo_id = repositories.id) inner join pkgs on act_version.pkg_id = pkgs.id')
    rows = cursor.fetchall()

    plength = len(rows)
    pbar = progress_bar('Creating Package<->Repo Links', plength)
    i = 0

    for row in rows:
        repo = Repository.objects.get(id=row['id'])
        p_name = PackageName.objects.get(name=row['name'])
        try:
            package = Package.objects.get(name=p_name,release=row['act_rel'], version=row['act_version'], arch=PackageArchitecture.objects.get(name=row['arch']))
            repo.packages.add(package)
        except Package.DoesNotExist:
            print 'Package does not exist: %s %s %s %s %s %s %s' % (row['name'], p_name, p_name.id, row['act_rel'], row['act_version'], row['arch'], PackageArchitecture.objects.get(name=row['arch']).id)
        repo.save()
        pbar.update(i+1)
        i += 1

    cursor.close()