Running custom Mezzanine code through Fabric (for more complex/production code use a Django management command).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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