This commit is contained in:
Swann 2019-02-07 17:34:28 +01:00
parent 3a3dd44a22
commit e61b4e18e8
No known key found for this signature in database
GPG Key ID: B02D0B41F8B6D2EE
8 changed files with 0 additions and 267 deletions

View File

@ -1,22 +0,0 @@
import sys
import os
thirdPartyDir = "C:\\Users\\slumber\\repos\\phd\src\\2019_rcf\\libs"
if thirdPartyDir not in sys.path:
print('Adding local modules dir to the path')
sys.path.insert(0, thirdPartyDir)
import umsgpack
import bpy
import esper
from rna_xml import rna2xml
try:
umsgpack.packb((getattr(bpy.data,'objects')))
except:
pass

View File

@ -1,20 +0,0 @@
import bpy
bl_info = {
"name": "Sprite preview",
"author": "Cube Animation",
"version": (1, 0),
"blender": (2, 80, 0),
"location": "Properties > Object > Sprite Components",
"description": "Manage sprite components in blender",
"warning": "",
"wiki_url": "",
"category": "Cube Animation",
}
def register():
pass
def unregister():
pass

View File

@ -1,66 +0,0 @@
#!/usr/bin/env python3
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contributor(s): Campbell Barton
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
# This script dumps rna into xml.
# useful for finding bugs in RNA api.
# Example usage
# blender some.blend --background -noaudio --python intern/tools/dump_rna2xml.py
import os
import bpy
import rna_xml
def main():
filename = os.path.splitext(bpy.data.filepath)[0] + ".xml"
file = open(filename, 'w')
if 1:
# blend file
rna_xml.rna2xml(file.write,
root_rna=bpy.data,
root_rna_skip={"window_managers"})
else:
# theme. just another test
rna_xml.rna2xml(file.write,
root_rna=bpy.context.user_preferences.themes[0],
method='ATTR')
file.close()
# read back to ensure this is valid!
from xml.dom.minidom import parse
xml_nodes = parse(filename)
print("Written:", filename)
# test reading back theme
if 1:
theme = xml_nodes.getElementsByTagName("Theme")[0]
rna_xml.xml2rna(theme,
root_rna=bpy.context.user_preferences.themes[0],)
if __name__ == "__main__":
main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

53
main.py
View File

@ -1,53 +0,0 @@
import net_systems
import replication_system
import net_components
from libs.esper import esper
import zmq
import sys
import argparse
import time
# TODO: Implement a manager class for each aspect (ex: Network_Manager)
# TODO: Is it right to implement server-client as ESC ?...
def main():
# Argument parsing
parser = argparse.ArgumentParser(
description='Launch an instance of collaboration system')
parser.add_argument('-r', choices=list(net_components.Role),
type=net_components.Role, help='role for the instance ')
args = parser.parse_args()
instance_role = args.r
instance_context = zmq.Context()
print("Starting a {} instance \n".format(instance_role))
# Create a World instance to hold everything:
world = esper.World()
# Instantiate a Processor (or more), and add them to the world:
world.add_processor(net_systems.SessionSystem())
world.add_processor(replication_system.ReplicationSystem())
# Instanciate a session entity
session = world.create_entity()
world.add_component(
session, net_components.NetworkInterface(context=instance_context))
world.add_component(
session, net_components.User(role=instance_role))
# A dummy main loop:
try:
while True:
# Call world.process() to run all Processors.
world.process()
time.sleep(1)
except KeyboardInterrupt:
return
if __name__ == '__main__':
main()

View File

@ -1,43 +0,0 @@
import zmq
# from zmq.asyncio import Context, ZMQEventLoop
# import asyncio
from enum import Enum, auto
class Role(Enum):
NONE = 'NONE'
SERVER = 'SERVER'
CLIENT = 'CLIENT'
def __str__(self):
return self.value
class Replication(Enum):
NONE = auto()
REPLICATED = auto()
REPNOTIFY = auto()
class User:
def __init__(self, name="default", ip="localhost",role=Role.NONE):
self.name = name
self.role = role
class NetworkInterface:
def __init__(self, host="*",context=None, socket_type=zmq.REP,protocol='tcp',port=5555):
self.host = host
self.context = context
self.socket = context.socket(socket_type)
#TODO: Is this right to it here?
print("{}://{}:{}".format(protocol,host,port))
self.socket.bind("tcp://*:5555")
class Property:
def __init__(self, property=None, replication=Replication.NONE):
self.property = property
self.replication = replication
class Function:
def __init__(self, function=None):
self.function = function

View File

@ -1,45 +0,0 @@
import time
import asyncio
import zmq
import zmq.asyncio
import net_components
from libs.esper import esper
class SessionSystem(esper.Processor):
"""
Handle Client-Server session managment
"""
def __init__(self):
super().__init__()
# Initialize poll set
# TODO: Use zmq_poll..
def process(self):
# This will iterate over every Entity that has BOTH of these components:
for ent, (net_interface, user) in self.world.get_components(net_components.NetworkInterface,net_components.User):
if user.role is net_components.Role.SERVER:
print("Server loops")
try:
message = net_interface.socket.recv()
print("test")
except KeyboardInterrupt:
break
print("test")
if user.role is net_components.Role.CLIENT:
# Send reply back to client
socket.send(b"Hello")
@asyncio.coroutine
def recv_and_process():
sock = ctx.socket(zmq.PULL)
sock.bind(url)
msg = yield from sock.recv_multipart() # waits for msg to be ready
reply = yield from async_process(msg)
yield from sock.send_multipart(reply)

View File

@ -1,18 +0,0 @@
import zmq
from libs.esper import esper
class ReplicationSystem(esper.Processor):
"""
Handle Client-Server session managment
"""
def __init__(self):
super().__init__()
# Initialize poll set
# TODO: Use zmq_poll..
async def process(self):
# This will iterate over every Entity that has BOTH of these components:
print("test")