mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Don't display log advertisement if not needed
This commit is contained in:
parent
5e5ac0be50
commit
37c5547755
2 changed files with 44 additions and 6 deletions
|
@ -42,6 +42,7 @@ from moulinette.utils.log import getActionLogger
|
|||
|
||||
import yunohost.domain
|
||||
from yunohost.utils.network import get_public_ip
|
||||
from yunohost.utils.errors import YunoHostError
|
||||
|
||||
from moulinette import m18n
|
||||
from yunohost.app import app_ssowatconf
|
||||
|
@ -839,13 +840,15 @@ def _check_domain_is_ready_for_ACME(domain):
|
|||
|
||||
# Check if IP from DNS matches public IP
|
||||
if not _dns_ip_match_public_ip(public_ip, domain):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_dns_ip_differs_from_public_ip', domain=domain))
|
||||
raise YunoHostError(m18n.n(
|
||||
'certmanager_domain_dns_ip_differs_from_public_ip', domain=domain),
|
||||
log_advertisement=False)
|
||||
|
||||
# Check if domain seems to be accessible through HTTP?
|
||||
if not _domain_is_accessible_through_HTTP(public_ip, domain):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_http_not_working', domain=domain))
|
||||
raise YunoHostError(m18n.n(
|
||||
'certmanager_domain_http_not_working', domain=domain),
|
||||
log_advertisement=False)
|
||||
|
||||
|
||||
def _get_dns_ip(domain):
|
||||
|
@ -854,8 +857,9 @@ def _get_dns_ip(domain):
|
|||
resolver.nameservers = DNS_RESOLVERS
|
||||
answers = resolver.query(domain, "A")
|
||||
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_error_no_A_record', domain=domain))
|
||||
raise YunoHostError(m18n.n(
|
||||
'certmanager_error_no_A_record', domain=domain),
|
||||
log_advertisement=False)
|
||||
|
||||
return str(answers[0])
|
||||
|
||||
|
|
34
src/yunohost/utils/errors.py
Normal file
34
src/yunohost/utils/errors.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" License
|
||||
|
||||
Copyright (C) 2018 YUNOHOST.ORG
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, see http://www.gnu.org/licenses
|
||||
|
||||
"""
|
||||
import errno
|
||||
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
|
||||
class YunoHostError(MoulinetteError):
|
||||
"""
|
||||
YunoHostError allows to indicate if we should or shouldn't display a message
|
||||
to users about how to display logs about this error.
|
||||
"""
|
||||
|
||||
def __init__(self, message, log_advertisement=True):
|
||||
self.log_advertisement = log_advertisement
|
||||
super(YunoHostError, self).__init__(errno.EINVAL, message)
|
Loading…
Add table
Reference in a new issue