/usr/share/doc/python-doit-doc/html/tools.html is in python-doit-doc 0.30.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tools — doit - automation tool</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.30',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favico.ico"/>
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Extending doit" href="extending.html" />
<link rel="prev" title="custom uptodate" href="uptodate.html" />
<style>
body {
font-size: 16px;
}
div.topic {
padding: 0;
background-color: #F8F4A6;
border: 1px solid #D8D486;
}
div.topic p.first {
margin: 0;
padding: 0.1em 0 0.1em 0.5em;
background-color: #E8E496;
border-bottom: 1px solid #C8C476;
}
div.topic p {
margin: 0.5em 1em 0.5em 1em;
}
p.topic-title {
display: run-in;
margin-right: 15px;
}
a.external-link {
background: url(_static/external.png) center right no-repeat;
padding-right: 13px;
}
div.related ul li a.external-link {
padding-right: 13px;
}
.sidebartext {
font-size: 75%;
line-height: 130%;
}
</style>
</head>
<body>
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 50px">
<img src="_static/doit.png" alt="doit logo" />
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="extending.html" title="Extending doit"
accesskey="N">next</a></li>
<li class="right" >
<a href="uptodate.html" title="custom uptodate"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Home</a> | </li>
<li><a href="contents.html">Documentation</a> | </li>
<!-- TODO news -->
<li><a class="external-link" href="https://github.com/pydoit/doit">Code</a> | </li>
<li><a class="external-link" href="https://github.com/pydoit/doit/issues">Issues</a> | </li>
<li><a class="external-link" href="http://pypi.python.org/pypi/doit">Download</a> | </li>
<li><a class="external-link" href="http://groups.google.co.in/group/python-doit">Forum</a> | </li>
<li><a class="external-link" href="https://twitter.com/py_doit">Twitter</a></li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="contents.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Tools</a><ul>
<li><a class="reference internal" href="#create-folder-action">create_folder (action)</a></li>
<li><a class="reference internal" href="#title-with-actions-title">title_with_actions (title)</a></li>
<li><a class="reference internal" href="#longrunning-action">LongRunning (action)</a></li>
<li><a class="reference internal" href="#interactive-action">Interactive (action)</a></li>
<li><a class="reference internal" href="#pythoninteractiveaction-action">PythonInteractiveAction (action)</a></li>
<li><a class="reference internal" href="#set-trace">set_trace</a></li>
<li><a class="reference internal" href="#ipython-integration">IPython integration</a></li>
</ul>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
<h3>Sponsors</h3>
<div>
<a href="http://pygarden.com"><img src="_static/pygarden.png" alt="pygarden.com logo" style="display:block; margin:auto;"/></a><br/>
</div>
<h3>Donate</h3>
<br/>
<div class="sidebartext">
If you use <em>doit</em> and think it is a useful project. Please consider to make a donation to support the developer/maintainer with maintanance tasks (bug fixes, merge patches, reply users) and further development.<br/>
</div>
<h3></h3>
<a href="http://python.org"><img src="_static/python-powered-w-100x40.png" alt="python logo"/></a><br/><br/>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="tools">
<h1>Tools<a class="headerlink" href="#tools" title="Permalink to this headline">¶</a></h1>
<p><cite>doit.tools</cite> includes some commonly used code. These are not used by the <cite>doit</cite>
core, you can see it as a “standard library”.
The functions/class used with <cite>uptodate</cite> were already introduced in the previous
section.</p>
<div class="section" id="create-folder-action">
<h2>create_folder (action)<a class="headerlink" href="#create-folder-action" title="Permalink to this headline">¶</a></h2>
<p>Creates a folder if it does not exist yet. Uses <cite>os.makedirs() <http://docs.python.org/2/library/os#os.makedirs>_</cite>.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">doit.tools</span> <span class="k">import</span> <span class="n">create_folder</span>
<span class="n">BUILD_PATH</span> <span class="o">=</span> <span class="s2">"_build"</span>
<span class="k">def</span> <span class="nf">task_build</span><span class="p">():</span>
<span class="k">return</span> <span class="p">{</span><span class="s1">'actions'</span><span class="p">:</span> <span class="p">[(</span><span class="n">create_folder</span><span class="p">,</span> <span class="p">[</span><span class="n">BUILD_PATH</span><span class="p">]),</span>
<span class="s1">'touch </span><span class="si">%(targets)s</span><span class="s1">'</span><span class="p">],</span>
<span class="s1">'targets'</span><span class="p">:</span> <span class="p">[</span><span class="s2">"</span><span class="si">%s</span><span class="s2">/file.o"</span> <span class="o">%</span> <span class="n">BUILD_PATH</span><span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="title-with-actions-title">
<h2>title_with_actions (title)<a class="headerlink" href="#title-with-actions-title" title="Permalink to this headline">¶</a></h2>
<p>Return task name task actions from a task. This function can be used as ‘title’ attribute of a task dictionary to provide more detailed information of the action being executed.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">doit.tools</span> <span class="k">import</span> <span class="n">title_with_actions</span>
<span class="k">def</span> <span class="nf">task_with_details</span><span class="p">():</span>
<span class="k">return</span> <span class="p">{</span><span class="s1">'actions'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'echo abc 123'</span><span class="p">],</span>
<span class="s1">'title'</span><span class="p">:</span> <span class="n">title_with_actions</span><span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="longrunning-action">
<span id="tools-longrunning"></span><h2>LongRunning (action)<a class="headerlink" href="#longrunning-action" title="Permalink to this headline">¶</a></h2>
<p>This is useful for executing long running process like a web-server.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">doit.tools</span> <span class="k">import</span> <span class="n">LongRunning</span>
<span class="k">def</span> <span class="nf">task_top</span><span class="p">():</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s2">"top"</span>
<span class="k">return</span> <span class="p">{</span><span class="s1">'actions'</span><span class="p">:</span> <span class="p">[</span><span class="n">LongRunning</span><span class="p">(</span><span class="n">cmd</span><span class="p">)],}</span>
</pre></div>
</div>
</div>
<div class="section" id="interactive-action">
<h2>Interactive (action)<a class="headerlink" href="#interactive-action" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="pythoninteractiveaction-action">
<h2>PythonInteractiveAction (action)<a class="headerlink" href="#pythoninteractiveaction-action" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="set-trace">
<h2>set_trace<a class="headerlink" href="#set-trace" title="Permalink to this headline">¶</a></h2>
<p><cite>doit</cite> by default redirects stdout and stderr. Because of this when you try to
use the python debugger with <code class="docutils literal"><span class="pre">pdb.set_trace</span></code>, it does not work properly.
To make sure you get a proper PDB shell you should use doit.tools.set_trace
instead of <code class="docutils literal"><span class="pre">pdb.set_trace</span></code>.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>
<span class="k">def</span> <span class="nf">need_to_debug</span><span class="p">():</span>
<span class="c1"># some code here</span>
<span class="kn">from</span> <span class="nn">doit</span> <span class="k">import</span> <span class="n">tools</span>
<span class="n">tools</span><span class="o">.</span><span class="n">set_trace</span><span class="p">()</span>
<span class="c1"># more code</span>
<span class="k">def</span> <span class="nf">task_X</span><span class="p">():</span>
<span class="k">return</span> <span class="p">{</span><span class="s1">'actions'</span><span class="p">:[(</span><span class="n">need_to_debug</span><span class="p">,)]}</span>
</pre></div>
</div>
</div>
<div class="section" id="ipython-integration">
<span id="tools-ipython"></span><h2>IPython integration<a class="headerlink" href="#ipython-integration" title="Permalink to this headline">¶</a></h2>
<p>A handy possibility for interactive experimentation is to define tasks from
within <em>ipython</em> sessions and use the <code class="docutils literal"><span class="pre">%doit</span></code> <a class="reference external" href="http://ipython.org/ipython-doc/dev/interactive/tutorial.html#magic-functions">magic function</a>
to discover and execute them.</p>
<p>First you need to register the new magic function into ipython shell.</p>
<div class="highlight-pycon"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">doit.tools</span> <span class="kn">import</span> <span class="n">register_doit_as_IPython_magic</span>
<span class="gp">>>> </span><span class="n">register_doit_as_IPython_magic</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p>To permanently add this magic-function to your IPython include it on your
<a class="reference external" href="http://ipython.org/ipython-doc/3/config/intro.html?highlight=profile#profiles">profile</a>,
create a new script inside your startup-profile
(i.e. <code class="file docutils literal"><span class="pre">~/.ipython/profile_default/startup/doit_magic.ipy</span></code>)
with the following content:</p>
<div class="last highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">doit.tools</span> <span class="k">import</span> <span class="n">register_doit_as_IPython_magic</span>
<span class="n">register_doit_as_IPython_magic</span><span class="p">()</span>
</pre></div>
</div>
</div>
<p>Then you can define your <cite>task_creator</cite> functions and invoke them with <cite>%doit</cite>
magic-function, instead of invoking the cmd-line script with a <code class="file docutils literal"><span class="pre">dodo.py</span></code>
file.</p>
<p>Examples:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="o">%</span><span class="n">doit</span> <span class="o">--</span><span class="n">help</span> <span class="c1">## Show help for options and arguments.</span>
<span class="gp">>>> </span><span class="k">def</span> <span class="nf">task_foo</span><span class="p">():</span>
<span class="go"> return {'actions': ["echo hi IPython"],</span>
<span class="go"> 'verbosity': 2}</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">doit</span> <span class="nb">list</span> <span class="c1">## List any tasks discovered.</span>
<span class="go">foo</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">doit</span> <span class="c1">## Run any tasks.</span>
<span class="go">. foo</span>
<span class="go">hi IPython</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="extending.html" title="Extending doit"
>next</a></li>
<li class="right" >
<a href="uptodate.html" title="custom uptodate"
>previous</a> |</li>
<li><a href="index.html">Home</a> | </li>
<li><a href="contents.html">Documentation</a> | </li>
<!-- TODO news -->
<li><a class="external-link" href="https://github.com/pydoit/doit">Code</a> | </li>
<li><a class="external-link" href="https://github.com/pydoit/doit/issues">Issues</a> | </li>
<li><a class="external-link" href="http://pypi.python.org/pypi/doit">Download</a> | </li>
<li><a class="external-link" href="http://groups.google.co.in/group/python-doit">Forum</a> | </li>
<li><a class="external-link" href="https://twitter.com/py_doit">Twitter</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2008-2017, Eduardo Schettino.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.5.
</div>
</body>
</html>
|