Skip to content

Commit

Permalink
Merge pull request #6 from OpenframeProject/tmp-folder
Browse files Browse the repository at this point in the history
download to /tmp/ and non extra arguments
  • Loading branch information
jmwohl committed Jul 11, 2016
2 parents 21cf840 + 2951011 commit f8dac47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
15 changes: 9 additions & 6 deletions bin/glslLoader
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import sys, urllib, os, re

COMMAND='glslViewer'
SHADER_PATH = '';
SHADER_PATH = ''

TMP_DIR = '/tmp/'
TMP_SHD = TMP_DIR + 'shader.frag'

if len(sys.argv) > 1:
SHADER_PATH = sys.argv[1]
Expand All @@ -16,8 +19,8 @@ if SHADER_PATH.isdigit():

if SHADER_PATH.startswith('http'):
http = urllib.URLopener()
http.retrieve(SHADER_PATH, 'shader.frag')
SHADER_PATH='shader.frag'
http.retrieve(SHADER_PATH, TMP_SHD)
SHADER_PATH=TMP_SHD

COMMAND += ' ' + SHADER_PATH
counter=0
Expand All @@ -28,11 +31,11 @@ with open(SHADER_PATH) as f:
uniform = result.group(1)
url = result.group(2)
ext = os.path.splitext(url)[1]
img = str(counter) + ext
img_path = TMP_DIR + str(counter) + ext
print counter,uniform,url,ext
http = urllib.URLopener()
http.retrieve(url, img)
COMMAND += ' -' + uniform + ' ' + img
http.retrieve(url, img_path)
COMMAND += ' -' + uniform + ' ' + img_path
counter += 1

print COMMAND
Expand Down
15 changes: 1 addition & 14 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var pjson = require('./package.json'),
debug = require('debug')('openframe:glslviewer'),
Extension = require('openframe-extension');

/**
Expand All @@ -17,19 +16,7 @@ module.exports = new Extension({
// does this type of artwork need to be downloaded to the frame?
'download': false,
// how do start this type of artwork? currently two token replacements, $filepath and $url
'start_command': function(_config) {
debug('Artwork config: ', _config);
var config = _config || {},
command = 'glslLoader';
if (config.w) {
command += ' -w ' + config.w;
}
if (config.h) {
command += ' -h ' + config.h;
}
command += ' $url';
return command;
},
'start_command': 'glslLoader $url',
// how do we stop this type of artwork?
'end_command': 'pkill glslViewer'
}
Expand Down
11 changes: 3 additions & 8 deletions test/extension.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ describe('properties', function() {
assert(typeof format.end_command === 'string');
});

it('should use w and h properties to set -w and -h flags in start_command', function() {
it('should use glslLoader as start command', function() {
var format = GlslExtension.props.format,
config = {
w: 1000,
h: 1000
},
command = format.start_command(config);
command = format.start_command;

assert(typeof command === 'string');
assert(command.indexOf('-w 1000') !== -1);
assert(command.indexOf('-h 1000') !== -1);
assert(command === 'glslLoader $url');
});
});

0 comments on commit f8dac47

Please sign in to comment.