(self, obj)
| 30 | self.conn = HTTPConnection(host, port=port, timeout=30) |
| 31 | |
| 32 | def execute(self, obj): |
| 33 | try: |
| 34 | self.conn.request('POST', '/', json.dumps(obj), |
| 35 | { 'Authorization' : self.authhdr, |
| 36 | 'Content-type' : 'application/json' }) |
| 37 | except ConnectionRefusedError: |
| 38 | print('RPC connection refused. Check RPC settings and the server status.', |
| 39 | file=sys.stderr) |
| 40 | return None |
| 41 | |
| 42 | resp = self.conn.getresponse() |
| 43 | if resp is None: |
| 44 | print("JSON-RPC: no response", file=sys.stderr) |
| 45 | return None |
| 46 | |
| 47 | body = resp.read().decode('utf-8') |
| 48 | resp_obj = json.loads(body) |
| 49 | return resp_obj |
| 50 | |
| 51 | @staticmethod |
| 52 | def build_request(idx, method, params): |
no test coverage detected