소스 검색

warn when github api returns an error

Thomas Buck 1 년 전
부모
커밋
05159e2e0e
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12
    2
      macros.py

+ 12
- 2
macros.py 파일 보기

@@ -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
 

Loading…
취소
저장