How to use Fabric in Django project?
黄舟
黄舟 2017-05-27 17:39:51
0
1
719

I want to synchronize files to a remote server in Django. I saw that the rsync_project method under Fabric's fabric.contrib.project can synchronize files.

#!/usr/bin/env python3

from fabric.contrib.project import rsync_project
from fabric.api import env, execute

env.hosts = ['172.30.200.82', '172.30.200.87']

def test():
    rsync_project(local_dir='/data/logstash-2.2.2', remote_dir='/data')

if __name__ == '__main__':
    test()

As above, directly executing python test.py will prompt No hosts found. Please specify (single) host string for connection:, be sure to use the command line to execute fab -f test.py test can run correctly. Now I want to put this function into the Django background. I also encountered this problem. I would like to ask how to integrate this function into Django, that is, let this function run directly. It can be executed without the need to go to the command line and use the fab command to call it again.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
淡淡烟草味

Use subprocess module?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!