Pārlūkot izejas kodu

warn when github api returns an error

Thomas Buck 1 gadu atpakaļ
vecāks
revīzija
05159e2e0e
1 mainītis faili ar 12 papildinājumiem un 2 dzēšanām
  1. 12
    2
      macros.py

+ 12
- 2
macros.py Parādīt failu

@@ -360,12 +360,22 @@ def lightgallery(links):
360 360
 # github helper macros
361 361
 # -----------------------------------------------------------------------------
362 362
 
363
-import urllib, json
363
+import urllib, json, sys
364 364
 
365 365
 def restRequest(url):
366 366
     response = urllib.urlopen(url)
367 367
     if response.getcode() != 200:
368
-        raise Exception("invalid response code", response.getcode())
368
+        sys.stderr.write("\n")
369
+        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
370
+        sys.stderr.write("!!!!!!!                  WARNING                 !!!!!\n")
371
+        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
372
+        sys.stderr.write("invalid response code: " + str(response.getcode()) + "\n")
373
+        sys.stderr.write("url: \"" + url + "\"\n")
374
+        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
375
+        sys.stderr.write("!!!!!!!                  WARNING                 !!!!!\n")
376
+        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
377
+        sys.stderr.write("\n")
378
+        return ""
369 379
     data = json.loads(response.read())
370 380
     return data
371 381
 

Notiek ielāde…
Atcelt
Saglabāt