Package coprs :: Module helpers
[hide private]
[frames] | no frames]

Module helpers

source code

Classes [hide private]
CounterStatType
PermissionEnum
BuildSourceEnum
JSONEncodedDict
Represents an immutable structure as a json-encoded string.
Paginator
Serializer
RedisConnectionProvider
StringLiteral
Teach SA how to literalize various things.
LiteralDialect
SubdirMatch
Functions [hide private]
 
generate_api_token(size=30)
Generate a random string used as token to access the API remotely.
source code
 
chroot_to_branch(chroot)
Get a git branch name from chroot.
source code
 
parse_package_name(pkg)
Parse package name from possibly incomplete nvra string.
source code
 
generate_repo_url(mock_chroot, url)
Generates url with build results for .repo file.
source code
 
fix_protocol_for_backend(url)
Ensure that url either has http or https protocol according to the option in app config "ENFORCE_PROTOCOL_FOR_BACKEND_URL"
source code
 
fix_protocol_for_frontend(url)
Ensure that url either has http or https protocol according to the option in app config "ENFORCE_PROTOCOL_FOR_FRONTEND_URL"
source code
 
get_redis_connection()
Creates connection to redis, now we use default instance at localhost, no config needed
source code
 
str2bool(v) source code
 
copr_url(view, copr, **kwargs)
Examine given copr and generate proper URL for the `view`
source code
 
url_for_copr_view(view, group_view, copr, **kwargs) source code
 
url_for_copr_builds(copr) source code
 
literal_query(statement)
NOTE: This is entirely insecure.
source code
 
stream_template(template_name, **context) source code
 
generate_repo_name(repo_url)
based on url, generate repo name
source code
 
pre_process_repo_url(chroot, repo_url)
Expands variables and sanitize repo url to be used for mock config
source code
 
parse_repo_params(repo, supported_keys=None)
:param repo: str repo from Copr/CoprChroot/Build/...
source code
 
generate_build_config(copr, chroot_id)
Return dict with proper build config contents
source code
 
generate_additional_repos(copr_chroot) source code
 
trim_git_url(url) source code
 
get_parsed_git_url(url) source code
 
get_copr_repo_id(copr_dir)
We cannot really switch to the new copr:{hostname}:{owner}:{project} format yet, because it is implemented in dnf-plugins-core-3.x which is only on F29+
source code
 
pagure_html_diff_changed(html_string) source code
 
raw_commit_changes(text) source code
Variables [hide private]
  REPO_DL_STAT_FMT = "repo_dl_stat::{copr_user}@{copr_project_na...
  CHROOT_REPO_MD_DL_STAT_FMT = "chroot_repo_metadata_dl_stat:hse...
  CHROOT_RPMS_DL_STAT_FMT = "chroot_rpms_dl_stat:hset::{copr_use...
  PROJECT_RPMS_DL_STAT_FMT = "project_rpms_dl_stat:hset::{copr_u...
  FINISHED_STATUSES = ["succeeded", "forked", "canceled", "skipp...
  PY3 = str is not bytes
  text = str if PY3 else unicode
  int_type = int if PY3 else(int, long)
  str_type = str if PY3 else(str, unicode)
Function Details [hide private]

generate_api_token(size=30)

source code 
Generate a random string used as token to access the API
remotely.

:kwarg: size, the size of the token to generate, defaults to 30
    chars.
:return: a string, the API token for the user.

chroot_to_branch(chroot)

source code 

Get a git branch name from chroot. Follow the fedora naming standard.

generate_repo_url(mock_chroot, url)

source code 

Generates url with build results for .repo file. No checks if copr or mock_chroot exists.

copr_url(view, copr, **kwargs)

source code 

Examine given copr and generate proper URL for the `view`

Values of `username/group_name` and `coprname` are automatically passed as the first two URL parameters,
and therefore you should *not* pass them manually.

Usage:
  copr_url("coprs_ns.foo", copr)
  copr_url("coprs_ns.foo", copr, arg1='bar', arg2='baz)

literal_query(statement)

source code 

NOTE: This is entirely insecure. DO NOT execute the resulting strings. This can be used for debuggin - it is not and should not be used in production code.

It is useful if you want to debug an sqlalchemy query, i.e. copy the resulting SQL query into psql console and try to tweak it so that it actually works or works faster.

parse_repo_params(repo, supported_keys=None)

source code 

:param repo: str repo from Copr/CoprChroot/Build/... :param supported_keys list of supported optional parameters :return: dict of optional parameters parsed from the repo URL

get_copr_repo_id(copr_dir)

source code 

We cannot really switch to the new
copr:{hostname}:{owner}:{project} format yet, because it is implemented in
dnf-plugins-core-3.x which is only on F29+

Since the F29+ plugin is able to work with both old and new formats, we can
safely stay with the old one until F28 is still supported. Once it goes EOL,
we can migrate to the new format.

New format is:

    return "copr:{0}:{1}:{2}".format(app.config["PUBLIC_COPR_HOSTNAME"].split(":")[0],
                                     copr_dir.copr.owner_name.replace("@", "group_"),
                                     copr_dir.name)


Variables Details [hide private]

REPO_DL_STAT_FMT

Value:
"repo_dl_stat::{copr_user}@{copr_project_name}:{copr_name_release}"

CHROOT_REPO_MD_DL_STAT_FMT

Value:
"chroot_repo_metadata_dl_stat:hset::{copr_user}@{copr_project_name}:{c\
opr_chroot}"

CHROOT_RPMS_DL_STAT_FMT

Value:
"chroot_rpms_dl_stat:hset::{copr_user}@{copr_project_name}:{copr_chroo\
t}"

PROJECT_RPMS_DL_STAT_FMT

Value:
"project_rpms_dl_stat:hset::{copr_user}@{copr_project_name}"

FINISHED_STATUSES

Value:
["succeeded", "forked", "canceled", "skipped", "failed"]