django and calling cli java application
I am just trying to gather some information, and whether it is possible to tie in cli java application and set up the class path using python. Also to be able to pass data around and share information between the two applications (web frontend and java application)
I currently I have a java application and looking to see if it is possible interface the two between django and j开发者_如何学JAVAava. Since I am familiar with it, instead of having to learn a new web framework like wicket.
I understand this maybe more python specific than django, any help would be appreciated.
Thanks
In Python you can run other programs using module subprocess and read/write from their standard output/input. More complex CLI (command-line) applications can be controlled with pexpect. Of course you can set environment variable CLASSPATH
.
If you want to run other programs in a web app (Django), make sure it will not make your users waiting for the HTML page for too long.
Yeah subprocess is a great module to call commandline scripts. If you are worried that the process will take to long for the user to wait around for html, consider using celery to asynchronously call your external scripts as a background process.
精彩评论