login community faq

My Django project is executed in a virtual environment. This is the virtual env and project structure:

1
2
3
4
5
6
7
8
9
$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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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 Oct 20 '12 at 08:55

redtk's gravatar image

redtk
1

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.

(Oct 20 '12 at 12:31) bmeyer71 ♦♦ bmeyer71's gravatar image

I had errors in one of my files. I fixed them and manage.py commands work again. Thanks for your help.

(Oct 20 '12 at 19:19) redtk redtk's gravatar image
Be the first one to answer this question!
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×641
×41
×6
×5

Asked: Oct 20 '12 at 08:55

Seen: 267 times

Last updated: Oct 20 '12 at 19:19

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited