How to use the patchman.repos.models.Repository.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 / scripts / import-pakiti2-data.py View on Github external
repotype="R"
        repo.repotype = repotype
        repo.save()
        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 / sbin / patchman.py View on Github external
def get_repos(repo=None, action='Performing action', only_enabled=False):
    """ Helper function to get a list of repos
    """

    repos = []

    if repo:
        try:
            repos.append(Repository.objects.get(id=repo))
            message = '{0!s} for repo {1!s}'.format(action, repo)
        except:
            message = 'Repo {0!s} does not exist'.format(repo)
    else:
        message = '{0!s} for all repos'.format(action)
        if only_enabled:
            repos = Repository.objects.filter(enabled=True)
        else:
            repos = Repository.objects.all()

    if verbose:
        print message

    return repos