Moving blender render files to be accessed via pkg_resources

Previously the .blend and .py files had to be in the same directory
mediagoblin/celery launched from.  This is now fixed so it pulls them
out of the package proper.
This commit is contained in:
Christopher Allan Webber 2012-12-01 20:16:15 -06:00
parent 8bef424f24
commit 39c340f280
3 changed files with 28 additions and 11 deletions

View File

@ -18,6 +18,7 @@ import os
import json
import logging
import subprocess
import pkg_resources
from mediagoblin import mg_globals as mgg
from mediagoblin.processing import create_pub_filepath, \
@ -29,6 +30,17 @@ from mediagoblin.media_types.stl import model_loader
_log = logging.getLogger(__name__)
SUPPORTED_FILETYPES = ['stl', 'obj']
BLEND_FILE = pkg_resources.resource_filename(
'mediagoblin.media_types.stl',
os.path.join(
'assets',
'blender_render.blend'))
BLEND_SCRIPT = pkg_resources.resource_filename(
'mediagoblin.media_types.stl',
os.path.join(
'assets',
'blender_render.py'))
def sniff_handler(media_file, **kw):
if kw.get('media') is not None:
@ -55,7 +67,12 @@ def blender_render(config):
arg_string = "blender -b blender_render.blend -F "
arg_string +="JPEG -P blender_render.py"
env = {"RENDER_SETUP" : json.dumps(config), "DISPLAY":":0"}
subprocess.call(arg_string.split(" "), env=env)
subprocess.call(
["blender",
"-b", BLEND_FILE,
"-F", "JPEG",
"-P", BLEND_SCRIPT],
env=env)
def process_stl(entry):