Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from fabric.api import env, roles, task
  3. from fabric.tasks import Task
  4.  
  5. env.roledefs['my_role'] = ['localhost', '127.0.0.1']
  6.  
  7.  
  8. class CustomTask(Task):
  9.  
  10. def __init__(self, func, *args, **kwargs):
  11. super(CustomTask, self).__init__(*args, **kwargs)
  12. self.func = func
  13.  
  14. def run(self, *args, **kwargs):
  15. print("I want to do something here")
  16. return self.func(*args, **kwargs)
  17.  
  18.  
  19. @task(task_class=CustomTask)
  20. def cmd1():
  21. print('hello there')
  22.  
  23.  
  24. # @roles('my_role') # Uncomment this and 'fab -l' will fail
  25. @task(task_class=CustomTask)
  26. def cmd2():
  27. print('hello you')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement