Reputation: 41
I have a fabric task eg-
def run_task():
#code here
From the command prompt I run this task:
fab -c env.fabricrc run_task -H hostnamr
How can I run this task from django?I click on a button on a webpage in django app and it should do this. How can I achieve this?
Upvotes: 0
Views: 1194
Reputation: 4131
Here's the section on how to use fabric as a python module/library without using the fab command to run tasks.
Short example:
from fabric.api import execute
#import your task if it is not in the same module, i.e.:
from mytasks import run_task
execute(run_task, hosts='hostname')
Upvotes: 1
Reputation: 31981
I think you should place this logic somewhere in your Django app. And let run_task
be just a wrapper around this logic.
It is fabfile that's based on the app, not vise versa.
Upvotes: 0