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-03-26 06:42:59 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-26 06:42:59 +0300
commit04e32be958bb90be2824c083eba8f983d9133f76 (patch)
treec65d6c5373966888d4210bcc3830373048d623cb /release/scripts
parentbc88e61efa3fdf9b0f2dc2d3790567d0c2c26a82 (diff)
optparse module is deprecated, use new argparse module in background job template.
correction to example in doc too.
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/templates/background_job.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/release/scripts/templates/background_job.py b/release/scripts/templates/background_job.py
index 0337f8f4922..90ddba8a91d 100644
--- a/release/scripts/templates/background_job.py
+++ b/release/scripts/templates/background_job.py
@@ -66,7 +66,7 @@ def example_function(body_text, save_path, render_path):
import sys # to get command line args
-import optparse # to parse options for us and print a nice help message
+import argparse # to parse options for us and print a nice help message
def main():
@@ -84,16 +84,18 @@ def main():
usage_text = "Run blender in background mode with this script:"
usage_text += " blender --background --python " + __file__ + " -- [options]"
- parser = optparse.OptionParser(usage=usage_text)
+ print(usage_text)
+
+ parser = argparse.ArgumentParser(description=usage_text)
# Example background utility, add some text and renders or saves it (with options)
# Possible types are: string, int, long, choice, float and complex.
- parser.add_option("-t", "--text", dest="body_text", help="This text will be used to render an image", type="string")
+ parser.add_argument("-t", "--text", dest="body_text", help="This text will be used to render an image", type=str, required=True)
- parser.add_option("-s", "--save", dest="save_path", help="Save the generated file to the specified path", metavar='FILE')
- parser.add_option("-r", "--render", dest="render_path", help="Render an image to the specified path", metavar='FILE')
+ 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')
- options, args = parser.parse_args(argv) # In this example we wont use the args
+ options = parser.parse_args(argv) # In this example we wont use the args
if not argv:
parser.print_help()