From 6ec7473792a6e8849a0af260aa3cc383454e0741 Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Mon, 15 Jun 2020 15:56:38 +0200
Subject: [PATCH] Intercept unl.ru errors

---
 scripts/unlizeXml.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/unlizeXml.py b/scripts/unlizeXml.py
index db0611e..b5ef35f 100755
--- a/scripts/unlizeXml.py
+++ b/scripts/unlizeXml.py
@@ -32,9 +32,12 @@ def unlize(text, lang, dry_run=False):
         'translate': 'Process'
     }
 
-    r = requests.post(url, data)
-    # Remove garbage before first '['
-    return ''.join(r.text.partition('[')[1:])
+    try:
+        r = requests.post(url, data)
+        # Remove garbage before first '['
+        return ''.join(r.text.partition('[')[1:])
+    except Exception as e:
+        return 'Error calling unl.ru : "{error}"'.format(error=e)
 
 
 def nestedBody2Str(b):
-- 
GitLab