Selaa lähdekoodia

[fix] encapsulate wolframalpha token fetching errors

Adam Tauber 9 vuotta sitten
vanhempi
commit
db72fc6449
1 muutettua tiedostoa jossa 6 lisäystä ja 3 poistoa
  1. 6
    3
      searx/engines/wolframalpha_noapi.py

+ 6
- 3
searx/engines/wolframalpha_noapi.py Näytä tiedosto

@@ -44,9 +44,12 @@ token = {'value': '',
44 44
 # seems, wolframalpha resets its token in every hour
45 45
 def obtain_token():
46 46
     update_time = time() - (time() % 3600)
47
-    token_response = http_get('https://www.wolframalpha.com/input/api/v1/code?ts=9999999999999999999', timeout=2.0)
48
-    token['value'] = loads(token_response.text)['code']
49
-    token['last_updated'] = update_time
47
+    try:
48
+        token_response = http_get('https://www.wolframalpha.com/input/api/v1/code?ts=9999999999999999999', timeout=2.0)
49
+        token['value'] = loads(token_response.text)['code']
50
+        token['last_updated'] = update_time
51
+    except:
52
+        pass
50 53
     return token
51 54
 
52 55