Exemplo n.º 1
0
def check_backups(app_configs, **kwargs):
    from weblate.wladmin.models import BackupService

    errors = []
    if not BackupService.objects.filter(enabled=True).exists():
        errors.append(
            weblate_check(
                "weblate.I028",
                "Backups are not configured, "
                "it is highly recommended for production use",
                Info,
            ))
    for service in BackupService.objects.filter(enabled=True):
        try:
            last_obj = service.last_logs()[0]
            last_event = last_obj.event
            last_log = last_obj.log
        except IndexError:
            last_event = "error"
            last_log = "missing"
        if last_event == "error":
            errors.append(
                weblate_check(
                    "weblate.C029",
                    f"There was error while performing backups: {last_log}",
                ))
            break

    return errors
Exemplo n.º 2
0
def check_gpg(app_configs, **kwargs):
    get_gpg_public_key()
    template = "{}: {}"
    return [
        weblate_check("weblate.C036", template.format(key, message))
        for key, message in GPG_ERRORS.items()
    ]
Exemplo n.º 3
0
def check_fonts(app_configs=None, **kwargs):
    """Checks font rendering."""
    try:
        render_size("DejaVu Sans", Pango.Weight.NORMAL, 11, 0, "test")
        return []
    except Exception as error:
        return [weblate_check("weblate.C024", "Failed to use Pango: {}".format(error))]
Exemplo n.º 4
0
def check_avatars(app_configs, **kwargs):
    if not settings.ENABLE_AVATARS:
        return []
    try:
        download_avatar_image("*****@*****.**", 32)
        return []
    except (OSError, CertificateError) as error:
        return [weblate_check("weblate.E018", f"Failed to download avatar: {error}")]
Exemplo n.º 5
0
def check_formats(app_configs, **kwargs):
    from weblate.formats.models import FILE_FORMATS

    message = "Failure in loading handler for {} file format: {}"
    return [
        weblate_check(f"weblate.W025.{key}",
                      message.format(key, value.strip()), Warning)
        for key, value in FILE_FORMATS.errors.items()
    ]
Exemplo n.º 6
0
def check_vcs(app_configs, **kwargs):
    from weblate.vcs.models import VCS_REGISTRY

    message = "Failure in loading VCS module for {}: {}"
    return [
        weblate_check(f"weblate.W033.{key}",
                      message.format(key, value.strip()), Warning)
        for key, value in VCS_REGISTRY.errors.items()
    ]
Exemplo n.º 7
0
def check_git_backend(app_configs, **kwargs):
    if find_git_http_backend() is None:
        return [
            weblate_check(
                "weblate.E022",
                "Failed to find git-http-backend, the git exporter will not work.",
            )
        ]
    return []
Exemplo n.º 8
0
def check_avatars(app_configs, **kwargs):
    from weblate.auth.models import get_anonymous
    from weblate.accounts.avatar import download_avatar_image

    if not settings.ENABLE_AVATARS:
        return []
    try:
        download_avatar_image(get_anonymous(), 32)
        return []
    except (IOError, CertificateError) as error:
        return [weblate_check("weblate.E018", f"Failed to download avatar: {error}")]
Exemplo n.º 9
0
def check_version(app_configs=None, **kwargs):
    try:
        latest = get_latest_version()
    except (ValueError, OSError):
        return []
    if LooseVersion(latest.version) > LooseVersion(VERSION_BASE):
        # With release every two months, this get's triggered after three releases
        if latest.timestamp + timedelta(days=180) < datetime.now():
            return [
                weblate_check(
                    "weblate.C031",
                    "You Weblate version is outdated, please upgrade to {}.".
                    format(latest.version),
                )
            ]
        return [
            weblate_check(
                "weblate.I031",
                "New Weblate version is available, please upgrade to {}.".
                format(latest.version),
                Info,
            )
        ]
    return []
Exemplo n.º 10
0
def check_git(app_configs, **kwargs):
    template = "Failure in configuring Git: {}"
    return [
        weblate_check("weblate.C035", template.format(message))
        for message in GIT_ERRORS
    ]