Files
test2/release/io/netrender/utils.py
Martin Poirier 22274d3807 More automatic stuff.
Server can now be set to broadcast on local network (every 10s, approximately 20 bytes of data) where client and slave can pick up its existence. This is on by default.

Default ip address is now "[default]", which means for the master that it will listen to all interface and for the clients and slave that they will automatically work out the master's address from its broadcast.
2009-09-15 19:53:18 +00:00

72 lines
1.6 KiB
Python

import bpy
import sys, os
import re
import http, http.client, http.server, urllib
import subprocess, shutil, time, hashlib
import netrender.model
VERSION = b"0.5"
QUEUED = 0
DISPATCHED = 1
DONE = 2
ERROR = 3
def rnaType(rna_type):
bpy.types.register(rna_type)
return rna_type
def rnaOperator(rna_op):
bpy.ops.add(rna_op)
return rna_op
def clientConnection(scene):
netsettings = scene.network_render
if netsettings.server_address == "[default]":
bpy.ops.render.netclientscan()
conn = http.client.HTTPConnection(netsettings.server_address, netsettings.server_port)
if clientVerifyVersion(conn):
return conn
else:
conn.close()
return None
def clientVerifyVersion(conn):
conn.request("GET", "version")
response = conn.getresponse()
if response.status != http.client.OK:
conn.close()
return False
server_version = response.read()
if server_version != VERSION:
print("Incorrect server version!")
print("expected", VERSION, "received", server_version)
return False
return True
def prefixPath(prefix_directory, file_path, prefix_path):
if os.path.isabs(file_path):
# if an absolute path, make sure path exists, if it doesn't, use relative local path
full_path = file_path
if not os.path.exists(full_path):
p, n = os.path.split(full_path)
if main_path and p.startswith(main_path):
directory = prefix_directory + p[len(main_path):]
full_path = directory + n
if not os.path.exists(directory):
os.mkdir(directory)
else:
full_path = prefix_directory + n
else:
full_path = prefix_directory + file_path
return full_path