feat: replication progress
This commit is contained in:
@ -22,7 +22,8 @@ from . import environment
|
|||||||
DEPENDENCIES = {
|
DEPENDENCIES = {
|
||||||
"zmq",
|
"zmq",
|
||||||
"umsgpack",
|
"umsgpack",
|
||||||
"yaml"
|
"yaml",
|
||||||
|
"esper"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
12
client.py
12
client.py
@ -12,7 +12,7 @@ from random import randint
|
|||||||
import zmq
|
import zmq
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from . import environment, helpers, message
|
from . import environment,replication, helpers, message
|
||||||
from .libs import dump_anything, umsgpack
|
from .libs import dump_anything, umsgpack
|
||||||
|
|
||||||
CONNECT_TIMEOUT = 2
|
CONNECT_TIMEOUT = 2
|
||||||
@ -98,6 +98,15 @@ class Client(object):
|
|||||||
id, str) else id), (address.encode() if isinstance(
|
id, str) else id), (address.encode() if isinstance(
|
||||||
address, str) else address), b'%d' % port])
|
address, str) else address), b'%d' % port])
|
||||||
|
|
||||||
|
def replicate(self, py_object):
|
||||||
|
"""Entry point for python object replication
|
||||||
|
- Create object replication structure
|
||||||
|
- Add it to the distributed hash table
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
# node = Factory(py_object)
|
||||||
|
|
||||||
|
# self.store
|
||||||
def init(self):
|
def init(self):
|
||||||
"""
|
"""
|
||||||
Scene initialisation
|
Scene initialisation
|
||||||
@ -129,7 +138,6 @@ class Client(object):
|
|||||||
|
|
||||||
def add(self, key, value=None):
|
def add(self, key, value=None):
|
||||||
"""Set new value in distributed hash table
|
"""Set new value in distributed hash table
|
||||||
Sends [SET][key][value] to the agent
|
|
||||||
"""
|
"""
|
||||||
self.serial_feed.put(key)
|
self.serial_feed.put(key)
|
||||||
|
|
||||||
|
@ -13,35 +13,39 @@ import zmq
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
class ReplicatedDatablock(object):
|
class ReplicatedDatablock(object):
|
||||||
"""
|
"""
|
||||||
Datablock used for replication
|
Datablock used for replication
|
||||||
"""
|
"""
|
||||||
uuid = None # key (string)
|
uuid = None # key (string)
|
||||||
data = None # data blob
|
|
||||||
pointer = None # dcc data reference
|
pointer = None # dcc data reference
|
||||||
|
data = None # data blob (json)
|
||||||
|
deps = []
|
||||||
|
|
||||||
def __init__(self, owner=None, data=None):
|
def __init__(self, owner=None, data=None):
|
||||||
self.uuid = str(uuid4())
|
self.uuid = str(uuid4())
|
||||||
assert(owner)
|
assert(owner)
|
||||||
|
|
||||||
self.pointer = data
|
self.pointer = data
|
||||||
|
|
||||||
|
|
||||||
def push(self, socket):
|
def push(self, socket):
|
||||||
"""
|
"""
|
||||||
Here send data over the wire
|
Here send data over the wire:
|
||||||
|
- serialize the data
|
||||||
|
- send them as a multipart frame
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pull(cls, socket):
|
def pull(cls, socket):
|
||||||
"""
|
"""
|
||||||
Here we reeceive data from the wire
|
Here we reeceive data from the wire:
|
||||||
|
- read data from the socket
|
||||||
|
- reconstruct an instance
|
||||||
"""
|
"""
|
||||||
uuid, owner, body = socket.recv_multipart(zmq.NOBLOCK)
|
pass
|
||||||
key = key.decode() if key else None
|
|
||||||
id = id if id else None
|
|
||||||
body = umsgpack.unpackb(body) if body else None
|
|
||||||
|
|
||||||
def store(self, dict, persistent=False):
|
def store(self, dict, persistent=False):
|
||||||
"""
|
"""
|
||||||
@ -56,64 +60,59 @@ class ReplicatedDatablock(object):
|
|||||||
dict[self.uuid] = self
|
dict[self.uuid] = self
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def decode_data(self):
|
def deserialize(self):
|
||||||
"""
|
"""
|
||||||
I want to apply changes into the DCC
|
I want to apply changes into the DCC
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def encode_data(self):
|
def serialize(self):
|
||||||
"""
|
"""
|
||||||
I want to load data from DCC
|
I want to load data from DCC
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
class RpTest(ReplicatedDatablock):
|
|
||||||
def decode_data(self):
|
|
||||||
test_data = {}
|
|
||||||
|
|
||||||
|
import bpy, mathutils
|
||||||
|
|
||||||
# class RpObject(ReplicatedDatablock):
|
class RepObject(ReplicatedDatablock):
|
||||||
# def decode_data(self):
|
def deserialize(self):
|
||||||
# try:
|
try:
|
||||||
# if self.pointer is None:
|
if self.pointer is None:
|
||||||
# pointer = None
|
pointer = None
|
||||||
|
|
||||||
# # Object specific constructor...
|
# Object specific constructor...
|
||||||
# if data["data"] in bpy.data.meshes.keys():
|
if self.data["data"] in bpy.data.meshes.keys():
|
||||||
# pointer = bpy.data.meshes[data["data"]]
|
pointer = bpy.data.meshes[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.lights.keys():
|
elif self.data["data"] in bpy.data.lights.keys():
|
||||||
# pointer = bpy.data.lights[data["data"]]
|
pointer = bpy.data.lights[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.cameras.keys():
|
elif self.data["data"] in bpy.data.cameras.keys():
|
||||||
# pointer = bpy.data.cameras[data["data"]]
|
pointer = bpy.data.cameras[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.curves.keys():
|
elif self.data["data"] in bpy.data.curves.keys():
|
||||||
# pointer = bpy.data.curves[data["data"]]
|
pointer = bpy.data.curves[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.armatures.keys():
|
elif self.data["data"] in bpy.data.armatures.keys():
|
||||||
# pointer = bpy.data.armatures[data["data"]]
|
pointer = bpy.data.armatures[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.grease_pencils.keys():
|
elif self.data["data"] in bpy.data.grease_pencils.keys():
|
||||||
# pointer = bpy.data.grease_pencils[data["data"]]
|
pointer = bpy.data.grease_pencils[self.data["data"]]
|
||||||
# elif data["data"] in bpy.data.curves.keys():
|
elif self.data["data"] in bpy.data.curves.keys():
|
||||||
# pointer = bpy.data.curves[data["data"]]
|
pointer = bpy.data.curves[self.data["data"]]
|
||||||
|
|
||||||
# self.pointer = bpy.data.objects.new(data["name"], pointer)
|
self.pointer = bpy.data.objects.new(self.data["name"], pointer)
|
||||||
|
|
||||||
# self.pointer.matrix_world = mathutils.Matrix(data["matrix_world"])
|
self.pointer.matrix_world = mathutils.Matrix(self.data["matrix_world"])
|
||||||
|
|
||||||
# self.pointer.id = data['id']
|
self.pointer.id = self.data['id']
|
||||||
|
|
||||||
# client = bpy.context.window_manager.session.username
|
client = bpy.context.window_manager.session.username
|
||||||
|
|
||||||
# if self.pointer.id == client or self.pointer.id == "Common":
|
if self.pointer.id == client or self.pointer.id == "Common":
|
||||||
# self.pointer.hide_select = False
|
self.pointer.hide_select = False
|
||||||
# else:
|
else:
|
||||||
# self.pointer.hide_select = True
|
self.pointer.hide_select = True
|
||||||
|
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# logger.error("Object {} loading error: {} ".format(data["name"], e))
|
logger.error("Object {} loading error: {} ".format(self.data["name"], e))
|
||||||
|
|
||||||
# def encode_data(self):
|
def deserialize(self):
|
||||||
# self.data = dump_datablock(self.pointer, 1)
|
self.data = dump_datablock(self.pointer, 1)
|
||||||
|
|
||||||
|
|
||||||
o = BpyObject("toto")
|
|
||||||
|
Reference in New Issue
Block a user