The fact that your Matlab code is packaged like Jars may not help much here, at least not with pure Python.
There are several ways to take the code written in Java and expose it in Python.
Jython
If you are ready to give Jython a shot, this can be a very simple way to provide a Django interface to your banks.
You can basically write a normal Django application, and also use Jython to work with your Jars. This might be the best of both worlds, assuming you're not tied to CPython.
Django-jython
Java Compatibility Interfaces
At CPYTHON, any of the following projects will help you work with the code in your Jar files:
- JCC : create a Python extension module that wraps your Jar file
- JPype : Provides an API to run the JVM and call into code running in this JVM from Python.
Separate process:
If you have a separate program written in Matlab (actually in any language), you can execute it as a child of your Django application. You look at a simple web form in Django that would allow you to enter values as input to this process, and then in your view (after checking the form) you would do something like:
command = "mymatlabprogram.exe %s"%(arg1,) process = subprocess.Popen(command.split()) stdout, stderr = process.communicate()
Assuming this worked, you can pull responses from stdout messages or errors from stderr. You can use the image created by this process, etc. Once something like this works, you can look at celeryd to extract material from the subprocess from your web application.
The advantage of working with a separate process is that you isolate errors in Matlab code from hacking your web application and vice versa. The disadvantage is that you have to serialize everything and work multiple times between the client’s browser and your web application, between the web application and the executable and back to the client.
source share