Friday, March 25, 2016

Simple subprocess help

Okay, so I have figured out that the subprocess is the module that I want to use in this context and I have tried implementing some simple code based on the documentation but I am getting an

Exception Type: OSError  Exception Value: [Errno 2] No such file or directory  Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py in _execute_child, line 1335.  

A brief overview of what I'm trying to do:

This is the code I have in views. Its intent is to take text input from the model form, POST that to the DB and then pass that input into my script which produces an XML file which is stored in another column in the DB. I'm very new to django so I'm sorry if this is an simple fix, but I couldn't find any documentation relating django to subprocess that was helpful.

def queries_create(request):      if not request.user.is_authenticated():         return render(request, 'login_error.html')          form = QueryForm(request.POST or None)      if form.is_valid():        instance = form.save(commit=False)        instance.save()        p=subprocess.Popen([request.POST['post'], './path/to/run_pipeline.sh'])        p.save()        context = {          "title":"Create",        "form": form,        }      return render(request, "query_form.html", context) 

Model code snippet:

class Query(models.Model):    problem/intervention = models.TextField()      updated = models.DateTimeField(auto_now=True, auto_now_add=False)    timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3695d62e-6633-4dae-8afe-792b917cc0b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment