Chris Spencer
2015-11-18 05:39:38 UTC
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.
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.