Expose class members as Fabric tasks
Project description
Fabric has class-based tasks but they are limited: Task class represents a single task.
This module make it possible to have class-based Fabric task sets.
Installation
pip install fabric-taskset
Usage
TaskSet is a class that can expose its methods as Fabric tasks.
Example:
# my_lib/say.py from taskset import TaskSet, task class SayBase(TaskSet): def say(self, what): raise NotImplemented() @task(default=True, alias='hi') def hello(self): self.say('hello') class EchoSay(SayBase): def say(self, what): local('echo ' + what) instance = EchoSay() instance.expose_to_current_module() # fabfile.py from mylib import say
and then e.g.:
$ fab say.hi hello
taskset.task is a decorator declaring the wrapped method to be task. It acceps the same arguments as fabric.decorators.task so use it on methods just like fabric’s decorator is used on functions.
Acknowledgements
https://github.com/ramusus/fabriclassed is a very similar app. At the time of writing it is focused on old-style Fabric tasks and has a small deployment framework included.
In order to feed my NIH syndrome I create Fabric-taskset which exposes new-style Fabric tasks, provides slightly different API and doesn’t have extra goodies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fabric-taskset-0.1.tar.gz
.
File metadata
- Download URL: fabric-taskset-0.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 715d87269df7b65ab8511424c42ceaf8a707a8545837645c5f4c6d5c056196a7 |
|
MD5 | e696ababf534320a1f8ed1fe61d7b133 |
|
BLAKE2b-256 | 968862af2805b242e7a751f042bc2b9b8d53c2545f7dcadb46996387a1292aef |