fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] How to dynamically define tasks in different modules?


From: Chris Spencer
Subject: [Fab-user] How to dynamically define tasks in different modules?
Date: Wed, 18 Nov 2015 00:39:38 -0500

Is it possible to dynamically expose tasks in a namespace other than the module in which they appear?

Say I have the file `myfabtasks.py` containing the tasks `configure_apache`. By default, Fabric exposes this as `myfabtasks.configure_apache`, which is a little clunky. How would I expose it as `apache.configure` without renaming my module filename and task?

My goal is to make tasks class-based, and I'm currently able to dynamically create tasks with arbitrary names, but they're still restricted to the namespace of their module's filename, which causes conflicts if I have two classes in the same file that have the same method name.

I spent some time digging through the code, specifically in main.py and the `extract_tasks` function, but this behavior unfortunately seems to be hardcoded. Is there any workaround?

I tried dynamically creating a module with an arbitrary name and reassigning my tasks there, as explained at http://stackoverflow.com/questions/3799545/dynamically-importing-python-module/3799609#3799609, but Fab never seems to find the dynamic module.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]