From e894b2919c54a1cf577ec170cd9e6d99bedc6da9 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Thu, 4 Sep 2014 15:30:18 +0530 Subject: finshed basic dependency handling --- website/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'website/helpers.py') diff --git a/website/helpers.py b/website/helpers.py index f137541..be8165b 100644 --- a/website/helpers.py +++ b/website/helpers.py @@ -3,7 +3,7 @@ import os, re, sys, time, subprocess from soc.settings import PROJECT_DIR from timeout import TimerTask -def scilab_run(code, token, example_id): +def scilab_run(code, token, book_id, dependency_exists): #Check for system commands system_commands = re.compile( 'unix\(.*\)|unix_g\(.*\)|unix_w\(.*\)|unix_x\(.*\)|unix_s\(.*\)|host|newfun|execstr|ascii|mputl|dir\(\)' @@ -37,14 +37,16 @@ def scilab_run(code, token, example_id): #traps even syntax errors eg: endfunton f = open(file_path, "w") f.write('mode(2);\n') + if dependency_exists: + f.write('getd("/var/www/scilab_in/uploads/{0}/DEPENDENCIES/");'.format(book_id)) + f.write('lines(0);\n') f.write(unicode(code)) f.write('\nquit();') f.close() - #this makes it possible to execute scilab without the problem of \ #getting stuck in the prompt in case of error - cmd = 'printf "lines(0)\nexec(\'{0}\',2);\nquit();"'.format(file_path) + cmd = 'printf "exec(\'{0}\',2);\nquit();"'.format(file_path) cmd += ' | /home/cheese/scilab-5.4.1/bin/scilab-adv-cli -nw' task = TimerTask(cmd, timeout=10) -- cgit