diff options
author | Srikant Patnaik | 2016-04-15 18:42:27 +0530 |
---|---|---|
committer | Srikant Patnaik | 2016-04-15 18:42:27 +0530 |
commit | cdf4c8f9bb0a2d5af5a954403ad2e08e2825f792 (patch) | |
tree | 12d187428b703996b59e375288a8ed3bb383ecc9 /website/helpers.py | |
parent | 1f51a377928f921f2c021ab1e9d57d2e47b5b770 (diff) | |
download | scilab-on-cloud-cdf4c8f9bb0a2d5af5a954403ad2e08e2825f792.tar.gz scilab-on-cloud-cdf4c8f9bb0a2d5af5a954403ad2e08e2825f792.tar.bz2 scilab-on-cloud-cdf4c8f9bb0a2d5af5a954403ad2e08e2825f792.zip |
added changes to show plot
Diffstat (limited to 'website/helpers.py')
-rw-r--r-- | website/helpers.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/website/helpers.py b/website/helpers.py index 36d1cb4..aaeb44c 100644 --- a/website/helpers.py +++ b/website/helpers.py @@ -20,15 +20,16 @@ def scilab_run(code, token, book_id, dependency_exists): plot_exists = False #Finding the plot and appending xs2jpg function - p = re.compile(r'.*plot.*\(.*\).*\n|bode\(.*\)|evans\(.*\)') + #p = re.compile(r'.*plot.*\(.*\).*\n|bode\(.*\)|evans\(.*\)') + p = re.compile(r'plot*|.*plot.*\(.*\).*\n|bode\(.*\)|evans\(.*\)') plot_path = '' if p.search(code): plot_exists = True code = code + '\n' current_time = time.time() - plot_path = PROJECT_DIR + '/static/tmp/{0}.jpg'.format(str(current_time)) - code += 'xs2jpg(gcf(), "{0}");\n'.format(plot_path) + plot_path = PROJECT_DIR + '/static/tmp/{0}.png'.format(str(current_time)) + #code += 'xs2jpg(gcf(), "{0}");\n'.format(plot_path) #Check whether to load scimax / maxima if 'syms' in code or 'Syms' in code: @@ -39,6 +40,8 @@ def scilab_run(code, token, book_id, dependency_exists): #traps even syntax errors eg: endfunton f = open(file_path, "w") + f.write('driver("PNG");\n') + f.write('xinit("{0}");\n'.format(plot_path)) f.write('mode(2);\n') if dependency_exists: f.write( @@ -46,6 +49,7 @@ def scilab_run(code, token, book_id, dependency_exists): ) f.write('lines(0);\n') f.write(unicode(code)) + f.write('\nxend();') f.write('\nquit();') f.close() |