views:

160

answers:

1

We have a Django app running on apache server (mod_python) on a windows machine which needs to call some r scripts. To do so it would be easiest to call r through os.system, however when django gets to the os.system command it freezes up. I've also tried subprocess with the same result.

We have a possibly related problem in that Django can only access the file system of the machine it's on, all network drives appear to be invisible to it, which is VERY frustrating.

Any ideas on both of these issues (I'm assuming it's the same limitation in both instances) would be most appreciated.

+1  A: 

Instead of os.system, would RPy2 meet your needs? I've used it in a similar case to the one you're describing with Django, and it's worked quite well.

The high-level interface in rpy2 is designed to facilitate the use of R by Python programmers. R objects are exposed as instances of Python-implemented classes, with R functions as bound methods to those objects in a number of cases.

ars
We did try out rPy2 but it seemed to have quite a few bugs whenit came to performing complicated processes. in the long term we might translate all the scripts directly into python code but for now seperate rscripts are the only guaranteed way we have of accurately processing our data.
danspants
Or do you mean calling the rscripts from rpy2? That simple solution I had not considered!
danspants
Right - try `rpy2.robjects.source` function to source a script, but I wonder now if this will be effective, if it's really related to some sort of network drive issue?
ars