mirror of
https://github.com/NetherlandsForensicInstitute/hansken-extraction-plugin-sdk-documentation.git
synced 2026-05-02 00:06:34 +00:00
228 lines
15 KiB
HTML
228 lines
15 KiB
HTML
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="en" data-content_root="../../">
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Run plugins with Hansken.py — Hansken Extraction Plugins for plugin developers 0.8.3
|
||
documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=649a27d8" />
|
||
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
|
||
<link rel="stylesheet" type="text/css" href="../../_static/wider_pages.css?v=32ad70ab" />
|
||
|
||
|
||
<!--[if lt IE 9]>
|
||
<script src="../../_static/js/html5shiv.min.js"></script>
|
||
<![endif]-->
|
||
|
||
<script src="../../_static/jquery.js?v=5d32c60e"></script>
|
||
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
|
||
<script src="../../_static/documentation_options.js?v=7f96dc5e"></script>
|
||
<script src="../../_static/doctools.js?v=9a2dae69"></script>
|
||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></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="How to debug an Extraction Plugin" href="debugging.html" />
|
||
<link rel="prev" title="Advanced use of the Test Framework in Python" href="testing.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.8.3
|
||
|
||
</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" aria-label="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"><a class="reference internal" href="getting_started.html">Getting started</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="packaging.html">Packaging</a></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 current"><a class="current reference internal" href="#">Run plugins with Hansken.py</a><ul>
|
||
<li class="toctree-l3"><a class="reference internal" href="#how-to-run-python-extraction-plugins-standalone-with-hansken-py">How to run python extraction plugins standalone with Hansken.py</a><ul>
|
||
<li class="toctree-l4"><a class="reference internal" href="#create-a-runner-file">Create a runner file</a></li>
|
||
<li class="toctree-l4"><a class="reference internal" href="#preparing-for-the-command">Preparing for the command</a></li>
|
||
<li class="toctree-l4"><a class="reference internal" href="#running-your-plugin-with-hansken-py">Running your plugin with Hansken.py</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#compatibility">Compatibility</a></li>
|
||
</ul>
|
||
</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" aria-label="Home"></a></li>
|
||
<li class="breadcrumb-item"><a href="../python.html">Python</a></li>
|
||
<li class="breadcrumb-item active">Run plugins with Hansken.py</li>
|
||
<li class="wy-breadcrumbs-aside">
|
||
<a href="../../_sources/dev/python/hanskenpy.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="run-plugins-with-hansken-py">
|
||
<h1>Run plugins with Hansken.py<a class="headerlink" href="#run-plugins-with-hansken-py" title="Link to this heading"></a></h1>
|
||
<p>Hansken.py is a Python client to Hansken’s REST API, developed and maintained by the Netherlands Forensic Institute.</p>
|
||
<p>With Hansken.py, you can run your Python plugin on a project on your Hansken installation that has already been
|
||
extracted. This way of running your plugin is useful during your plugin development. It is not required to upload your
|
||
plugin to Hansken and start an extraction, making the development cycle faster. However, please note that this is only
|
||
useful during the development stage of your plugin, as the execution of your plugin will be much slower compared to
|
||
running the plugin during a Hansken extraction.</p>
|
||
<div class="admonition note">
|
||
<p class="admonition-title">Note</p>
|
||
<p>The execution of your plugin will be much slower in Hansken.py compared to running the plugin during a Hansken
|
||
extraction.</p>
|
||
</div>
|
||
<section id="how-to-run-python-extraction-plugins-standalone-with-hansken-py">
|
||
<h2>How to run python extraction plugins standalone with Hansken.py<a class="headerlink" href="#how-to-run-python-extraction-plugins-standalone-with-hansken-py" title="Link to this heading"></a></h2>
|
||
<p>Running python extraction plugins standalone with Hansken.py is easy. It is just one command. This section explains how
|
||
to setup this command for your specific environment.</p>
|
||
<section id="create-a-runner-file">
|
||
<h3>Create a runner file<a class="headerlink" href="#create-a-runner-file" title="Link to this heading"></a></h3>
|
||
<p>Create a file <code class="docutils literal notranslate"><span class="pre">run_with_hansken.py</span></code> in the root folder of your plugin. This will aid you in running the plugin with
|
||
hansken.py.</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">hansken_extraction_plugin.runtime.extraction_plugin_runner</span> <span class="kn">import</span> <span class="n">run_with_hanskenpy</span>
|
||
|
||
<span class="kn">from</span> <span class="nn">plugin.my_plugin</span> <span class="kn">import</span> <span class="n">MyPlugin</span>
|
||
|
||
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
|
||
<span class="n">run_with_hanskenpy</span><span class="p">(</span><span class="n">MyPlugin</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
<section id="preparing-for-the-command">
|
||
<h3>Preparing for the command<a class="headerlink" href="#preparing-for-the-command" title="Link to this heading"></a></h3>
|
||
<p>Before you can enter the command that runs your extraction plugin with Hansken.py, you need to find three values:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">HANSKEN_PROJECT_ID</span></code> project id on which you want to run your plugin</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">YOUR_GATEKEEPER_URL</span></code> the URL to the Hansken gatekeeper</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">YOUR_KEYSTORE_URL</span></code> the URL to your keystore</p></li>
|
||
</ul>
|
||
<p>The correct values of these variables can be found in the Expert UI. Go to the search-page of your project in the
|
||
ExpertUI. Next to the search-bar hit the button “Save query”.</p>
|
||
<a class="reference external image-reference" href="hanskenpy_save_query.png"><img alt="hanskenpy_save_query.png" src="../../_images/hanskenpy_save_query.png" /></a>
|
||
<p>A new dialog shows up. At the bottom of this dialog, you will find your gatekeeper and keystore urls as well as the
|
||
project id.</p>
|
||
<a class="reference external image-reference" href="hanskenpy_gatekeeper_keystore.png"><img alt="hanskenpy_gatekeeper_keystore.png" src="../../_images/hanskenpy_gatekeeper_keystore.png" /></a>
|
||
</section>
|
||
<section id="running-your-plugin-with-hansken-py">
|
||
<h3>Running your plugin with Hansken.py<a class="headerlink" href="#running-your-plugin-with-hansken-py" title="Link to this heading"></a></h3>
|
||
<p>Next, open a terminal in the project root folder of your plugin and enter the following command. It will run your
|
||
extraction plugin with Hansken.py in Hansken. Replace the three variables with their respective values.</p>
|
||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>python3<span class="w"> </span>./run_with_hanskenpy.py<span class="w"> </span>-v<span class="w"> </span>-l<span class="w"> </span>-<span class="w"> </span>HANSKEN_PROJECT_ID<span class="w"> </span>--endpoint<span class="w"> </span>YOUR_GATEKEEPER_URL<span class="w"> </span>--keystore<span class="w"> </span>YOUR_KEYSTORE_URL
|
||
</pre></div>
|
||
</div>
|
||
<p>If your command runs well, you might be prompted for your username and password. There will be some output (note that
|
||
the output may vary depending on your system setup and project content):</p>
|
||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>[2021-03-16 12:59:45.344248+0000] INFO: hansken.auth: selected IDP ID (...) with SOAP endpoint (...)
|
||
[2021-03-16 12:59:45.344450+0000] WARNING: hansken.auth: IDP url known, user+pass auth required but no username supplied
|
||
username []: testaccount
|
||
[2021-03-16 12:59:48.423245+0000] INFO: hansken.auth: user acknowledged environment username or supplied custom username: testaccount
|
||
password for user testaccount:
|
||
[2021-03-16 12:59:53.799668+0000] INFO: hansken.auth: identity provider url and user+pass provided or known, using Keycloak SAML with Basic auth
|
||
[2021-03-16 12:59:53.805538+0000] INFO: hansken_extraction_plugin.runtime.extraction_plugin_runner: PluginRunner is running plugin class Plugin
|
||
[2021-03-16 12:59:53.859299+0000] INFO: hansken.auth: posting SAML request with authorization for user testaccount to IDP endpoint (...)
|
||
[2021-03-16 12:59:54.240290+0000] INFO: plugin.extraction_plugin: processing trace 54197e67-8135-40c3-93f1-3d73a5552693
|
||
[2021-03-16 12:59:54.240753+0000] INFO: plugin.extraction_plugin: processing trace OCRimage
|
||
[2021-03-16 12:59:54.240753+0000] INFO: plugin.extraction_plugin: processing trace (...)
|
||
</pre></div>
|
||
</div>
|
||
<p>Note that the arguments <code class="docutils literal notranslate"><span class="pre">-v</span></code> and <code class="docutils literal notranslate"><span class="pre">-l</span> <span class="pre">-</span></code> are passed to enable logging. To find out what other options can be passed to
|
||
this command, please have a look at the hansken.py documentation, or simply run the following command:</p>
|
||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>python3<span class="w"> </span>./run_with_hanskenpy.py<span class="w"> </span>--help
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
<section id="compatibility">
|
||
<h2>Compatibility<a class="headerlink" href="#compatibility" title="Link to this heading"></a></h2>
|
||
<p>At this moment, running Extraction Plugins with Hansken.py has a few limitations. These are:</p>
|
||
<ul class="simple">
|
||
<li><p>When writing an Extraction Plugin for use with Hansken.py, the matcher must contain exactly one “$data.property =
|
||
value” expression.</p></li>
|
||
<li><p><a class="reference internal" href="../concepts/data_transformations.html"><span class="doc">Data transformations</span></a> are currently not supported by Hansken.py.</p></li>
|
||
<li><p><a class="reference internal" href="../concepts/traces.html#tracelets"><span class="std std-ref">Tracelets</span></a> are not yet supported by the SDK in use with Hansken.py.</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||
<a href="testing.html" class="btn btn-neutral float-left" title="Advanced use of the Test Framework in Python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||
<a href="debugging.html" class="btn btn-neutral float-right" title="How to debug an Extraction Plugin" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||
</div>
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>© Copyright 2020-2024 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> |