@@ -0,0 +1,2390 @@
+import socket%0Aimport ctypes%0A%0AAddr = ctypes.c_ubyte * 4%0A%0AID = ctypes.c_ubyte * 20%0A%0Aclass PlasmaID(ctypes.Structure):%0A  _fields_ = %5B(%22plasma_id%22, ID)%5D%0A%0A# these must be in sync with plasma_request_type in plasma.h%0APLASMA_CREATE = 0%0A%0Aclass PlasmaRequest(ctypes.Structure):%0A  _fields_ = %5B(%22type%22, ctypes.c_int),%0A              (%22manager_id%22, ctypes.c_int),%0A              (%22object_id%22, PlasmaID),%0A              (%22size%22, ctypes.c_int64),%0A              (%22addr%22, Addr),%0A              (%22port%22, ctypes.c_int)%5D%0A%0Aclass PlasmaBuffer(ctypes.Structure):%0A  _fields_ = %5B(%22plasma_id%22, PlasmaID),%0A              (%22data%22, ctypes.c_void_p),%0A              (%22size%22, ctypes.c_int64),%0A              (%22writable%22, ctypes.c_int)%5D%0A%0Adef make_plasma_id(string):%0A  if len(string) != 20:%0A    raise Exception(%22PlasmaIDs must be 20 characters long%22)%0A  object_id = map(ord, string)%0A  return PlasmaID(plasma_id=ID(*object_id))%0A%0Aclass PlasmaClient(object):%0A  def __init__(self, socket_name):%0A    self.client = ctypes.cdll.LoadLibrary(%22../../build/plasma_client.so%22)%0A%0A    self.client.plasma_store_connect.restype = ctypes.c_int%0A%0A    self.client.plasma_create.argtypes = %5Bctypes.c_int, PlasmaID, ctypes.c_int64%5D%0A    self.client.plasma_create.restype = PlasmaBuffer%0A    %0A    self.client.plasma_get.argtypes = %5Bctypes.c_int, PlasmaID%5D%0A    self.client.plasma_get.restype = PlasmaBuffer%0A%0A    self.client.plasma_seal.argtypes = %5Bctypes.c_int, PlasmaID%5D%0A    self.client.plasma_seal.restype = None%0A%0A    self.buffer_from_memory = ctypes.pythonapi.PyBuffer_FromMemory%0A    self.buffer_from_memory.argtypes = %5Bctypes.c_void_p, ctypes.c_int64%5D%0A    self.buffer_from_memory.restype = ctypes.py_object%0A%0A    self.buffer_from_read_write_memory = ctypes.pythonapi.PyBuffer_FromReadWriteMemory%0A    self.buffer_from_read_write_memory.argtypes = %5Bctypes.c_void_p, ctypes.c_int64%5D%0A    self.buffer_from_read_write_memory.restype = ctypes.py_object%0A%0A    self.sock = self.client.plasma_store_connect(socket_name)%0A%0A  def create(self, object_id, size):%0A    buf = self.client.plasma_create(self.sock, make_plasma_id(object_id), size)%0A    return self.buffer_from_read_write_memory(buf.data, buf.size)%0A%0A  def get(self, object_id):%0A    buf = self.client.plasma_get(self.sock, make_plasma_id(object_id))%0A    return self.buffer_from_memory(buf.data, buf.size)%0A    %0A  def seal(self, object_id):%0A    self.client.plasma_seal(self.sock, make_plasma_id(object_id))%0A%0A    %0A

add python client