Skip to content

Commit b0d8603

Browse files
committed
more chuggin' along
1 parent 8714a78 commit b0d8603

5 files changed

Lines changed: 38 additions & 20 deletions

File tree

‎v3/generate_json_trace.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,23 @@ def js_var_finalizer(input_code, output_trace):
3535
help='JSON list of strings for simulated raw_input.', dest='raw_input_lst_json')
3636
parser.add_option("--create_jsvar", dest="js_varname", default=None,
3737
help="Create a JavaScript variable out of the trace")
38+
parser.add_option("--code", dest="usercode", default=None,
39+
help="Load user code from a string instead of a file and output compact JSON")
3840

3941
(options, args) = parser.parse_args()
4042
INDENT_LEVEL = None if options.compact else 2
4143

42-
fin = sys.stdin if args[0] == "-" else open(args[0])
43-
44-
if options.js_varname:
45-
JS_VARNAME = options.js_varname
46-
print(pg_logger.exec_script_str_local(fin.read(), options.raw_input_lst_json, options.cumulative, options.heapPrimitives, js_var_finalizer))
44+
if options.usercode:
45+
INDENT_LEVEL = None
46+
print(pg_logger.exec_script_str_local(options.usercode,
47+
options.raw_input_lst_json,
48+
options.cumulative,
49+
options.heapPrimitives,
50+
json_finalizer))
4751
else:
48-
print(pg_logger.exec_script_str_local(fin.read(), options.raw_input_lst_json, options.cumulative, options.heapPrimitives, json_finalizer))
52+
fin = sys.stdin if args[0] == "-" else open(args[0])
53+
if options.js_varname:
54+
JS_VARNAME = options.js_varname
55+
print(pg_logger.exec_script_str_local(fin.read(), options.raw_input_lst_json, options.cumulative, options.heapPrimitives, js_var_finalizer))
56+
else:
57+
print(pg_logger.exec_script_str_local(fin.read(), options.raw_input_lst_json, options.cumulative, options.heapPrimitives, json_finalizer))

‎v4-cokapi/cokapi.js‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,32 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2929
// This is a nodejs server based on express that serves the v4-cokapi/ app
3030
// To test locally, run 'make' and load http://localhost:3000/
3131

32+
// VERY IMPORTANT - turn on the sandbox when deploying online, or else
33+
// you'll be executing untrusted code on your server!
34+
var USE_DOCKER_SANDBOX = false;
35+
3236
var express = require('express');
3337
var serveStatic = require('serve-static');
3438
var app = express();
3539

40+
function assert(cond) {
41+
if (!cond) {
42+
var stack = new Error().stack;
43+
console.error('Assertion error');
44+
console.error(stack);
45+
throw 'Assertion Failure';
46+
}
47+
}
48+
3649
app.use(serveStatic('static/')); // put all static files in here
3750

38-
//app.get('/', function(req, res) {
39-
// res.send('Hello World!');
40-
//});
51+
app.get('/exec_py2', function(req, res) {
52+
if (USE_DOCKER_SANDBOX) {
53+
assert(false);
54+
} else {
55+
res.send('Hello World!');
56+
}
57+
});
4158

4259
var server = app.listen(3000, function() {
4360
var host = server.address().address;

‎v4-cokapi/static/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
<script type="text/javascript" src="js/ace/src-min-noconflict/ace.js" charset="utf-8"></script>
5656

5757
<script type="text/javascript" src="js/opt-frontend-common.js"></script>
58-
<script type="text/javascript" src="js/cokapi.js"></script>
58+
<script type="text/javascript" src="js/cokapi-frontend.js"></script>
5959
<link rel="stylesheet" href="css/opt-frontend.css"/>
6060

61-
<!-- include this AFTER cokapi.js so that configuration
61+
<!-- include this AFTER cokapi-frontend.js so that configuration
6262
global variables are already defined at load time -->
6363
<!--
6464
<script type="text/javascript" src="js/togetherjs/togetherjs-min.js"></script>

‎v4-cokapi/static/js/opt-frontend-common.js‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -673,15 +673,7 @@ function executeUserCode(sourceCode,
673673
frontendOptionsObj.startingInstruction = 0;
674674
}
675675

676-
if (frontendOptionsObj.holisticMode) {
677-
// do NOT override, or else bad things will happen with
678-
// jsPlumb arrows interfering ...
679-
delete frontendOptionsObj.visualizerIdOverride;
680-
681-
myVisualizer = new HolisticVisualizer(outputDiv, dataFromBackend, frontendOptionsObj);
682-
} else {
683-
myVisualizer = new ExecutionVisualizer(outputDiv, dataFromBackend, frontendOptionsObj);
684-
}
676+
myVisualizer = new ExecutionVisualizer(outputDiv, dataFromBackend, frontendOptionsObj);
685677
// SUPER HACK -- slip in backendOptionsObj as an extra field
686678
myVisualizer.backendOptionsObj = backendOptionsObj;
687679

0 commit comments

Comments
 (0)