How to use pbr - 10 common examples

To help you get started, we’ve selected a few pbr 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 openstack / os-testr / os_testr / subunit2html.py View on Github external
"""

import codecs
import collections
import datetime
import io
import sys
import traceback
from xml.sax import saxutils

import pbr.version
import subunit
import testtools


__version__ = pbr.version.VersionInfo('os_testr').version_string()


class TemplateData(object):
    """Define a HTML template for report customerization and generation.

    Overall structure of an HTML report

    HTML
    +------------------------+
    |                  |
    |                  |
    |                        |
    |   STYLESHEET           |
    |   +----------------+   |
    |   |                |   |
    |   +----------------+   |
github openstack / masakari-monitors / masakarimonitors / cmd / hostmonitor.py View on Github external
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "masakarimonitors")
    utils.monkey_patch()

    # From openstacksdk version 0.11.1 onwards, there is no way
    # you can add service to the connection. Hence we need to monkey patch
    # _find_service_filter_class method from sdk to allow
    # to point to the correct service filter class implemented in
    # masakari-monitors.
    sdk_ver = pbr.version.VersionInfo('openstacksdk').version_string()
    if sdk_ver in ['0.11.1', '0.11.2', '0.11.3']:
        utils.monkey_patch_for_openstacksdk("openstack._meta:masakarimonitors."
                                            "cmd."
                                            "masakari_service_filter_class")
    if sdk_ver in ['0.12.0']:
        utils.monkey_patch_for_openstacksdk("openstack._meta.connection:"
                                            "masakarimonitors.cmd."
                                            "masakari_service_filter_class")

    server = service.Service.create(binary='masakarimonitors-hostmonitor')
    service.serve(server)
    service.wait()
github openstack / pbr / pbr / builddoc.py View on Github external
'autodoc_index_modules',
                                                'AUTODOC_INDEX_MODULES')
        if not os.getenv('SPHINX_DEBUG'):
            # NOTE(afazekas): These options can be used together,
            # but they do a very similar thing in a different way
            if tree_index:
                self._sphinx_tree()
            if auto_index:
                self.generate_autoindex(
                    set(option_dict.get(
                        "autodoc_exclude_modules",
                        [None, ""])[1].split()))

        self.finalize_options()

        is_multibuilder_sphinx = version.SemanticVersion.from_pip_string(
            sphinx.__version__) >= version.SemanticVersion(1, 6)

        # TODO(stephenfin): Remove support for Sphinx < 1.6 in 4.0
        if not is_multibuilder_sphinx:
            log.warn('[pbr] Support for Sphinx < 1.6 will be dropped in '
                     'pbr 4.0. Upgrade to Sphinx 1.6+')

        # TODO(stephenfin): Remove this at the next MAJOR version bump
        if self.builders != ['html']:
            log.warn("[pbr] Sphinx 1.6 added native support for "
                     "specifying multiple builders in the "
                     "'[sphinx_build] builder' configuration option, "
                     "found in 'setup.cfg'. As a result, the "
                     "'[sphinx_build] builders' option has been "
                     "deprecated and will be removed in pbr 4.0. Migrate "
                     "to the 'builder' configuration option.")
github ryfeus / lambda-packs / Tensorflow / source / pbr / packaging.py View on Github external
def _from_git(distribution):
    option_dict = distribution.get_option_dict('pbr')
    changelog = git._iter_log_oneline()
    if changelog:
        changelog = git._iter_changelog(changelog)
    git.write_git_changelog(option_dict=option_dict, changelog=changelog)
    git.generate_authors(option_dict=option_dict)
github ryfeus / lambda-packs / Tensorflow / source / pbr / packaging.py View on Github external
def _get_version_from_git(pre_version=None):
    """Calculate a version string from git.

    If the revision is tagged, return that. Otherwise calculate a semantic
    version description of the tree.

    The number of revisions since the last tag is included in the dev counter
    in the version for untagged versions.

    :param pre_version: If supplied use this as the target version rather than
        inferring one from the last tag + commit messages.
    """
    git_dir = git._run_git_functions()
    if git_dir:
        try:
            tagged = git._run_git_command(
                ['describe', '--exact-match'], git_dir,
                throw_on_error=True).replace('-', '.')
            target_version = version.SemanticVersion.from_pip_string(tagged)
        except Exception:
            if pre_version:
                # not released yet - use pre_version as the target
                target_version = version.SemanticVersion.from_pip_string(
                    pre_version)
            else:
                # not released yet - just calculate from git history
                target_version = None
        result = _get_version_from_git_target(git_dir, target_version)
        return result.release_string()
github pyscaffold / pyscaffold / pbr / packaging.py View on Github external
def _from_git(distribution):
    option_dict = distribution.get_option_dict('pbr')
    changelog = git._iter_log_oneline()
    if changelog:
        changelog = git._iter_changelog(changelog)
    git.write_git_changelog(option_dict=option_dict, changelog=changelog)
    git.generate_authors(option_dict=option_dict)
github openstack / pbr / pbr / builddoc.py View on Github external
warn_env = list(filter(lambda x: os.getenv(x), _deprecated_envs))
        if warn_opts or warn_env:
            msg = ('The autodoc and autodoc_tree features are deprecated in '
                   '4.2 and will be removed in a future release. You should '
                   'use the sphinxcontrib-apidoc Sphinx extension instead. '
                   'Refer to the pbr documentation for more information.')
            if warn_opts:
                msg += ' Deprecated options: %s' % list(warn_opts)
            if warn_env:
                msg += ' Deprecated environment variables: %s' % warn_env

            log.warn(msg)

        if git._git_is_installed():
            git.write_git_changelog(option_dict=option_dict)
            git.generate_authors(option_dict=option_dict)
        tree_index = options.get_boolean_option(option_dict,
                                                'autodoc_tree_index_modules',
                                                'AUTODOC_TREE_INDEX_MODULES')
        auto_index = options.get_boolean_option(option_dict,
                                                'autodoc_index_modules',
                                                'AUTODOC_INDEX_MODULES')
        if not os.getenv('SPHINX_DEBUG'):
            # NOTE(afazekas): These options can be used together,
            # but they do a very similar thing in a different way
            if tree_index:
                self._sphinx_tree()
            if auto_index:
                self.generate_autoindex(
                    set(option_dict.get(
                        "autodoc_exclude_modules",
                        [None, ""])[1].split()))
github openstack / pbr / pbr / packaging.py View on Github external
def _get_version_from_git(pre_version):
    """Return a version which is equal to the tag that's on the current
    revision if there is one, or tag plus number of additional revisions
    if the current revision has no tag.
    """

    git_dir = git._run_git_functions()
    if git_dir:
        if pre_version:
            try:
                return git._run_git_command(
                    ['describe', '--exact-match'], git_dir,
                    throw_on_error=True).replace('-', '.')
            except Exception:
                return "%s.dev%s" % (pre_version, _get_revno(git_dir))
        else:
            # git describe always is going to return one of three things
            # - a short-sha if there are no tags
            # - a tag, if there's one on the current revision
            # - a string of the form $last_tag-$revs_since_last_tag-g$short_sha
            raw_version = git._run_git_command(['describe', '--always'],
                                               git_dir)
            # First, if there are no -'s or .'s, then it's just a short sha.
            # Create a synthetic version for it.
            if '-' not in raw_version and '.' not in raw_version:
                return "0.0.0.post%s" % _get_revno(git_dir)
            # Now, we want to strip the short-sha prefix
github ryfeus / lambda-packs / Tensorflow / source / pbr / packaging.py View on Github external
def _from_git(distribution):
    option_dict = distribution.get_option_dict('pbr')
    changelog = git._iter_log_oneline()
    if changelog:
        changelog = git._iter_changelog(changelog)
    git.write_git_changelog(option_dict=option_dict, changelog=changelog)
    git.generate_authors(option_dict=option_dict)
github pymedusa / Medusa / ext / pbr / packaging.py View on Github external
def _get_version_from_git(pre_version=None):
    """Calculate a version string from git.

    If the revision is tagged, return that. Otherwise calculate a semantic
    version description of the tree.

    The number of revisions since the last tag is included in the dev counter
    in the version for untagged versions.

    :param pre_version: If supplied use this as the target version rather than
        inferring one from the last tag + commit messages.
    """
    git_dir = git._run_git_functions()
    if git_dir:
        try:
            tagged = git._run_git_command(
                ['describe', '--exact-match'], git_dir,
                throw_on_error=True).replace('-', '.')
            target_version = version.SemanticVersion.from_pip_string(tagged)
        except Exception:
            if pre_version:
                # not released yet - use pre_version as the target
                target_version = version.SemanticVersion.from_pip_string(
                    pre_version)
            else:
                # not released yet - just calculate from git history
                target_version = None
        result = _get_version_from_git_target(git_dir, target_version)
        return result.release_string()
    # If we don't know the version, return an empty string so at least
    # the downstream users of the value always have the same type of
    # object to work with.