Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2012-02-12 23:32:24 +0400
committerMartin Poirier <theeth@yahoo.com>2012-02-12 23:32:24 +0400
commita6d7d6c040ff61c7b894cb374ded7c5d450290c2 (patch)
treeef6df78ba1c5b2bcaa1294faa11e6a23d62756c8 /netrender/repath.py
parenta4683ac1a4f0e3ff23573dff1c9d739e6d46ac69 (diff)
netrender
change to the repatching and local naming algorithms to better support different files with same name and dependency folder hierarchies.
Diffstat (limited to 'netrender/repath.py')
-rw-r--r--netrender/repath.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/netrender/repath.py b/netrender/repath.py
index af8f79d8..e06b17c5 100644
--- a/netrender/repath.py
+++ b/netrender/repath.py
@@ -21,6 +21,8 @@ import subprocess
import bpy
+DEBUG = False
+
from netrender.utils import *
BLENDER_PATH = sys.argv[0]
@@ -44,7 +46,9 @@ def update(job):
path, ext = os.path.splitext(job_full_path)
- new_path = path + ".remap" + ext
+ new_path = path + ".remap" + ext
+
+ original_path = main_file.original_path
# Disable for now. Partial repath should work anyway
#all = main_file.filepath != main_file.original_path
@@ -57,26 +61,33 @@ def update(job):
# Only update if needed
if paths:
- process = subprocess.Popen([BLENDER_PATH, "-b", "-noaudio", job_full_path, "-P", __file__, "--", new_path] + paths, stdout=sys.stdout, stderr=subprocess.STDOUT)
+ process = subprocess.Popen([BLENDER_PATH, "-b", "-noaudio", job_full_path, "-P", __file__, "--", new_path, original_path] + paths, stdout=sys.stdout, stderr=subprocess.STDOUT)
process.wait()
os.renames(job_full_path, job_full_path + ".bak")
os.renames(new_path, job_full_path)
-def process(paths):
+def process(original_path, paths):
+ if DEBUG: print("==========================================================")
+ original_directory = os.path.dirname(original_path)
path_map = {}
for i in range(0, len(paths), 2):
# special case for point cache
if paths[i].endswith(".bphys"):
path, filename = os.path.split(paths[i+1])
cache_name = filename.split("_")[0]
+ if DEBUG: print(cache_name, path)
path_map[cache_name] = path
# special case for fluids
elif paths[i].endswith(".bobj.gz"):
+ if DEBUG: print(os.path.split(paths[i])[0], os.path.split(paths[i+1])[0])
path_map[os.path.split(paths[i])[0]] = os.path.split(paths[i+1])[0]
else:
- path_map[os.path.split(paths[i])[1]] = paths[i+1]
+ if DEBUG: print(paths[i], paths[i+1])
+ path_map[paths[i]] = paths[i+1]
+ if DEBUG: print("----------------------------------------------------------")
+
# TODO original paths aren't really the original path, they are the normalized path
# so we repath using the filenames only.
@@ -84,8 +95,9 @@ def process(paths):
# LIBRARIES
###########################
for lib in bpy.data.libraries:
- file_path = bpy.path.abspath(lib.filepath)
- new_path = path_map.get(os.path.split(file_path)[1], None)
+ file_path = bpy.path.abspath(lib.filepath, start=original_directory)
+ new_path = path_map.get(file_path, None)
+ if DEBUG: print(file_path, new_path)
if new_path:
lib.filepath = new_path
@@ -94,8 +106,9 @@ def process(paths):
###########################
for image in bpy.data.images:
if image.source == "FILE" and not image.packed_file:
- file_path = bpy.path.abspath(image.filepath)
- new_path = path_map.get(os.path.split(file_path)[1], None)
+ file_path = bpy.path.abspath(image.filepath, start=original_directory)
+ new_path = path_map.get(file_path, None)
+ if DEBUG: print(file_path, new_path)
if new_path:
image.filepath = new_path
@@ -109,6 +122,7 @@ def process(paths):
cache_name = cacheName(object, point_cache)
new_path = path_map.get(cache_name, None)
+ if DEBUG: print(cache_name, new_path)
if new_path:
point_cache.use_external = True
point_cache.filepath = new_path
@@ -126,6 +140,7 @@ def process(paths):
modifier.filepath = new_path
processObjectDependencies(pointCacheFunc, fluidFunc, multiresFunc)
+ if DEBUG: print("==========================================================")
if __name__ == "__main__":
@@ -135,9 +150,8 @@ if __name__ == "__main__":
i = 0
if i:
- new_path = sys.argv[i+1]
- args = sys.argv[i+2:]
+ new_path, original_path, *args = sys.argv[i+1:]
- process(args)
+ process(original_path, args)
bpy.ops.wm.save_as_mainfile(filepath=new_path, check_existing=False)