Monday, May 30, 2011

python code works in command line but not in django

Dear all,

I tried using python to execute some external java program in my code.
My problem is the os.system(cmd) was not working properly when the
code was included into some view in views.py. However, executing the
code from terminal worked just fine. I am not sure what is wrong here.

>>>> this is from my medusa package

1 import os
2
3 def create_image():
4 path = os.path.abspath('tmp/medusa')
5 medusa = os.path.abspath('mirnaworkbench/Medusa/Medusa.jar')
6 cmd = str('java -cp ' + medusa + '
medusa.batchoperations.BatchOperations ' + path)
7 os.system(cmd)

>>>> this is from one of my views

MedusaConnector.create_image()


>>>>>
calling MedusaConnector.create_image() from python shell worked just
fine.

Thanks,

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment