From ecd6b51b126ee473c4942a53d1b17a76dd6b11c3 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 29 Dec 2015 18:36:17 +0100 Subject: Avoided to crash when the Internet is not reachable. --- ChangeLog | 5 +++++ plugins/python/welcome/version.py | 23 ++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index fcec4f1..eb972c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 15-12-29 Cyrille Bagard + * plugins/python/welcome/version.py: + Avoid to crash when the Internet is not reachable. + +15-12-29 Cyrille Bagard + * src/arch/vmpa.c: * src/arch/vmpa.h: Detect intersections between two ranges. diff --git a/plugins/python/welcome/version.py b/plugins/python/welcome/version.py index c823d60..9bd4db2 100644 --- a/plugins/python/welcome/version.py +++ b/plugins/python/welcome/version.py @@ -76,19 +76,24 @@ To display the lastest available version, please install the urllib3 pack lastest = None http = urllib3.PoolManager() - request = http.request('GET', 'http://0xdeadc0de.fr/chrysalide/updates/versions') + try: + request = http.request('GET', 'http://0xdeadc0de.fr/chrysalide/updates/versions') + except urllib3.exceptions.MaxRetryError: + request = None - html = request.data.decode('utf-8') + if request != None: - request.release_conn() + html = request.data.decode('utf-8') - available = html.split('\n') + request.release_conn() - for a in available: - desc = a.split('=') - if desc[0] == category: - lastest = desc[1] - break + available = html.split('\n') + + for a in available: + desc = a.split('=') + if desc[0] == category: + lastest = desc[1] + break return lastest -- cgit v0.11.2-87-g4458