def delete(self, fname): resp = rpc.call_sync( conn=self._conn, method="delete", fname=fname ) self._check_error(resp)
def close(self, fname): resp = rpc.call_sync( conn=self._conn, method="close", fname=fname ) self._check_error(resp)
def delete_chunk(self, chunkid): resp = rpc.call_sync( self._conn, "delete_chunk", chunkid=chunkid ) self._check_error(resp)
def request_new_chunk(self, fname): resp = rpc.call_sync( conn=self._conn, method="request_new_chunk", fname=fname ) self._check_error(resp) return ChunkInfo.from_hash(resp)
def open(self, fname): resp = rpc.call_sync( conn=self._conn, method="open", fname=fname ) self._check_error(resp) return FileInfo.from_hash(resp)
def write_chunk(self, chunkid, data): resp = rpc.call_sync( self._conn, "write_chunk", chunkid=chunkid, data=data, ) self._check_error(resp)
def read_chunk(self, chunkid, start_offset=-1, end_offset=-1): resp = rpc.call_sync( self._conn, "read_chunk", chunkid=chunkid, start_offset=start_offset, end_offset=end_offset ) self._check_error(resp) return resp["chunk"]
def ping(self): resp = rpc.call_sync(self._conn, "ping") assert(resp["status"] == "OK")
def addr(self): resp = rpc.call_sync(self._conn, "get_client_port") port = int(resp["port"]) host = self._conn.getpeername()[0] return (host, port)