Help related executing system command from django

42 views
Skip to first unread message

Malhar Vora

unread,
Oct 17, 2013, 5:21:50 AM10/17/13
to django-d...@googlegroups.com
Hello,

I am executing a python script from django as described below.

def executeScript(request):
    '''
    View to execute script from web interface
    '''
    print "Execute script view called"
    basepath =  os.path.dirname(os.path.abspath(__file__))
    filepath = basepath + os.path.sep + "script" + os.path.sep + "dataintegrator.py"
    argpath = basepath + os.path.sep + "script" + os.path.sep + "urls.txt"
    print "FilePath : " + filepath
    print "ArgPath : " + argpath

    test = subprocess.call(["python", filepath, argpath])
    print "###########Result of execution is : " + str(test)
    return HttpResponseRedirect("webadmin")

Here in above code, dataintegrator.py is a script that I am executing from django web. Now code in a script opens a file called "maps.txt" which is also in same directory as dataintegrator.py. When I execute script from command line it can read file but execution from web interface gives exception.

IOError: [Errno 2] No such file or directory: 'maps.txt'

Even the maps.txt file exists in same directory and script runs fine from command line than what is the problem with web interface. Anyone knows the solution ?


Regds,
Malhar Vora

Jorge Cardoso Leitão

unread,
Oct 17, 2013, 5:42:39 AM10/17/13
to django-d...@googlegroups.com
Hi Malhar.

I suggest you to post your question in the django-users mailing list. This mailing list is for the development of Django itself.

Thank you,
Jorge

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFA4AP-85pHuCFudKp04QpK5110PV7aAKQ6xxQuC%2BRogJKpU8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Daniele Procida

unread,
Oct 17, 2013, 6:31:16 AM10/17/13
to django-d...@googlegroups.com
On Thu, Oct 17, 2013, Jorge Cardoso Leitão <jo...@sapo.pt> wrote:

>I suggest you to post your question in the django-users mailing list.
>This mailing list is for the development of Django itself.

The django-users list can be found at <http://groups.google.com/group/django-users/>.

The #django IRC channel on IRC (on irc.freenode.net) is also very helpful.

Daniele

Reply all
Reply to author
Forward
0 new messages