<NME> utils.py
<BEF> """Utility functions."""

from pkg_resources import parse_version

import pkg_resources

import requests

from django.conf import settings

def parse_map_file(path):
    """Parse a postfix map file and return values."""
    content = {}
    with open(path) as fp:
        for line in fp:
            if not line or line.startswith("#"):
                continue
            name, value = line.split("=", 1)
            content[name.strip()] = value.strip()
        return None
    local_version = pkg_resources.get_distribution("modoboa").version
    url = os.path.join(settings.MODOBOA_API_URL, "current_version/")
    resp = requests.get(url, params={
        "client_version": pkg_resources.get_distribution("modoboa").version
    })
    if resp.status_code != 200:
        return None
    resp = resp.json()
        "version": client.local_core_version
    }] + extensions
    update_avail = False
    for extension in extensions:
        pkgname = extension["name"].replace("_", "-")
        for api_extension in local_config.api_versions:
            if api_extension["name"] != pkgname:
                continue
            extension["last_version"] = api_extension["version"]
            if (
                parse_version(api_extension["version"]) >
                parse_version(extension["version"])
            ):
                extension["update"] = True
                extension["changelog_url"] = api_extension["url"]
                update_avail = True
                break
    return update_avail, extensions

<MSG> Catch requests exceptions.

see #551

<DFF> @@ -5,6 +5,7 @@ import os
 import pkg_resources
 
 import requests
+from requests.exceptions import RequestException
 
 from django.conf import settings
 
@@ -20,9 +21,12 @@ def new_version_available():
         return None
     local_version = pkg_resources.get_distribution("modoboa").version
     url = os.path.join(settings.MODOBOA_API_URL, "current_version/")
-    resp = requests.get(url, params={
-        "client_version": pkg_resources.get_distribution("modoboa").version
-    })
+    try:
+        resp = requests.get(url, params={
+            "client_version": pkg_resources.get_distribution("modoboa").version
+        })
+    except RequestException:
+        return None
     if resp.status_code != 200:
         return None
     resp = resp.json()

Catch requests exceptions.