Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call Fabric directly in Python

Tags:

python

fabric

I want to extend Fabric with some functionality and would like to call Fabric programmatically.

What I figured out is to call the main() method in https://github.com/fabric/fabric/blob/master/fabric/main.py, but I can't pass any parameters directly to the function, because it reads it's parameters within the function.

Any idea to set the command line parameters programmatically and the calling main()?

like image 564
mitchkman Avatar asked Mar 28 '14 23:03

mitchkman


People also ask

What is the use of Fabric in Python?

Fabric is a Python library (i.e. a tool to build on) used for interacting with SSH and computer systems [easily] to automate a wide range of tasks, varying from application deployment to general system administration.

What is Fabfile PY?

The Fabfile This is the file that Fabric uses to execute tasks. Each task is a simple function. The fabfile should be in the same directory where you run the Fabric tool. The fabfile is where all of your functions, roles, configurations, etc. will be defined.

What is Fab command?

fab uses Python's optparse library, meaning that it honors typical Linux or GNU style short and long options, as well as freely mixing options and arguments. E.g. fab task1 -H hostname task2 -i path/to/keyfile is just as valid as the more straightforward fab -H hostname -i path/to/keyfile task1 task2 .


1 Answers

You can use the execute method in the Fabric library to call tasks.

http://docs.fabfile.org/en/1.8/api/core/tasks.html?highlight=execute#fabric.tasks.execute

like image 120
Bogdan Iulian Bursuc Avatar answered Sep 22 '22 00:09

Bogdan Iulian Bursuc