(url, options=None)
| 737 | logger.critical(errMsg) |
| 738 | |
| 739 | def _client(url, options=None): |
| 740 | logger.debug("Calling '%s'" % url) |
| 741 | try: |
| 742 | headers = {"Content-Type": "application/json"} |
| 743 | |
| 744 | if options is not None: |
| 745 | data = getBytes(jsonize(options)) |
| 746 | else: |
| 747 | data = None |
| 748 | |
| 749 | if DataStore.username or DataStore.password: |
| 750 | headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False) |
| 751 | |
| 752 | req = _urllib.request.Request(url, data, headers) |
| 753 | response = _urllib.request.urlopen(req) |
| 754 | text = getText(response.read()) |
| 755 | except: |
| 756 | if options: |
| 757 | logger.error("Failed to load and parse %s" % url) |
| 758 | raise |
| 759 | return text |
| 760 | |
| 761 | def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=None, password=None): |
| 762 | """ |
no test coverage detected
searching dependent graphs…