Tuesday, May 31, 2011

Re: python code works in command line but not in django

On May 30, 3:54 pm, Kann <vearas...@gmail.com> wrote:
> 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

"not working properly" is possibly not the most informative
description of your problem... What happens ? Get a traceback ? If so,
please post it (here or anywhere we can read it). Else please explain
what happens exactly.

> 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.

Very probably a permissions or env problem.

> >>>> 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)

OT: string concatenation yield a string object, so you don't need to
try and make a string from it. Also, Python as good support for string
formatting, which is usually more readable than string concatenation.

>  7     os.system(cmd)
>

And ? What happens ?

--
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