def __init__(self, api_manager, **options): """ In Flask-Restless, it is up to you to choose which models you would like to make available as an api. It should also be a choice to expose your datamodel, and preferably in the same intuitive way that you register your models. This object functions as a puppet model to give the user the feeling like they are registering just another model they want to expose. """ api_manager.create_api_blueprint = attach_listener( api_manager.create_api_blueprint, self) self.api_manager = api_manager vi = VersionInfo('flask-restless-datamodel') serialize_naively = options.get('serialize_naively', False) self.data_model = { 'FlaskRestlessDatamodel': { 'server_version': vi.release_string(), 'serialize_naively': serialize_naively } } self.polymorphic_info = defaultdict(dict) self.options = options self.model_renderer = None self.model_views = {} self.app = None self.cereal = Cereal(raise_load_errors=options.get( 'raise_load_errors', True), serialize_naively=serialize_naively)
def print_version(): """Print version number and exit.""" from pbr.version import VersionInfo version = VersionInfo('faucet').semantic_version().release_string() message = 'Faucet %s' % version print(message) sys.exit(0)
def key_values(): cli = dict() about_info = About(PKG_NAME) version_info = VersionInfo(PKG_NAME) cli['tapis_cli_name'] = about_info.project cli['tapis_cli_version'] = version_info.version_string() return cli
def __init__(self, reg=None): if reg is not None: self._reg = reg version = VersionInfo('faucet').semantic_version().release_string() self.faucet_version = Gauge( # pylint: disable=unexpected-keyword-arg 'faucet_pbr_version', 'Faucet PBR version', ['version'], registry=self._reg) self.faucet_version.labels(version=version).set(1) # pylint: disable=no-member
def __init__(self, reg=None): if reg is not None: self._reg = reg # TODO: investigate faster alternative (https://bugs.launchpad.net/pbr/+bug/1688405) version = VersionInfo('faucet').semantic_version().release_string() self.faucet_version = PromGauge( # pylint: disable=unexpected-keyword-arg 'faucet_pbr_version', 'Faucet PBR version', ['version'], registry=self._reg) self.faucet_version.labels(version=version).set(1) # pylint: disable=no-member
def __init__(self, reg=None): if reg is not None: self._reg = reg self.version = VersionInfo( 'faucet').semantic_version().release_string() self.faucet_version = PromGauge('faucet_pbr_version', 'Faucet PBR version', ['version'], registry=self._reg) self.faucet_version.labels(version=self.version).set(1) # pylint: disable=no-member self.server = None self.thread = None
def cli(package: str, inc_kwargs: dict) -> None: """Bump a MAJOR.MINOR.PATCH version string at the specified index location or 'patch' digit.""" semver = VersionInfo(package).semantic_version() # Pre-decrement a "dev" version to get the real version tuple. if 'dev' in semver.version_tuple(): semver = semver.decrement() semver = semver.increment(**inc_kwargs) click.echo(semver.release_string(), nl=False)
def get(self): """Retrieve the Storyboard system information. Example:: curl https://my.example.org/api/v1/systeminfo """ sb_ver = VersionInfo('storyboard') return wmodels.SystemInfo(version=sb_ver.version_string())
def __init__(self, app: HTTPApplication): super().__init__(app=app, mount_point='/') self.fernet = MultiFernet( [Fernet(key) for key in settings.AUTH_FERNET_KEYS]) self.api_spec = APISpec( title='Sandwich Cloud API', openapi_version='3.0.0', version=VersionInfo( 'sandwichcloud-deli').semantic_version().release_string(), plugins=[ "deli.counter.http.spec.plugins.docstring", ])
def get_git_rev_or_version(): '''Either get the current git commit or the PyPI distribution Use pbr to get the package version''' command = ['git', 'rev-parse', 'HEAD'] try: output = subprocess.check_output( # nosec command, stderr=subprocess.DEVNULL) if isinstance(output, bytes): output = output.decode('utf-8') ver_type = 'commit' except subprocess.CalledProcessError: ver_type = 'package' output = VersionInfo('tern').version_string() return ver_type, output.split('\n').pop(0)
def create_setup_file(): lib_version = VersionInfo("spotify_tensorflow").version_string() contents_for_setup_file = """ import setuptools if __name__ == "__main__": setuptools.setup( name="spotify_tensorflow_dataflow", packages=setuptools.find_packages(), install_requires=[ "spotify-tensorflow=={version}" ]) """.format(version=lib_version) # noqa: W293 setup_file_path = os.path.join(tempfile.mkdtemp(), "setup.py") with open(setup_file_path, "w") as f: f.writelines(textwrap.dedent(contents_for_setup_file)) return setup_file_path
def test(): extras = {} for i, k in enumerate(['project_id', 'user_id'], 1): try: extras[k] = sys.argv[i] except IndexError: pass vol = { 'name': 'test-volume', 'size': 1 } vol.update(extras) MAX_SEMVER = SemanticVersion(major=3, minor=4, patch=0) semver = VersionInfo('python-novaclient').semantic_version() def list_nova_volumes(): """Conditional on python-novaclient <= 3.3.0""" return nova.volumes.list() if semver <= MAX_SEMVER else [] def get_nova_volume(volume_id): pass print('Listing volumes') vols = { 'cinderclient': cinder.volumes.list(), 'novaclient': list_nova_volumes(), } pprint(vols) print('Creating volume') print(' with: %s' % vol) # NB(kamidzi): os-vol-* attrs appear later vol = cinder.volumes.create(**vol) for state in poll_volume(vol): # wait for tenant_id attribute if str(state.status).lower() == 'available' \ and hasattr(vol, 'os-vol-tenant-attr:tenant_id'): break pprint(render_volume(vol)) print('Listing volumes') vols = { 'cinderclient': cinder.volumes.list(), 'novaclient': list_nova_volumes(), } pprint(vols)
def test_render_template_passed_vals_supercede_builtin(): """Values in a passed dict should override default/discovered values """ from pbr.version import VersionInfo from tapis_cli import PKG_NAME from tapis_cli.templating import render_template version_info = VersionInfo(PKG_NAME) version_string = version_info.version_string() source = 'Tapis CLI version {{ tapis_cli_version }} is cool' env = {} rendered = render_template(source, passed_vals=env) assert version_string in rendered # Pass over-ride value env = {'tapis_cli_version': 9000} rendered = render_template(source, passed_vals=env) assert '9000' in rendered
def main(): bootstrap.execute() governance = Governance() args = cli.argparser(governance.groups()).parse_args() GeneralConfig(args.debug, args.verbose) version = VersionInfo("vigo") if args.version: print("vigo v{version}".format(version=version)) return 0 try: Analyze(args.groups, governance, args.query) except OpenstackerException as err: print(str(err)) return 1 footer = "Generated by vigo v{version}".format(version=version) print("-" * len(footer)) print(footer) print("-" * len(footer)) return 0
def main(): args = cli.argparser().parse_args() version = VersionInfo("sixectomy") if args.version: print("sixectomy v{version}".format(version=version)) return 0 filename = args.file if not filename: return 0 try: analyze = Analyze(filename) except SixectomyException as err: print(str(err)) return 1 else: report = Report() report.rendering("cli.txt", analyze) footer = "Generated by sixectomy v{version}".format(version=version) print("-" * len(footer)) print(footer) print("-" * len(footer)) return 0
def __init__(self): version = VersionInfo('faucet').semantic_version().release_string() self.faucet_version = Gauge('faucet_pbr_version', 'Faucet PBR version', ['version']) # pylint: disable=no-member self.faucet_version.labels(version=version).set(1)
def get_user_agent(): sf_version = VersionInfo('shakenfist_client').version_string() return 'Mozilla/5.0 (Ubuntu; Linux x86_64) Shaken Fist/%s' % sf_version
from .rotation_matrix_3d import rotation_from_angles from .rotation_matrix_3d import rotation_around_x from .rotation_matrix_3d import rotation_around_y from .rotation_matrix_3d import rotation_around_z from .rotation_matrix_3d import rotation_around_axis from .rotation_matrix_nd import rotation_from_angle_and_plane from .rotation_matrix_2d import rotation_from_angle from .rotation_matrix_nd import random_matrix from pbr.version import VersionInfo _v = VersionInfo('mgen').semantic_version() __version__ = _v.release_string() version_info = _v.version_tuple()
import argparse import logging import sys from cliff.app import App from cliff.commandmanager import CommandManager from pbr.version import VersionInfo from . import settings version_info = VersionInfo('dc_cli') class CatalogApp(App): logger = logging.getLogger(__name__) if settings.LOGLEVEL is not None: logging.basicConfig(level=settings.LOGLEVEL) def __init__(self): super(CatalogApp, self).__init__( description='Data Catalog CLI', version=version_info.version_string(), command_manager=CommandManager('dc.cli'), deferred_help=True, ) def build_option_parser(self, description, version): parser = super(CatalogApp, self).build_option_parser(description, version) parser.add_argument('--host',
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # SPDX-License-Identifier: EPL-1.0 ############################################################################## # Copyright (c) 2017-2018 The Linux Foundation and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## """Configuration for Sphinx.""" import os import sys # Sys.path for RTD to resolve docs_conf package sys.path.insert(0, os.path.abspath("..")) from pbr.version import VersionInfo # noqa from docs_conf.conf import * # noqa version = str(VersionInfo("lfdocs-conf")) release = str(VersionInfo("lfdocs-conf")) linkcheck_ignore = [ # The '#' in the path makes sphinx think it's an anchor "https://gerrit.linuxfoundation.org/infra/#/admin/projects/releng/docs-conf" ]
from pbr.version import VersionInfo _v = VersionInfo('clang-build').semantic_version() __version__ = _v.release_string() version_info = _v.version_tuple
#!/usr/bin/python # Copyright (c) 2015 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing # to use, modify, copy, or redistribute it subject to the terms # and conditions of the GNU General Public License version 2. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. from pbr.version import VersionInfo version_info = VersionInfo('nexus')
""" TRAW: TestRail API Wrapper TRAW is an API wrapper for Gurrock's TestRail test management suite The intended way to begin is to instantiate the TRAW Client: .. code-block:: python import traw testrail = traw.Client(username='******', user_api_key='api_key', url='url') See the Client help documentation (`help(traw.Client)`) for more information """ import logging from pbr.version import VersionInfo from .client import Client # NOQA __version__ = VersionInfo('traw').semantic_version().release_string() __all__ = ('__version__', 'Client') logging.getLogger(__package__).addHandler(logging.NullHandler())
from pbr.version import VersionInfo # TODO: 3.8+ and later, use importlib: https://pypi.org/project/importlib-metadata/ __version__ = VersionInfo('networkml').semantic_version().release_string()
from ldap3 import Connection, Server from ldap3 import SIMPLE, SUBTREE, MODIFY_REPLACE from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult, \ LDAPInvalidCredentialsResult, LDAPUserNameIsMandatoryError, \ LDAPSocketOpenError, LDAPExceptionError from time import time from Crypto.PublicKey import RSA from pbr.version import VersionInfo import logging import os BASE_DIR = os.path.dirname(__file__) LOG = logging.getLogger(__name__) LOG_FORMAT = '%(asctime)s %(levelname)s: %(message)s' _v = VersionInfo(__name__).semantic_version() __version__ = _v.release_string() version_info = _v.version_tuple() @get('/') def get_index(): return index_tpl() @post('/') def post_index(): form = request.forms.getunicode def error(msg): return index_tpl(username=form('username'), alerts=[('error', msg)])
'''Like ogopogo, osteoporosis is elusive''' __all__ = ( '__version__', 'version_info', ) from pbr.version import VersionInfo _v = VersionInfo('ogo').semantic_version() __version__ = _v.release_string() version_info = _v.version_tuple()
format: "unit-<ID>" (e.g. unit-mysql/0) """ from pbr.version import VersionInfo from .fakejuju import get_filename, set_envvars, FakeJuju __all__ = [ "__version__", "get_bootstrap_spec", "get_filename", "set_envvars", "FakeJuju", ] _v = VersionInfo("fakejuju").semantic_version() __version__ = _v.release_string() version_info = _v.version_tuple() def get_bootstrap_spec(name, admin_secret=None): """Return the BootstrapSpec instance for the given controller. @param name: The controller name to set up. @param admin_secret: The admin user password to use. """ import txjuju.cli driver = "dummy" default_series = None # Use the default. return txjuju.cli.BootstrapSpec(name, driver, default_series, admin_secret)
def print_version(): """Print version number and exit.""" version = VersionInfo('faucet').semantic_version().release_string() message = 'Faucet %s' % version print(message)
from pbr.version import VersionInfo __version__ = VersionInfo('ipeanim').version_string() __version_info__ = VersionInfo('ipeanim').semantic_version().version_tuple()
def version(self): return VersionInfo( 'sandwichcloud-deli').semantic_version().release_string()