Accessing doit config object

31 views
Skip to first unread message

Mike Pagel

unread,
Oct 16, 2017, 12:18:36 PM10/16/17
to python-doit
I am starting to use doit for a production CI project and I like it a lot. I will be building a library of doit tasks that can be used across different projects. For this I'd like to access some global configuration options from within a task (definition). One such example is to look at the current verbosity level and then tune the logging level accordingly. I know I can always add custom options, but using what's already there would be great.

Secondly, I have to configure my "doit-task-library" by setting a few paths, basically injecting some kind of (non-pythonic) dependencies. I can think of a few ways to do that, but just out of curiosity: could I use the config object in some way, by adding custom properties? If so, I would also need access to it from a task definition context.

I am just looking for the idiomatic way... :-)

Thanks a lot,
Mike

Eduardo Schettino

unread,
Oct 16, 2017, 1:06:27 PM10/16/17
to python-doit
On Mon, Oct 16, 2017 at 3:48 PM, 'Mike Pagel' via python-doit <pytho...@googlegroups.com> wrote:
I am starting to use doit for a production CI project and I like it a lot. I will be building a library of doit tasks that can be used across different projects. For this I'd like to access some global configuration options from within a task (definition). One such example is to look at the current verbosity level and then tune the logging level accordingly. I know I can always add custom options, but using what's already there would be great.

I guess for "verbosity" it is available in available in the "task" object. See http://pydoit.org/tasks.html#keywords-with-task-metadata

For the command line execution you should be able to retrieve it somehow.
There is no official API for that, you will need to check the code.


Secondly, I have to configure my "doit-task-library" by setting a few paths, basically injecting some kind of (non-pythonic) dependencies. I can think of a few ways to do that, but just out of curiosity: could I use the config object in some way, by adding custom properties? If so, I would also need access to it from a task definition context.

no, you can not pass custom properties, but i guess in this case it would not be useful.
I guess you need a custom `uptodade` callable.
Look at the ones shipped with doit you should be able to see an example.
 

I am just looking for the idiomatic way... :-)

Thanks a lot,
Mike

--
You received this message because you are subscribed to the Google Groups "python-doit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-doit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages