/usr/share/doc/phatch/html/lib.system.html is in phatch-doc 0.2.7.1-1.
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 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | <!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>system — Phatch v0.2 documentation</title>
<link rel="stylesheet" href="_static/default.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.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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="top" title="Phatch v0.2 documentation" href="index.html" />
<link rel="up" title="lib" href="lib.html" />
<link rel="next" title="thumbnail" href="lib.thumbnail.html" />
<link rel="prev" title="safe" href="lib.safe.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="lib.thumbnail.html" title="thumbnail"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="lib.safe.html" title="safe"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Phatch v0.2 documentation</a> »</li>
<li><a href="lib.html" accesskey="U">lib</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-lib.system">
<span id="system"></span><h1>system<a class="headerlink" href="#module-lib.system" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="lib.system.MethodRegister">
<em class="property">class </em><tt class="descclassname">lib.system.</tt><tt class="descname">MethodRegister</tt><a class="headerlink" href="#lib.system.MethodRegister" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="lib.system.MethodRegister.does_process">
<tt class="descname">does_process</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#lib.system.MethodRegister.does_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the filename can be processed by any of the
registered methods.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> (<em>string</em>) – filename</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="lib.system.MethodRegister.get_methods">
<tt class="descname">get_methods</tt><big>(</big><em>extension</em><big>)</big><a class="headerlink" href="#lib.system.MethodRegister.get_methods" title="Permalink to this definition">¶</a></dt>
<dd><p>Get all methods registered for an extension.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>extension</strong> (<em>string</em>) – file extension</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">list of methods registered for the extension</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="lib.system.MethodRegister.register">
<tt class="descname">register</tt><big>(</big><em>extensions</em>, <em>method</em><big>)</big><a class="headerlink" href="#lib.system.MethodRegister.register" title="Permalink to this definition">¶</a></dt>
<dd><p>Register one method for multiple extensions. If the method
is None, it will cancel the registration.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>extensions</strong> (<em>list of strings</em>) – list of file extensions</li>
<li><strong>method</strong> – method to open a file</li>
<li><strong>method</strong> – function</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="lib.system.MethodRegister.unregister_extension">
<tt class="descname">unregister_extension</tt><big>(</big><em>extension</em><big>)</big><a class="headerlink" href="#lib.system.MethodRegister.unregister_extension" title="Permalink to this definition">¶</a></dt>
<dd><p>Unregister an extension from all methods.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>extensions</strong> (<em>list of strings</em>) – list of file extensions</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="lib.system.MethodRegister.unregister_method">
<tt class="descname">unregister_method</tt><big>(</big><em>method</em><big>)</big><a class="headerlink" href="#lib.system.MethodRegister.unregister_method" title="Permalink to this definition">¶</a></dt>
<dd><p>Unregister a method from all extensions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – method to open a file</li>
<li><strong>method</strong> – function</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="lib.system.TempFile">
<em class="property">class </em><tt class="descclassname">lib.system.</tt><tt class="descname">TempFile</tt><big>(</big><em>suffix=''</em>, <em>path=None</em><big>)</big><a class="headerlink" href="#lib.system.TempFile" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="lib.system.TempFile.close">
<tt class="descname">close</tt><big>(</big><em>force_remove=True</em>, <em>dest=''</em><big>)</big><a class="headerlink" href="#lib.system.TempFile.close" title="Permalink to this definition">¶</a></dt>
<dd><p>It is important to call this method when finished with
the temporary file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>force_remove</strong> (<em>boolean</em>) – Remove temporary file and raise IOError when it does not exist
anymore. Set to False too allow for processes that delete the
temporary file when failing to exit succesfully.</li>
<li><strong>dest</strong> (<em>string</em>) – This is eg used for thumbnails in order to rename them to
their proper location</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="lib.system.call">
<tt class="descclassname">lib.system.</tt><tt class="descname">call</tt><big>(</big><em>args</em>, <em>**keyw</em><big>)</big><a class="headerlink" href="#lib.system.call" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as subprocess.call, but if only a command line text is
given it breaks it in a list of arguments so it can be used
also with <tt class="docutils literal"><span class="pre">shell=False</span></tt> on Unix.</p>
</dd></dl>
<dl class="function">
<dt id="lib.system.ensure_path">
<tt class="descclassname">lib.system.</tt><tt class="descname">ensure_path</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#lib.system.ensure_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Ensure a path exists, create all not existing paths.</p>
<p>It raises an OSError, if an invalid path is specified.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>path</strong> (<em>str</em>) – the absolute folder path (not relative!)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="lib.system.file_extension">
<tt class="descclassname">lib.system.</tt><tt class="descname">file_extension</tt><big>(</big><em>uri</em><big>)</big><a class="headerlink" href="#lib.system.file_extension" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="lib.system.filename_to_title">
<tt class="descclassname">lib.system.</tt><tt class="descname">filename_to_title</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#lib.system.filename_to_title" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a filename to a title. It replaces dashes with spaces
and converts every first character to uppercase.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>filename</strong> (<em>str</em>) – an absolute or relative path</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">titled version of the filename</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">filename_to_title</span><span class="p">(</span><span class="s">'~/highlight_mask.png'</span><span class="p">)</span>
<span class="go">'Highlight Mask'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.find_command">
<tt class="descclassname">lib.system.</tt><tt class="descname">find_command</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#lib.system.find_command" title="Permalink to this definition">¶</a></dt>
<dd><p>Find command in text</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> (<em>string</em>) – command line</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">text</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">text</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">find_command</span><span class="p">(</span><span class="s">'convert image.jpg image.jpg'</span><span class="p">)</span>
<span class="go">'convert'</span>
<span class="gp">>>> </span><span class="n">find_command</span><span class="p">(</span><span class="s">'"/my apps/convert" image.jpg image.jpg'</span><span class="p">)</span>
<span class="go">'"/my apps/convert"'</span>
<span class="gp">>>> </span><span class="n">find_command</span><span class="p">(</span><span class="s">'/my apps/convert image.jpg image.jpg'</span><span class="p">)</span>
<span class="go">'/my'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.find_exe">
<tt class="descclassname">lib.system.</tt><tt class="descname">find_exe</tt><big>(</big><em>executable</em>, <em>quote=True</em>, <em>use_which=True</em>, <em>raise_exception=False</em><big>)</big><a class="headerlink" href="#lib.system.find_exe" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds an executable binary. Returns None if the binary can
not be found.</p>
<p>This method need some extra love for Windows and Mac.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>executable</strong> (<em>string</em>) – binary which will be used as a plugin (eg imagemagick)</li>
<li><strong>quote</strong> (<em>bool</em>) – quote the path if it contains spaces</li>
<li><strong>use_which</strong> (<em>bool</em>) – use the command <tt class="docutils literal"><span class="pre">which</span></tt> on non windows platforms</li>
<li><strong>raise_exception</strong> (<em>bool</em>) – raise exception if not found</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">absolute path to the binary</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string or None</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">find_exe</span><span class="p">(</span><span class="s">'python'</span><span class="p">)</span>
<span class="go">'/usr/bin/python'</span>
<span class="gp">>>> </span><span class="n">find_exe</span><span class="p">(</span><span class="s">'python'</span><span class="p">,</span> <span class="n">use_which</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="go">'/usr/bin/python'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.find_in">
<tt class="descclassname">lib.system.</tt><tt class="descname">find_in</tt><big>(</big><em>filename</em>, <em>paths</em><big>)</big><a class="headerlink" href="#lib.system.find_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds a filename in a list of paths.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>filename</strong> (<em>str</em>) – filename</li>
<li><strong>paths</strong> (<em>list of strings</em>) – paths</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">found filename with path or None</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string or None</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="lib.system.fix_quotes">
<tt class="descclassname">lib.system.</tt><tt class="descname">fix_quotes</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#lib.system.fix_quotes" title="Permalink to this definition">¶</a></dt>
<dd><p>Fix quotes for a command line parameter. Only surround
by quotes if a space is present in the filename.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> (<em>string</em>) – command line parameter</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">text with quotes if needed</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">fix_quotes</span><span class="p">(</span><span class="s">'blender'</span><span class="p">)</span>
<span class="go">'blender'</span>
<span class="gp">>>> </span><span class="n">fix_quotes</span><span class="p">(</span><span class="s">'/my programs/blender'</span><span class="p">)</span>
<span class="go">'"/my programs/blender"'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.is_file">
<tt class="descclassname">lib.system.</tt><tt class="descname">is_file</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#lib.system.is_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks wether a path is a valid local or remote file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>path</strong> (<em>str</em>) – the path which has to be checked</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if path is a valid local or remote file, False otherwise</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">is_file</span><span class="p">(</span><span class="s">'http://www.foo.com/logo.png'</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">is_file</span><span class="p">(</span><span class="s">'ftp://foo.com/logo.png'</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">is_file</span><span class="p">(</span><span class="s">'/etc/fstab'</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">is_file</span><span class="p">(</span><span class="s">'/etc/fstap'</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.is_www_file">
<tt class="descclassname">lib.system.</tt><tt class="descname">is_www_file</tt><big>(</big><em>url</em><big>)</big><a class="headerlink" href="#lib.system.is_www_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks whether a file is remote (http or ftp).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>url</strong> (<em>str</em>) – file path or url</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if remote, False if local</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">is_www_file</span><span class="p">(</span><span class="s">'http://www.foo.com/logo.png'</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">is_www_file</span><span class="p">(</span><span class="s">'ftp://foo.com/logo.png'</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">is_www_file</span><span class="p">(</span><span class="s">'logo.png'</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.set_bin_paths">
<tt class="descclassname">lib.system.</tt><tt class="descname">set_bin_paths</tt><big>(</big><em>paths=</em><span class="optional">[</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#lib.system.set_bin_paths" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes where binaries can be found.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>paths</strong> (<em>list of strings</em>) – list of paths where binaries might be found</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="lib.system.shell">
<tt class="descclassname">lib.system.</tt><tt class="descname">shell</tt><big>(</big><em>*args</em>, <em>**options</em><big>)</big><a class="headerlink" href="#lib.system.shell" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs a shell command and captures the output.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>args</strong> (<em>tuple of strings</em>) – the command to be executed in the shell</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">stdout and stdout</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">typle of strings</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">shell</span><span class="p">(</span><span class="s">'echo world'</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">('world\n', '')</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.shell_cache">
<tt class="descclassname">lib.system.</tt><tt class="descname">shell_cache</tt><big>(</big><em>args</em>, <em>cache=''</em>, <em>key=None</em>, <em>validate=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#lib.system.shell_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs a shell command and captures the output. It uses a caching system
so that cached results don’t need to run a subprocess anymore. The results
are cached by sys.platform</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>args</strong> (<em>tuple of strings</em>) – the command to be executed in the shell</li>
<li><strong>cache</strong> (<em>string</em>) – the filename of the cache file</li>
<li><strong>validate</strong> – a validate (eg mtime) to validate the cache result</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">stdout and stdout</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">typle of strings</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">shell</span><span class="p">(</span><span class="s">'echo world'</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">('world\n', '')</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.shell_returncode">
<tt class="descclassname">lib.system.</tt><tt class="descname">shell_returncode</tt><big>(</big><em>*args</em>, <em>**options</em><big>)</big><a class="headerlink" href="#lib.system.shell_returncode" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs a shell command and returns it’s exit code.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>args</strong> (<em>tuple of strings</em>) – the command to be executed in the shell</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">command exit code</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">integer</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="lib.system.split_command">
<tt class="descclassname">lib.system.</tt><tt class="descname">split_command</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#lib.system.split_command" title="Permalink to this definition">¶</a></dt>
<dd><p>Breaks a single command line into a list of string arguments.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> (<em>str</em>) – command line text</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">list of arguments</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list of str</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">split_command</span><span class="p">(</span><span class="s">'blender file_in.png file_out.png'</span><span class="p">)</span>
<span class="go">['blender', 'file_in.png', 'file_out.png']</span>
<span class="gp">>>> </span><span class="n">split_command</span><span class="p">(</span><span class="s">'"/my progs/blender" file_in.png file_out.png'</span><span class="p">)</span>
<span class="go">['"/my progs/blender"', 'file_in.png', 'file_out.png']</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.start">
<tt class="descclassname">lib.system.</tt><tt class="descname">start</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#lib.system.start" title="Permalink to this definition">¶</a></dt>
<dd><p>Open a file or browse a folder.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>path</strong> (<em>string</em>) – location of the file</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="lib.system.title">
<tt class="descclassname">lib.system.</tt><tt class="descname">title</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#lib.system.title" title="Permalink to this definition">¶</a></dt>
<dd><p>Turns a text in a title</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> (<em>str</em>) – text</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">title</p>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">title</span><span class="p">(</span><span class="s">'hello_world'</span><span class="p">)</span>
<span class="go">'Hello World'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="lib.system.wrap">
<tt class="descclassname">lib.system.</tt><tt class="descname">wrap</tt><big>(</big><em>text</em>, <em>fill=70</em><big>)</big><a class="headerlink" href="#lib.system.wrap" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="lib.safe.html"
title="previous chapter">safe</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="lib.thumbnail.html"
title="next chapter">thumbnail</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="lib.thumbnail.html" title="thumbnail"
>next</a> |</li>
<li class="right" >
<a href="lib.safe.html" title="safe"
>previous</a> |</li>
<li><a href="index.html">Phatch v0.2 documentation</a> »</li>
<li><a href="lib.html" >lib</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2009, www.stani.be.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
</div>
</body>
</html>
|