Skip to content

Instantly share code, notes, and snippets.

@dbischof
Created December 20, 2013 20:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dbischof/8060934 to your computer and use it in GitHub Desktop.
Running custom Mezzanine code through Fabric (for more complex/production code use a Django management command).
# Two Fabric related items that tripped me up:
#
# 1. For most complex code, you have to prepend your code string with code=, as in fab python:code="[Your code]".
# Not doing this will result in the following error:
# TypeError: python() got an unexpected keyword argument '[the first few chars of your code...]'
#
# 2. If you have an = in your code, it must be escaped. Not escaping them will result in the following error:
# ValueError: too many values to unpack
#
# Here's a short sample:
fab python:code="from datetime import datetime
from example.foo.models import Foo
foos \= Foo.objects.filter(time__exact\='').all()
for foo in foos: foo.time \= datetime.now(); foo.save(); time.sleep(10)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment