diff options
author | Jayaram R Pai | 2014-09-04 15:30:18 +0530 |
---|---|---|
committer | Jayaram R Pai | 2014-09-04 15:30:18 +0530 |
commit | e894b2919c54a1cf577ec170cd9e6d99bedc6da9 (patch) | |
tree | 3a31db68eb452befb2fab18f3ecfe3145707a843 /website/helpers.py | |
parent | 87b533642db245fe3c03c9b1fd8220f0f7a195f8 (diff) | |
download | scilab-on-cloud-e894b2919c54a1cf577ec170cd9e6d99bedc6da9.tar.gz scilab-on-cloud-e894b2919c54a1cf577ec170cd9e6d99bedc6da9.tar.bz2 scilab-on-cloud-e894b2919c54a1cf577ec170cd9e6d99bedc6da9.zip |
finshed basic dependency handling
Diffstat (limited to 'website/helpers.py')
-rw-r--r-- | website/helpers.py | 8 |
1 files changed, 5 insertions, 3 deletions
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) |