[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30094] branches/soc-2010-leifandersen/ tests/render/run.py: 1.
Leif Andersen
leif.a.andersen at gmail.com
Wed Jul 7 21:35:39 CEST 2010
Revision: 30094
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30094
Author: leifandersen
Date: 2010-07-07 21:35:39 +0200 (Wed, 07 Jul 2010)
Log Message:
-----------
1. The -v (vorbose) flag actually works, making the output look much nicer.
Modified Paths:
--------------
branches/soc-2010-leifandersen/tests/render/run.py
Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py 2010-07-07 19:11:55 UTC (rev 30093)
+++ branches/soc-2010-leifandersen/tests/render/run.py 2010-07-07 19:35:39 UTC (rev 30094)
@@ -5,7 +5,11 @@
import os
import sys
import string
+import subprocess
+from subprocess import Popen, PIPE
+
+
BLENDER_BIN = "blender"
RUN_ANIMATIONS = False
RUN_IMAGES = True
@@ -56,8 +60,16 @@
def render_test(self):
'''Renders a single image of the first frame of the blend file.
Also changes output_path slightly'''
- command = BLENDER_BIN + " -b " + self.blend_path + " -o " + self.test_path + "_#### -F PNG -x 1 -f 1"
- os.system(command)
+
+ # The old way of running the command: TODO, remove when certain Popen() works.
+ # command = BLENDER_BIN + " -b " + self.blend_path + " -o " + self.test_path + "_#### -F PNG -x 1 -f 1"
+ # os.system(command)
+
+ p = Popen([BLENDER_BIN, '-b', self.blend_path, '-o', self.test_path + '_####', '-F', 'PNG', '-x', '1', '-f', '1'], stdout=PIPE, stderr=PIPE, stdin=PIPE)
+ p.wait()
+ if VERBOSE:
+ print p.communicate()[0]
+
self.test_path += '_0001.png'
try:
self.test_image = Image.open(self.test_path)
@@ -120,6 +132,7 @@
message = ""
def __init__(self, blend_path, good_path, test_path):
+ ''''''
self.name = os.path.split(blend_path)[1]
self.blend_path = blend_path
self.good_path = []
@@ -144,9 +157,15 @@
def render_test(self):
''''''
- command = BLENDER_BIN + " -b " + self.blend_path + " -o " + string.replace(self.test_path[0], '_0001.png', '') + "_#### -F PNG -x 1 -a"
- os.system(command)
+ # The old way, TODO, remove when certain Popen() works.
+ # command = BLENDER_BIN + " -b " + self.blend_path + " -o " + string.replace(self.test_path[0], '_0001.png', '') + "_#### -F PNG -x 1 -a"
+ # os.system(command)
+ p = Popen([BLENDER_BIN, '-b', self.blend_path, '-o', string.replace(self.test_path[0], '_0001.png', '') + '_####', '-F', 'PNG', '-x', '1', '-a'], stdout=PIPE, stderr=PIPE, stdin=PIPE)
+ p.wait()
+ if VERBOSE:
+ print p.communicate()[0]
+
try:
self.test_image = []
for imagename in self.test_path:
@@ -163,6 +182,7 @@
self.message = "Failed to render"
def setup_test(self):
+ ''''''
if self.test_image != None:
self.passed_arr = []
self.diff_sum = []
@@ -204,6 +224,7 @@
self.passed = False
def save_diff(self, output_path):
+ ''''''
if self.diff_image != None:
self.diff_path = []
(diff_directory, diff_file) = os.path.split(output_path)
@@ -216,6 +237,7 @@
def get_cases(folder):
'''Returns all of the blend files in the folder'''
cases = []
+ print ''
for filename in os.listdir(sys.path[0]):
if filename.find('.blend') != -1:
blend_path = os.path.join(sys.path[0],filename)
@@ -362,15 +384,14 @@
# Run cases
for test_case in cases:
- print test_case.name
- if not VERBOSE:
- sys.stdout = LOG
+ print test_case.name + '...',
test_case.render_test()
test_case.setup_test()
test_case.save_diff(os.path.join(HTML_OUTPUT, 'output', string.replace(test_case.name, '.blend', '_diff.png')))
- if not VERBOSE:
- sys.stdout = SAVEOUT
- print test_case.passed
+ if test_case.passed:
+ print 'OK'
+ else:
+ print 'FAILED'
# Output Result
console_output(cases)
More information about the Bf-blender-cvs
mailing list