On 08/09/06 21:13, Robin Gruyters wrote:
> Hi ya,
> 
> My hosting provider doesn't give shell access, so I can't execute like
> "syncdb", "startapp", "startproject", etc.
> 
> Is there another way to do this? (e.g. by creating a runsync.py script?! (or
> something?))
> 
> Regards,
> 
> Robin
> 

Haven't tried this, but in theory something like this should/could work.


def my_syncdb_view(request):
   # check if user has permission to run this here

   # prepare to capture output of syncdb()
   import sys
   orig_stdout = sys.stdout
   orig_stderr = sys.stderr
   from cStringIO import StringIO
   sys.stdout = StringIO()
   sys.stderr = StringIO()

   from django.core.management import syncdb
   syncdb()

   # rewind stringio instances
   sys.stdout.seek(0)
   sys.stderr.seek(0)

   output = []
   output.append("<h3>Output:</h3>")
   output.append('<pre>')
   output.append(sys.stdout.read())
   output.append('</pre>')

   output.append("<h3>Errors:</h3>")
   output.append('<pre>')
   output.append(sys.stderr.read())
   output.append('</pre>')

   # set stdout and stderr back just in case
   sys.stdout = orig_stdout
   sys.stderr = orig_stderr

   return HttpResponse('\n'.join(output))


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to