WebFaction
Community site: login faq

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
12
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.

(20 Oct '12, 12:31) bmeyer71 ♦♦

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

(20 Oct '12, 19:19) redtk
Be the first one to answer this question!
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×75
×9
×7

question asked: 20 Oct '12, 08:55

question was seen: 1,972 times

last updated: 20 Oct '12, 19:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM