My Django project is executed in a virtual environment. This is the virtual env and project structure:
$HOME/webapps/myproject -- virtual environment
$HOME/webapps/myproject/bin
$HOME/webapps/myproject/include
$HOME/webapps/myproject/lib
$HOME/webapps/myproject/project
$HOME/webapps/myproject/project/manage.py
$HOME/webapps/myproject/project/project
$HOME/webapps/myproject/project/project/settings.py
and the rest of django project files
I want to run syncdb to create tables for the project, but I get an error. This
is my script:
import xmlrpclib
USER = 'myuser'
PASS = 'mypassword'
PROJ = 'myproject'
server = xmlrpclib.ServerProxy('https://api.webfaction.com/')
session_id, account = server.login(USER, PASS)
# I want to run syncdb.
commands = [
'cd $HOME/webapps/%s' % PROJ,
'. bin/activate',
'cd project',
'python manage.py syncdb']
server.system(session_id, '; '.join(commands))
This is the error:
Traceback (most recent call last):
File "deploy.py", line 17, in <module>
server.system(session_id, '; '.join(commands))
File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<class \'webfaction_api.exceptions.CommandError\'>:Error while executing system commands:\nTraceback (most recent call last):\n File "manage.py", line 10, in <module>\n execute_from_command_line(sys.argv)\n File "/home/myuser/webapps/myproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line\n utility.execute()\n File "/home/myuser/webapps/myproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute\n self.fetch_command(subcommand)'>
How do I use manage.py commands from WebFaction API?
asked
20 Oct '12, 08:55
redtk
1●2
accept rate:
0%
If you run the command from an ssh console session do you get the same error?
You also might want to take a look at using fabric for tasks like this as well as deployment.
I had errors in one of my files. I fixed them and manage.py commands work again. Thanks for your help.