コード例 #1
0
 def __getitem__(self, key):
     url = self._url.format(method="GET", key=key)
     string = request.urlopen(url, timeout=.5).read().decode("utf-8")
     value = string.split("\t")[-1][:-1]
     if not value:
         raise UndefinedExtStateError(key)
     value = json.loads(value)
     return value
コード例 #2
0
 def _get_request(self, connection, address):
     try:
         request = connection.recv()
         request = json.loads(request.decode())
     except (ConnectionAbortedError, ConnectionResetError):
         # Client has disconnected
         # Pretend client has nicely requested to disconnect
         input = {"args": (address, ), "kwargs": {}}
         request = {"function": self.disconnect, "input": input}
     return request
コード例 #3
0
ファイル: client.py プロジェクト: tomas1808/reapy
 def _get_result(self):
     s = self.recv(timeout=None).decode()
     return json.loads(s)