Files
hansken-extraction-plugin-s…/0.6.0/dev/python/getting_started.html
2022-08-05 09:22:07 +02:00

193 lines
11 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Getting Started in Python &mdash; Hansken Extraction Plugins for plugin developers 0.6.0
documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/wider_pages.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Python code snippets" href="snippets.html" />
<link rel="prev" title="Prerequisites" href="prerequisites.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> Hansken Extraction Plugins for plugin developers
</a>
<div class="version">
0.6.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../concepts.html">General concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../spec.html">Extraction Plugin specifications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../java.html">Java</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../python.html">Python</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="api_changelog.html">Python API Changelog</a></li>
<li class="toctree-l2"><a class="reference internal" href="prerequisites.html">Prerequisites</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Getting Started in Python</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#installation">Installation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#building-and-running">Building and running</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#building-a-docker-image-for-a-python-plugin">Building a docker image for a Python plugin</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="snippets.html">Python code snippets</a></li>
<li class="toctree-l2"><a class="reference internal" href="testing.html">Advanced use of the Test Framework in Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="hanskenpy.html">Hansken.py</a></li>
<li class="toctree-l2"><a class="reference internal" href="debugging.html">How to debug an Extraction Plugin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../python.html#api-documentation">API Documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contact.html">Contact</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../changes.html">Changelog</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Hansken Extraction Plugins for plugin developers</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../python.html">Python</a> &raquo;</li>
<li>Getting Started in Python</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/dev/python/getting_started.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="getting-started-in-python">
<h1>Getting Started in Python<a class="headerlink" href="#getting-started-in-python" title="Permalink to this heading"></a></h1>
<p>See the
<a class="reference external" href="https://git.eminjenv.nl/hanskaton/hansken-extraction-plugin-sdk/doc-step-by-step">doc-step-by-step repository on git.eminjenv.nl</a>
for a more extensive guide that takes you by the hand from the very beginning. It explains how to install all
prerequisites, how to write your first Extraction Plugin in Python, how to test it and how to run it.</p>
<p>This section assumes you use the same setup as is used in
the <a class="reference external" href="https://git.eminjenv.nl/hanskaton/hansken-extraction-plugin-sdk/examples">Extraction Plugin Examples</a> and have
installed all prerequisites.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h2>
<p>To install the Python Extraction Plugins SDK, run:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip install hansken-extraction-plugin
</pre></div>
</div>
</section>
<section id="building-and-running">
<h2>Building and running<a class="headerlink" href="#building-and-running" title="Permalink to this heading"></a></h2>
<p>If you just want to build and test a python plugin code, use:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>tox
</pre></div>
</div>
<p>This will show the test results for the plugin and a wheel distribution is created in the <code class="docutils literal notranslate"><span class="pre">dist/</span></code> directory.</p>
<p>To test the plugin running in a docker image:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>tox -e integration
</pre></div>
</div>
<p>To serve the plugin manually:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>serve_plugin -vvv &lt;file&gt; &lt;port&gt;
</pre></div>
</div>
<p>Where <code class="docutils literal notranslate"><span class="pre">file</span></code> is the Python implementation of the plugin, and <code class="docutils literal notranslate"><span class="pre">port</span></code> is the port on which the plugin is served.
The command line option <code class="docutils literal notranslate"><span class="pre">-vvv</span></code> prints debug information to standard output.</p>
<p>For more information, see <a class="reference internal" href="testing.html"><span class="doc">Testing</span></a>.</p>
<section id="building-a-docker-image-for-a-python-plugin">
<h3>Building a docker image for a Python plugin<a class="headerlink" href="#building-a-docker-image-for-a-python-plugin" title="Permalink to this heading"></a></h3>
<p>Make sure that the Extraction Plugins SDK is <a class="reference internal" href="#"><span class="doc">installed</span></a> as well as Docker.
Then, build your plugin container image using the following command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>build_plugin PLUGIN_FILE DOCKER_FILE_DIRECTORY <span class="o">[</span>DOCKER_IMAGE_NAME<span class="o">]</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>build_plugin plugin/chatplugin.py . extraction-plugins/chatplugin
</pre></div>
</div>
<p>This will generate a plugin image:</p>
<ul class="simple">
<li><p>The extraction plugin is added to your local image registry (<code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">images</span></code>),</p></li>
<li><p>Note that DOCKER_IMAGE_NAME is optional and will default to <code class="docutils literal notranslate"><span class="pre">extraction-plugin/PLUGINID</span></code>, e.g.
<code class="docutils literal notranslate"><span class="pre">extraction-plugin/nfi.nl/extract/chat/whatsapp</span></code>,</p></li>
<li><p>The image is tagged with two tags: <code class="docutils literal notranslate"><span class="pre">latest</span></code>, and your plugin version.</p></li>
</ul>
<p>To verify that the image has been built, type the following command to view all local images:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker images
</pre></div>
</div>
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="prerequisites.html" class="btn btn-neutral float-left" title="Prerequisites" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="snippets.html" class="btn btn-neutral float-right" title="Python code snippets" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2020-2022 Netherlands Forensic Institute.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>