git @ Cat's Eye Technologies kinoje / e50bc7a
exe argument is optional, defaults to generic Executor. Chris Pressey 4 years ago
4 changed file(s) with 15 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
11 import os
22 import sys
33
4 from kinoje.utils import LoggingExecutor, load_config_file
4 from kinoje.utils import Executor, LoggingExecutor, load_config_file
55
66
77 SUPPORTED_OUTPUT_FORMATS = ('.m4v', '.mp4', '.gif')
88
99
1010 class Compiler(object):
11 def __init__(self, config, dirname, outfilename, exe):
11 def __init__(self, config, dirname, outfilename, exe=None):
1212 self.dirname = dirname
13 self.exe = exe
13 self.exe = exe or Executor()
1414 self.outfilename = outfilename
1515 self.config = config
1616 self.frame_fmt = "%08d.png"
104104
105105 exe = LoggingExecutor('compiler.log')
106106
107 compiler = Compiler.get_class_for(options.output)(config, options.framesdir, options.output, exe)
107 compiler = Compiler.get_class_for(options.output)(config, options.framesdir, options.output, exe=exe)
108108 compiler.compile_all()
109109
110110 if options.view:
55
66 from jinja2 import Template
77
8 from kinoje.utils import LoggingExecutor, fmod, tween, load_config_file
8 from kinoje.utils import Executor, LoggingExecutor, fmod, tween, load_config_file
99
1010
1111 class Expander(object):
1212 """Takes a directory and a template (Jinja2) and expands the template a number of times,
1313 creating a number of filled-out text files in the directory."""
14 def __init__(self, config, dirname, exe):
14 def __init__(self, config, dirname, exe=None):
1515 self.dirname = dirname
1616 self.template = Template(config['template'])
1717 self.config = config
18 self.exe = exe
18 self.exe = exe or Executor()
1919
2020 self.fun_context = {}
2121 for key, value in self.config.get('functions', {}).iteritems():
6060
6161 exe = LoggingExecutor('movie.log')
6262
63 expander = Expander(config, options.instantsdir, exe)
63 expander = Expander(config, options.instantsdir, exe=exe)
6464 expander.expand_all()
6565
6666 exe.close()
4747 instants_dir = mkdtemp()
4848 frames_dir = mkdtemp()
4949
50 expander = Expander(config, instants_dir, exe)
50 expander = Expander(config, instants_dir, exe=exe)
5151 expander.expand_all()
5252
53 renderer = Renderer(config, instants_dir, frames_dir, exe)
53 renderer = Renderer(config, instants_dir, frames_dir, exe=exe)
5454 renderer.render_all()
5555
56 compiler = Compiler.get_class_for(output_filename)(config, frames_dir, output_filename, exe)
56 compiler = Compiler.get_class_for(output_filename)(config, frames_dir, output_filename, exe=exe)
5757 compiler.compile_all()
5858
5959 exe.close()
88 except ImportError:
99 from yaml import Loader
1010
11 from kinoje.utils import LoggingExecutor, load_config_file
11 from kinoje.utils import Executor, LoggingExecutor, load_config_file
1212
1313
1414 class Renderer(object):
1515 """Takes a source directory filled with text files and a destination directory and
1616 creates one image file in the destination directory from each text file in the source."""
17 def __init__(self, config, src, dest, exe):
17 def __init__(self, config, src, dest, exe=None):
1818 self.command = config['command']
1919 self.libdir = config['libdir']
2020 self.src = src
2121 self.dest = dest
22 self.exe = exe
22 self.exe = exe or Executor()
2323 self.width = config['width']
2424 self.height = config['height']
2525
6262
6363 exe = LoggingExecutor('renderer.log')
6464
65 renderer = Renderer(config, options.instantsdir, options.framesdir, exe)
65 renderer = Renderer(config, options.instantsdir, options.framesdir, exe=exe)
6666 renderer.render_all()
6767
6868 exe.close()