Browse Source

warn when github api returns an error

Thomas Buck 1 year ago
parent
commit
05159e2e0e
1 changed files with 12 additions and 2 deletions
  1. 12
    2
      macros.py

+ 12
- 2
macros.py View File

360
 # github helper macros
360
 # github helper macros
361
 # -----------------------------------------------------------------------------
361
 # -----------------------------------------------------------------------------
362
 
362
 
363
-import urllib, json
363
+import urllib, json, sys
364
 
364
 
365
 def restRequest(url):
365
 def restRequest(url):
366
     response = urllib.urlopen(url)
366
     response = urllib.urlopen(url)
367
     if response.getcode() != 200:
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
     data = json.loads(response.read())
379
     data = json.loads(response.read())
370
     return data
380
     return data
371
 
381
 

Loading…
Cancel
Save