[fix] Catch ConnectionError from requests package

This commit is contained in:
opi 2016-03-06 19:30:10 +01:00
parent 62620a58cf
commit 8f2e93ddc0

View file

@ -31,6 +31,7 @@ import shutil
import json
import yaml
import errno
import requests
from urllib import urlopen
from moulinette.core import MoulinetteError
@ -88,12 +89,11 @@ def domain_add(auth, domain, dyndns=False):
if dyndns:
if len(domain.split('.')) < 3:
raise MoulinetteError(errno.EINVAL, m18n.n('domain_dyndns_invalid'))
import requests
from yunohost.dyndns import dyndns_subscribe
try:
r = requests.get('https://dyndns.yunohost.org/domains')
except ConnectionError:
except requests.ConnectionError:
pass
else:
dyndomains = json.loads(r.text)