Using Python Fabric without the command-line tool (fab)

后端 未结 5 1010
旧时难觅i
旧时难觅i 2021-02-01 06:19

Altough Fabric documentations refers to a way of using the library for SSH access without requiring the fab command-line tool and/or tasks, I can\'t seem to manage a way to do i

5条回答
  •  无人共我
    2021-02-01 06:59

    This is what needs to be done:

    in example.py

    from fabric.api import settings, run
    
    def ps():
      with settings(host_string='example.com'):
        run("ps")
    ps()
    

    see docs for using fabric as a library: http://docs.fabfile.org/en/1.8/usage/env.html#host-string

提交回复
热议问题