Example #1
0
def buildPool():
    args = []
    kwargs = {'maxsize': config.xgetint('database', 'pool-maxsize', default=25)}
    dsn = config.xget('database', 'dsn')
    if dsn:
        args.append(dsn)
    else:
        for key in ('database', 'user', 'password', 'host'):
            val = config.xget('database', key)
            if val:
                kwargs[key] = val
        port = config.xgetint('database', 'port')
        if port:
            kwargs['port'] = port
    if not args and not kwargs:
        raise ValueError('database is not configured')
    pool = PostgresConnectionPool(*args, **kwargs)
    initSchema(pool)
    return pool
Example #2
0
def initSchema(pool):
    with pool.cursor() as cur:
        cur.execute(
            'SELECT tablename FROM pg_tables '
             'WHERE tableowner=%s',
            (config.xget('database', 'user',
                default=pwd.getpwuid(os.getuid())[0]),))
        result = set([x[0] for x in cur.fetchall()])
        for key in schema:
            if key not in result:
                cur.execute(schema[key])
Example #3
0
 def __init__(self, pool):
     host = config.xget('web', 'host', default='*')
     port = config.xgetint('web', 'port', default=8080)
     super(ArchRepoWebServer, self).__init__('%s:%d' % (host, port), log=None)
     cherrypy.server.unsubscribe()
     static_dir = resource_filename('archrepo', 'templates/static')
     self.application = cherrypy.tree.mount(
         ArchRepoApplication(pool), config={
             '/': {'tools.sessions.on': True},
             '/static': {'tools.staticdir.on': True,
                         'tools.staticdir.dir': static_dir}})
     self.application.log.access_log.level = self.application.log.access_log.parent.level
     self.application.log.error_log.level = self.application.log.error_log.parent.level
Example #4
0
    def my_init(self, **kwargs):
        self._started_event = AsyncResult()
        self._repo_lock = defaultdict(RLock)
        self._same_pkg_locks = defaultdict(RLock)
        self._ignored_move_events = set()
        self._move_events = {}

        self._pool = kwargs.get('pool')

        self._repo_dir = config.get('repository', 'path')
        self._db_name = config.get('repository', 'name') + '.db.tar.gz'
        self._verify = config.xgetbool('repository', 'verify-tarball', True)
        self._auto_rename = config.xgetbool('repository', 'auto-rename', True)
        self._command_add = config.xget('repository', 'command-add',
                                        default='repo-add')
        self._command_remove = config.xget('repository', 'command-remove',
                                        default='repo-remove')
        self._command_fuser = config.xget('repository', 'command-fuser',
                                          default='fuser')
        self._command_pkginfo = os.path.join(
            os.environ.get('ARCHREPO_PREFIX', sys.prefix), 'bin',
            'read_pkginfo.py')
        self._semaphore = Semaphore(
            config.xgetint('repository', 'concurrent-jobs', default=256))
Example #5
0
 def __init__(self, pool):
     super(FluxAuth, self).__init__(pool)
     self._hmac_key = config.get('flux-sso', 'key')
     self._sso_api_url = config.get('flux-sso', 'api')
     self._sso_cookie = config.xget('flux-sso', 'cookie', default='xsdauth')