diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-12-02 14:14:15 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-12-03 14:40:49 -0600 |
commit | e7e435342af45576db6b4b7ab6117fe31c052262 (patch) | |
tree | 068ca3ca4afecd3fefe2cc7cdf35f8c5d6f69b58 | |
parent | c31a5010669851768f3dbc5167c60c7d6a8ff93f (diff) | |
download | mediagoblin-e7e435342af45576db6b4b7ab6117fe31c052262.tar.lz mediagoblin-e7e435342af45576db6b4b7ab6117fe31c052262.tar.xz mediagoblin-e7e435342af45576db6b4b7ab6117fe31c052262.zip |
Switch stl processing over to using the workbench
Previously this was writing directly to the public store... that won't
work with cloudfiles backend, for example :)
-rw-r--r-- | mediagoblin/media_types/stl/processing.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/mediagoblin/media_types/stl/processing.py b/mediagoblin/media_types/stl/processing.py index 2f7e2cfd..cd949e2a 100644 --- a/mediagoblin/media_types/stl/processing.py +++ b/mediagoblin/media_types/stl/processing.py @@ -79,7 +79,6 @@ def process_stl(entry): """ Code to process an stl or obj model. """ - workbench = mgg.workbench_manager.create_workbench() queued_filepath = entry.queued_media_file queued_filename = workbench.localized_file( @@ -103,8 +102,8 @@ def process_stl(entry): greatest = greatest[-1] def snap(name, camera, width=640, height=640, project="ORTHO"): - path = create_pub_filepath(entry, name_builder.fill(name)) - render_file = mgg.public_store.get_file(path, "wb") + filename = name_builder.fill(name) + workbench_path = workbench.joinpath(filename) shot = { "model_path": queued_filename, "model_ext": ext, @@ -115,11 +114,21 @@ def process_stl(entry): "projection": project, "width": width, "height": height, - "out_file": render_file.name, + "out_file": workbench_path, } - render_file.close() blender_render(shot) - return path + + # make sure the image rendered to the workbench path + assert os.path.exists(workbench_path) + + # copy it up! + with open(workbench_path, 'rb') as rendered_file: + public_path = create_pub_filepath(entry, filename) + + with mgg.public_store.get_file(public_path, "wb") as public_file: + public_file.write(rendered_file.read()) + + return public_path thumb_path = snap( "{basename}.thumb.jpg", @@ -144,10 +153,7 @@ def process_stl(entry): "{basename}.side.jpg", [greatest*-2, model.average[1], model.average[2]]) - - - - # Save the public file stuffs + ## Save the public file stuffs model_filepath = create_pub_filepath( entry, name_builder.fill('{basename}{ext}')) @@ -155,7 +161,6 @@ def process_stl(entry): with open(queued_filename, 'rb') as queued_file: model_file.write(queued_file.read()) - # Remove queued media file from storage and database mgg.queue_store.delete_file(queued_filepath) entry.queued_media_file = [] |