Пример #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('service')
    parser.add_argument('-d', '--debug', action='store_true')
    parser.add_argument('-s', '--debug-sql', action='store_true')
    args = parser.parse_args()

    load_config(['/usr/share/koschei/config.cfg', '/etc/koschei/config-backend.cfg'])
    if args.debug:
        logging.getLogger().setLevel(logging.DEBUG)
    if args.debug_sql:
        logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
    log = logging.getLogger('koschei.main')

    plugin.load_plugins('backend')
    svc = service.load_service(args.service)
    if not svc:
        print("No such service", file=sys.stderr)
        sys.exit(2)
    signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))
    try:
        svc(backend.KoscheiBackendSession()).run_service()
    except Exception:
        log.exception("Service %s crashed.", args.service)
        raise
    except KeyboardInterrupt:
        sys.exit(0)
Пример #2
0
from koschei.backend import service


# TODO: move this to plugins requiring fedmsg
def init_fedmsg():
    try:
        import fedmsg
        import fedmsg.meta
        fedmsg_config = fedmsg.config.load_config()
        fedmsg.meta.make_processors(**fedmsg_config)
    except ImportError:
        print("Unable to initialize fedmsg", file=sys.stderr)


if __name__ == '__main__':
    load_config(['/usr/share/koschei/config.cfg', '/etc/koschei/config-backend.cfg'])
    log = logging.getLogger('koschei.main')

    if len(sys.argv) < 2:
        print("Requires service name", file=sys.stderr)
        sys.exit(2)
    name = sys.argv[1]
    plugin.load_plugins('backend')
    init_fedmsg()
    service = service.load_service(name)
    if not service:
        print("No such service", file=sys.stderr)
        sys.exit(2)
    signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))
    try:
        service().run_service()
Пример #3
0
from alembic import context
from logging.config import fileConfig

from koschei.config import load_config
from koschei.db import Base, grant_db_access, get_engine

load_config(['/usr/share/koschei/config.cfg', '/etc/koschei/config-admin.cfg'])

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():
    """Run migrations in 'offline' mode.
Пример #4
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
#
# Author: Michael Simacek <*****@*****.**>

import logging
import time
from sqlalchemy import event
from sqlalchemy.engine import Engine
from koschei.config import load_config

load_config(['config.cfg.template', 'aux/test-config.cfg'])

from koschei.frontend import app as application
import koschei.frontend.views
import koschei.frontend.auth

logger = logging.getLogger("koschei.sql")
logger.setLevel(logging.DEBUG)


@event.listens_for(Engine, "before_cursor_execute")
def before_cursor_execute(conn, cursor, statement, 
                        parameters, context, executemany):
    context._query_start_time = time.time()
    logger.debug("Start Query:\n%s" % statement)
    logger.debug("Parameters:\n%r" % (parameters,))
Пример #5
0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
#
# Author: Michael Simacek <*****@*****.**>

import os

from koschei.config import load_config, get_config

testdir = os.path.dirname(os.path.realpath(__file__))

load_config([
    '{0}/../config.cfg.template'.format(testdir),
    '{0}/test_config.cfg'.format(testdir)
],
            ignore_env=True)

config = get_config(None)
Пример #6
0
from __future__ import print_function

# pylint: disable=W0221
import re
import os
import sys
import argparse
import logging

from koschei.models import (get_engine, Base, Package, PackageGroup, Session,
                            AdminNotice, Collection)
from koschei.backend import Backend, PackagesDontExist, koji_util
from koschei.config import load_config, get_config


load_config(['/usr/share/koschei/config.cfg', '/etc/koschei/config-admin.cfg'])


def parse_group_name(name):
    if '/' not in name:
        return None, name
    ns, _, name = name.partition('/')
    return ns, name


class Command(object):
    needs_backend = True

    def setup_parser(self, parser):
        pass
Пример #7
0
from koschei import config
try:
    from koschei.backend.koji_util import KojiRepoDescriptor
except ImportError:
    from koschei.backend.repo_util import KojiRepoDescriptor
from koschei.backend import koji_util, depsolve, repo_cache

log = logging.getLogger('')

# Use git repo name and branch for module/stream.
module = os.path.basename(os.getcwd())
with open('.git/HEAD') as f:
    stream = re.match(r'ref: refs/heads/(.*)', f.readlines()[0]).group(1)

config.load_config(['koschei.cfg'], ignore_env=True)

full_refs = config.get_config('full_refs')
default_ref = config.get_config('default_ref')
include_build_deps = config.get_config('include_build_deps')
api = config.get_config('api')
profiles = config.get_config('profiles')
includes = config.get_config('includes')
excludes = config.get_config('excludes')
frozen_refs = config.get_config('frozen_refs')
stream_override = config.get_config('stream_override')
macros = config.get_config('macros', None)

ks = koji_util.KojiSession()

tag_name = config.get_koji_config('primary', 'tag_name')
Пример #8
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
#
# Author: Michael Simacek <*****@*****.**>

import logging
import time
from sqlalchemy import event
from sqlalchemy.engine import Engine
from koschei.config import load_config

load_config(['config.cfg.template', 'aux/test-config.cfg'])

from koschei.frontend import app as application
import koschei.frontend.views
import koschei.frontend.auth

logger = logging.getLogger("koschei.sql")
logger.setLevel(logging.DEBUG)


@event.listens_for(Engine, "before_cursor_execute")
def before_cursor_execute(conn, cursor, statement, parameters, context,
                          executemany):
    context._query_start_time = time.time()
    logger.debug("Start Query:\n%s" % statement)
    logger.debug("Parameters:\n%r" % (parameters, ))
Пример #9
0
from koschei.backend import service


# TODO: move this to plugins requiring fedmsg
def init_fedmsg():
    try:
        import fedmsg
        import fedmsg.meta
        fedmsg_config = fedmsg.config.load_config()
        fedmsg.meta.make_processors(**fedmsg_config)
    except ImportError:
        print("Unable to initialize fedmsg", file=sys.stderr)


if __name__ == '__main__':
    load_config(
        ['/usr/share/koschei/config.cfg', '/etc/koschei/config-backend.cfg'])
    log = logging.getLogger('koschei.main')

    if len(sys.argv) < 2:
        print("Requires service name", file=sys.stderr)
        sys.exit(2)
    name = sys.argv[1]
    plugin.load_plugins('backend')
    init_fedmsg()
    service = service.load_service(name)
    if not service:
        print("No such service", file=sys.stderr)
        sys.exit(2)
    signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))
    try:
        service().run_service()
Пример #10
0
# Copyright (C) 2014-2016 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
#
# Author: Michael Simacek <*****@*****.**>

import os

from koschei.config import load_config, get_config

testdir = os.path.dirname(os.path.realpath(__file__))

load_config(['{0}/../config.cfg.template'.format(testdir),
             '{0}/test_config.cfg'.format(testdir)],
            ignore_env=True)

config = get_config(None)