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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-10 19:24:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-10 19:24:05 +0400
commitdbd300910815692294e8919b6ea21e934731d2c8 (patch)
tree3ee917259147fc4d5fdd5140f7fd48ce85683de0
parent1c11e40cb7ed708228b70284a62be34916ec1b4d (diff)
- background job style cleanup.
- assert if material assignment is called with lib. (so the callers can be corrected). - correct example docs
-rw-r--r--GNUmakefile2
-rw-r--r--doc/python_api/examples/bpy.props.2.py4
-rw-r--r--release/scripts/templates/background_job.py62
-rw-r--r--source/blender/blenkernel/intern/material.c1
4 files changed, 39 insertions, 30 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 73d5c267705..008dfe77eae 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -106,7 +106,7 @@ test_pep8:
# run some checks on our cmakefiles.
test_cmake:
python build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
- @echo "written: test_cmake_consistency.txt"
+ @echo "written: test_cmake_consistency.log"
clean:
cd $(BUILD_DIR) ; make clean
diff --git a/doc/python_api/examples/bpy.props.2.py b/doc/python_api/examples/bpy.props.2.py
index e27e6227ba3..22fef5dc13a 100644
--- a/doc/python_api/examples/bpy.props.2.py
+++ b/doc/python_api/examples/bpy.props.2.py
@@ -22,6 +22,6 @@ bpy.types.Material.my_settings = \
# test the new settings work
material = bpy.data.materials[0]
-material.my_settings.val_int = 5
-material.my_settings.val_float = 3.0
+material.my_settings.my_int = 5
+material.my_settings.my_float = 3.0
material.my_settings.my_string = "Foo"
diff --git a/release/scripts/templates/background_job.py b/release/scripts/templates/background_job.py
index 5cc2e04db0b..11b51e5a9b5 100644
--- a/release/scripts/templates/background_job.py
+++ b/release/scripts/templates/background_job.py
@@ -1,12 +1,18 @@
-# This script is an example of how you can run blender from the command line (in background mode with no interface)
-# to automate tasks, in this example it creates a text object, camera and light, then renders and/or saves it.
-# This example also shows how you can parse command line options to python scripts.
+# This script is an example of how you can run blender from the command line
+# (in background mode with no interface) to automate tasks, in this example it
+# creates a text object, camera and light, then renders and/or saves it.
+# This example also shows how you can parse command line options to scripts.
#
# Example usage for this test.
-# blender --background --factory-startup --python $HOME/background_job.py -- --text="Hello World" --render="/tmp/hello" --save="/tmp/hello.blend"
+# blender --background --factory-startup --python $HOME/background_job.py -- \
+# --text="Hello World" \
+# --render="/tmp/hello" \
+# --save="/tmp/hello.blend"
#
# Notice:
-# '--factory-startup' is used to avoid the user default settings from interfearing with automated scene generation.
+# '--factory-startup' is used to avoid the user default settings from
+# interfearing with automated scene generation.
+#
# '--' causes blender to ignore all following arguments so python can use them.
#
# See blender --help for details.
@@ -14,7 +20,7 @@
import bpy
-def example_function(body_text, save_path, render_path):
+def example_function(text, save_path, render_path):
scene = bpy.context.scene
@@ -27,15 +33,15 @@ def example_function(body_text, save_path, render_path):
# Text Object
txt_ob = bpy.data.objects.new(name="MyText", object_data=txt_data)
- scene.objects.link(txt_ob) # add the data to the scene as an object
- txt_data.body = body_text # set the body text to the command line arg given
- txt_data.align = 'CENTER' # center text
+ scene.objects.link(txt_ob) # add the data to the scene as an object
+ txt_data.body = text # the body text to the command line arg given
+ txt_data.align = 'CENTER' # center text
# Camera
- cam_data = bpy.data.cameras.new("MyCam") # create new camera data
+ cam_data = bpy.data.cameras.new("MyCam")
cam_ob = bpy.data.objects.new(name="MyCam", object_data=cam_data)
- scene.objects.link(cam_ob) # add the camera data to the scene (creating a new object)
- scene.camera = cam_ob # set the active camera
+ scene.objects.link(cam_ob) # instance the camera object in the scene
+ scene.camera = cam_ob # set the active camera
cam_ob.location = 0.0, 0.0, 10.0
# Lamp
@@ -65,14 +71,12 @@ def example_function(body_text, save_path, render_path):
bpy.ops.render.render(write_still=True)
-import sys # to get command line args
-import argparse # to parse options for us and print a nice help message
-
-
def main():
+ import sys # to get command line args
+ import argparse # to parse options for us and print a nice help message
- # get the args passed to blender after "--", all of which are ignored by blender specifically
- # so python may receive its own arguments
+ # get the args passed to blender after "--", all of which are ignored by
+ # blender so scripts may receive their own arguments
argv = sys.argv
if "--" not in argv:
@@ -81,31 +85,35 @@ def main():
argv = argv[argv.index("--") + 1:] # get all args after "--"
# When --help or no args are given, print this help
- usage_text = "Run blender in background mode with this script:"
- usage_text += " blender --background --python " + __file__ + " -- [options]"
+ usage_text = \
+ "Run blender in background mode with this script:"
+ " blender --background --python " + __file__ + " -- [options]"
parser = argparse.ArgumentParser(description=usage_text)
- # Example background utility, add some text and renders or saves it (with options)
+ # Example utility, add some text and renders or saves it (with options)
# Possible types are: string, int, long, choice, float and complex.
- parser.add_argument("-t", "--text", dest="body_text", help="This text will be used to render an image", type=str, required=True)
+ parser.add_argument("-t", "--text", dest="text", type=str, required=True,
+ help="This text will be used to render an image")
- parser.add_argument("-s", "--save", dest="save_path", help="Save the generated file to the specified path", metavar='FILE')
- parser.add_argument("-r", "--render", dest="render_path", help="Render an image to the specified path", metavar='FILE')
+ parser.add_argument("-s", "--save", dest="save_path", metavar='FILE',
+ help="Save the generated file to the specified path")
+ parser.add_argument("-r", "--render", dest="render_path", metavar='FILE',
+ help="Render an image to the specified path")
- options = parser.parse_args(argv) # In this example we wont use the args
+ args = parser.parse_args(argv) # In this example we wont use the args
if not argv:
parser.print_help()
return
- if not options.body_text:
+ if not args.text:
print("Error: --text=\"some string\" argument not given, aborting.")
parser.print_help()
return
# Run the example function
- example_function(options.body_text, options.save_path, options.render_path)
+ example_function(args.text, args.save_path, args.render_path)
print("batch job finished, exiting")
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index daa665f7183..36e386aeabe 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -688,6 +688,7 @@ void assign_material(Object *ob, Material *ma, int act)
if(act<1) act= 1;
/* prevent crashing when using accidentally */
+ BLI_assert(ob->id.lib != NULL);
if(ob->id.lib) return;
/* test arraylens */