diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-03-15 17:36:40 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-03-15 18:00:01 +0300 |
commit | c5dba540d73ec664ac3bfff02f73413906d66273 (patch) | |
tree | d3e49c579db4a95bf54beaa380de31f7a517336c /intern/cycles/blender | |
parent | 81dc8dd42aa6add0efe9d2e9e9912603ccdebd70 (diff) |
Cycles: Use argument parser for resumable render feature
Currently there is no functional changes, but we will be adding
couple more of options here soon.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index c8c9ef58c52..c9ee827aeeb 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -50,6 +50,18 @@ def _workaround_buggy_drivers(): _cycles.opencl_disable() +def _configure_argument_parser(): + import argparse + parser = argparse.ArgumentParser(description="Cycles Addon argument parser") + parser.add_argument("--cycles-resumable-num-chunks", + help="Number of chunks to split sample range into", + default=None) + parser.add_argument("--cycles-resumable-current-chunk", + help="Current chunk of samples range to render", + default=None) + return parser + + def _parse_command_line(): import sys @@ -57,25 +69,15 @@ def _parse_command_line(): if "--" not in argv: return - argv = argv[argv.index("--") + 1:] - - num_resumable_chunks = None - current_resumable_chunk = None - - # TODO(sergey): Add some nice error prints if argument is not used properly. - idx = 0 - while idx < len(argv) - 1: - arg = argv[idx] - if arg == '--cycles-resumable-num-chunks': - num_resumable_chunks = int(argv[idx + 1]) - elif arg == '--cycles-resumable-current-chunk': - current_resumable_chunk = int(argv[idx + 1]) - idx += 1 + parser = _configure_argument_parser() + args, unknown = parser.parse_known_args(argv[argv.index("--") + 1:]) - if num_resumable_chunks is not None and current_resumable_chunk is not None: + if args.cycles_resumable_num_chunks is not None and \ + args.cycles_resumable_current_chunk is not None: import _cycles - _cycles.set_resumable_chunks(num_resumable_chunks, - current_resumable_chunk) + _cycles.set_resumable_chunks( + int(args.cycles_resumable_num_chunks), + int(args.cycles_resumable_current_chunk)) def init(): |