Пример #1
0
def optimal_depcheck():
    optimal = []

    if not depcheck.test_db():
        if depcheck.test_mysqldb():
            text = _("Using the default sqlite3 database engine. SQLite is only suitable for small installations with a small number of users. Pootle will perform better with the MySQL database engine.")
        else:
            text = _("Using the default sqlite3 database engine. SQLite is only suitable for small installations with a small number of users. Pootle will perform better with the MySQL database engine, but you need to install python-MySQLdb first.")
        optimal.append({'dependency': 'db', 'text': text})

    if depcheck.test_cache():
        if depcheck.test_memcache():
            if not depcheck.test_memcached():
                # memcached configured but connection failing
                optimal.append({'dependency': 'cache',
                                'text': _("Pootle is configured to use memcached as a caching backend, but can't connect to the memcached server. Caching is currently disabled.")})
            else:
                if not depcheck.test_session():
                    if depcheck.test_cached_db_session():
                        text = _('For optimal performance, use django.contrib.sessions.backends.cached_db as the session engine.')
                    else:
                        text =  _('For optimal performance, use django.contrib.sessions.backends.cache as the session engine.')
                    optimal.append({'dependency': 'session', 'text': text})
        else:
            optimal.append({'dependency': 'cache',
                            'text': _('Pootle is configured to use memcached as caching backend, but Python support for memcached is not installed. Caching is currently disabled.')})
    else:
        optimal.append({'dependency': 'cache',
                        'text': _('For optimal performance, use memcached as the caching backend.')})

    if not depcheck.test_webserver():
        optimal.append({'dependency': 'webserver',
                        'text': _("For optimal performance, use Apache as the webserver.")})
    if not depcheck.test_from_email():
        optimal.append({'dependency': 'from_email',
                        'text': _('The "from" address used to send registration emails is not specified. Also review the mail server settings.')})
    if not depcheck.test_contact_email():
        optimal.append({'dependency': 'contact_email',
                        'text': _("No contact address is specified. The contact form will allow users to contact the server administrators.")})

    if not depcheck.test_debug():
        optimal.append({'dependency': 'debug',
                        'text': _('Running in debug mode. Debug mode is only needed when developing Pootle. For optimal performance, disable debugging mode.')})

    if not depcheck.test_livetranslation():
        optimal.append({'dependency': 'livetranslation',
                       'text': _("Running in live translation mode. Live translation is useful as a tool to learn about Pootle and localization, but has high impact on performance.")})

    return optimal
Пример #2
0
def required_depcheck():
    required = []

    status, version = depcheck.test_translate()
    if status:
        text = _('Translate Toolkit version %s installed.', version)
        state = 'tick'
    else:
        trans_vars = {
            'installed':
            version,
            'required':
            ".".join([str(i) for i in depcheck.TTK_MINIMUM_REQUIRED_VERSION]),
        }
        text = _(
            "Translate Toolkit version %(installed)s installed. Pootle "
            "requires at least version %(required)s.", trans_vars)
        state = 'error'

    required.append({
        'dependency': 'translate',
        'state': state,
        'text': text,
    })

    status, version = depcheck.test_django()
    if status:
        text = _('Django version %s is installed.', version)
        state = 'tick'
    else:
        trans_vars = {
            'installed':
            version,
            'required':
            ".".join(
                [str(i) for i in depcheck.DJANGO_MINIMUM_REQUIRED_VERSION]),
        }
        text = _(
            "Django version %(installed)s is installed. Pootle requires "
            "at least version %(required)s.", trans_vars)
        state = 'error'

    required.append({
        'dependency': 'django',
        'state': state,
        'text': text,
    })

    status, version = depcheck.test_lxml()
    if status:
        text = _('lxml version %s is installed.', version)
        state = 'tick'
    elif version is not None:
        trans_vars = {
            'installed':
            version,
            'required':
            ".".join([str(i) for i in depcheck.LXML_MINIMUM_REQUIRED_VERSION]),
        }
        text = _(
            "lxml version %(installed)s is installed. Pootle requires at "
            "least version %(required)s.", trans_vars)
        state = 'error'
    else:
        text = _('lxml is not installed. Pootle requires lxml.')
        state = 'error'

    required.append({
        'dependency': 'lxml',
        'state': state,
        'text': text,
    })

    status_redis_available, connection_settings = depcheck.test_redis_server_available(
    )
    if status_redis_available:
        status_redis_version, version = depcheck.test_redis_server_version()
        if status_redis_version:
            text = _(
                'Redis server accepting connections on '
                '%(host)s:%(port)s.', connection_settings)
            state = 'tick'
        else:
            trans_vars = {
                'installed':
                version,
                'required':
                ".".join([
                    str(i)
                    for i in depcheck.REDIS_MINIMUM_REQUIRED_SERVER_VERSION
                ]),
            }
            text = _(
                "Redis server version %(installed)s installed. Pootle "
                "requires at least version %(required)s.", trans_vars)
            state = 'error'
    else:
        text = _('Redis server is not available on %(host)s:%(port)s.',
                 connection_settings)
        state = 'error'

    required.append({
        'dependency': 'redis',
        'state': state,
        'text': text,
    })

    status_workers, connection_settings[
        'num'] = depcheck.test_rq_workers_running()
    if status_workers:
        text = ungettext('%(num)d RQ worker running.',
                         '%(num)d RQ workers running.',
                         connection_settings['num'], connection_settings)
        state = 'tick'
    else:
        text = _('No RQ workers are running.')
        state = 'error'
    required.append({
        'dependency': 'rq',
        'state': state,
        'text': text,
    })

    if depcheck.test_cache():
        if not depcheck.test_cache_server_connection():
            # Server configured but connection failing
            required.append({
                'dependency':
                'cache',
                'state':
                'error',
                'text':
                _("Pootle is configured to use Redis as a caching "
                  "backend, but can't connect to the cache.")
            })
        else:
            required.append({
                'dependency': 'cache',
                'state': 'tick',
                'text': _("Caching configured and running.")
            })
    else:
        required.append({
            'dependency': 'cache',
            'state': 'error',
            'text': _("Redis is required as the caching backend.")
        })

    return required