I’m begining to use Fabric for a Django production server.
Here is my fabfile.py
from fabric.api import *
env.hosts = ['me@myserver.net']
def srefresh():
with path('~me/myproject'):
run('python manage.py collectstatic')
sudo('apachectl restart')
And here is the output
$ fab srefresh
[me@myserver.net] Executing task ‘srefresh’
[me@myserver.net] run: python manage.py collectstatic
[me@myserver.net] out: python: can’t open file ‘manage.py’: [Errno 2] No such file or directory
What am I doing wrong ?
(not sure I’m using the with context manager well)
Actually, it’s quite clearly written in the docs.
fabric.context_managers.pathalters the PATH variable.fabric.context_managers.cdcan be used to change the remote directory. So in your case:should do the trick.