<!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>Importing projects from e.g. the ELOGbook to Labfolder at the FHI — Labfolder at FHI 1.0 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0',
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>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Printing via CUPS and attaching files to labfolder logbooks" href="installation_cups.html" />
<link rel="prev" title="Import and export of projects and entries" href="import_export.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head>
<body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="importing-projects-from-e-g-the-elogbook-to-labfolder-at-the-fhi">
<h1>Importing projects from e.g. the ELOGbook to Labfolder at the FHI<a class="headerlink" href="#importing-projects-from-e-g-the-elogbook-to-labfolder-at-the-fhi" title="Permalink to this headline">¶</a></h1>
<p>This is how you generally do it:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="mf">1.</span> <span class="n">In</span> <span class="n">labfolder</span><span class="p">,</span> <span class="n">create</span> <span class="n">a</span> <span class="n">new</span> <span class="n">group</span> <span class="n">project</span><span class="o">.</span>
<span class="mf">2.</span> <span class="n">Get</span> <span class="n">the</span> <span class="n">ELOG</span> <span class="n">logbook</span> <span class="s2">"operating"</span> <span class="ow">and</span> <span class="n">export</span> <span class="n">it</span> <span class="k">as</span> <span class="n">RAW</span><span class="o">.</span> <span class="n">Remember</span> <span class="n">where</span> <span class="n">you</span><span class="s1">'ve put the text file with the raw output and the directory with attachments files.</span>
<span class="mf">3.</span> <span class="n">Only</span> <span class="n">once</span><span class="p">:</span> <span class="n">Get</span> <span class="n">the</span> <span class="n">elog2labfolder</span> <span class="n">repository</span> <span class="kn">from</span> <span class="nn">github.</span>
<span class="mf">4.</span> <span class="n">Adapt</span> <span class="n">elog2labfolder</span><span class="o">.</span><span class="n">py</span> <span class="n">to</span> <span class="n">your</span> <span class="n">needs</span><span class="o">.</span> <span class="n">Specify</span> <span class="n">the</span> <span class="n">name</span> <span class="n">of</span> <span class="n">the</span> <span class="n">project</span> <span class="n">that</span> <span class="n">you</span> <span class="n">created</span> <span class="n">previously</span><span class="o">.</span>
<span class="mf">4.</span> <span class="n">Run</span> <span class="n">elog2labfolder</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>These steps are explained in more detail in the following.</p>
<div class="section" id="creating-a-group-project">
<h2>Creating a group project<a class="headerlink" href="#creating-a-group-project" title="Permalink to this headline">¶</a></h2>
<p>As the group admin (or one of the admins) in labfolder create a group project, for example, “operating” in a group named “FEL”. You are now the owner of this project. Make sure you don’t have several projects of the same name in one group.</p>
</div>
<div class="section" id="entries-from-elog">
<h2>Entries from ELOG<a class="headerlink" href="#entries-from-elog" title="Permalink to this headline">¶</a></h2>
<p>The ELOG entries of a certain project need to be exported as <em>Raw</em> which looks like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$@MID@$: 12
Date: Tue, 03 Dec 2013 12:15:14 +0100
Author: Wieland Schöllkopf
Author Email: mailto:wschoell@fhi-berlin.mpg.de
Category: Shift summary
Subject: 1st solid-state experiment with FHI FEL
Severity: DOCU
Keywords:
Record date: 1386069171
Attachment:
Encoding: HTML
========================================
<p>Today Alex Paarmann and Marc Herzog are measuring in the wavelength range from 10 to 20 micron with a 0.5 mm thick GGG (Gadolinium Gallium Garnet, <a title="Gadolinium" href="http://en.wikipedia.org/wiki/Gadolinium">Gd</a><sub>3</sub><a title="Gallium" href="http://en.wikipedia.org/wiki/Gallium">Ga</a><sub>5</sub><a title="Oxygen" href="http://en.wikipedia.org/wiki/Oxygen">O</a><sub>12</sub>). Electron energy is set to 26 MeV.</p>
</pre></div>
</div>
<p>The entry shown above looks like this in the ELOG webinterface:</p>
<a class="reference internal image-reference" href="_images/elog_entry.png"><img alt="_images/elog_entry.png" class="align-center" src="_images/elog_entry.png" style="width: 100%;" /></a>
<p>What is noticeable is that the ELOG export comes with an “ö” instead of an “ö”. Interestingly, if only entries done by Wieland are exported the export file has UTF-8 encoding which can actually print German “Umlaute” (ö, ä, ü). If, however, all entries are exported the encoding changes to an encoding that cannot handle e.g. “ö”.</p>
<p>After importing the above ELOG entry into labfolder this entry appears like that:</p>
<a class="reference internal image-reference" href="_images/entry_after_import.png"><img alt="_images/entry_after_import.png" class="align-center" src="_images/entry_after_import.png" style="width: 100%;" /></a>
</div>
<div class="section" id="using-python-to-import-from-elog-to-labfolder">
<h2>Using python to import from ELOG to labfolder<a class="headerlink" href="#using-python-to-import-from-elog-to-labfolder" title="Permalink to this headline">¶</a></h2>
<p>There is a GitHub project containing a python program for importing a raw (see the export example above) ELOG project. Get the project files by typing:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git
</pre></div>
</div>
<p>The script <em>elog2labfolder.py</em> is meant to be executed from remote, that is, not on the machine on which labfolder is running. A prerequisit is the python MySQLDB package because for a few methods the labfolder API cannot be used, instead, direct manipulation of the labfolder MySQL database is needed. The actual labfolder API is applied in the methodes collected in <em>myPythonAPIv1.py</em> and <em>myPythonAPIv2.py</em>. Mostly, API version 2 is used but adding text at the end of an entry can only be accomplished by using the version 1 API call. <em>getListOfAuthors.py</em> gives you a list of all authors that are mentioned in a raw ELOG export file.</p>
<p>To finally import an ELOG logbook to a labfolder project you need to run <code class="docutils literal"><span class="pre">$</span> <span class="pre">python</span> <span class="pre">elog2labfolder.py</span></code>. Prior to this you need to make some changes to the header of the file, that is, these lines:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">### Set the hostname</span>
<span class="c1">#hostname = 'lftest'</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="s1">'labfolder'</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">'lftest'</span><span class="p">:</span>
<span class="n">server</span> <span class="o">=</span> <span class="s1">'http://'</span> <span class="o">+</span> <span class="n">hostname</span> <span class="o">+</span> <span class="s1">'.rz-berlin.mpg.de:9091'</span>
<span class="k">elif</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">'labfolder'</span><span class="p">:</span>
<span class="n">server</span> <span class="o">=</span> <span class="s1">'https://'</span> <span class="o">+</span> <span class="n">hostname</span> <span class="o">+</span> <span class="s1">'.rz-berlin.mpg.de:9091'</span>
<span class="c1">### The entries will be created using the following labfolder account which specifies the author of the entry. During the creation process, however, the entry's author ID will be changed to the real author's ID if the real author is already contained in the user table of the labfolder DB.</span>
<span class="n">email</span> <span class="o">=</span> <span class="s1">'weiher@fhi-berlin.mpg.de'</span>
<span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getpass</span><span class="p">(</span><span class="s1">'Enter the labfolder password associated with '</span> <span class="o">+</span> <span class="n">emailAddress</span><span class="o">+</span><span class="s1">': '</span><span class="p">)</span>
<span class="c1">### Specify the absolute path to the raw ELOG export file.</span>
<span class="n">elogExportFile</span> <span class="o">=</span> <span class="s1">'/home/stefan/Dokumente/labfolder/OperatingLogbook_exportRaw_ORIGINAL.txt'</span>
<span class="c1">### Full path to where the attachments of the logbook to be imported are stored:</span>
<span class="n">attachmentsDirectory</span> <span class="o">=</span> <span class="s1">'/home/stefan/Dokumente/labfolder/Operating/'</span>
<span class="c1">### Project name in labfolder</span>
<span class="n">projectName</span> <span class="o">=</span> <span class="s1">'operating'</span>
</pre></div>
</div>
</div>
<div class="section" id="alternatives-to-manipulating-the-labfolder-db-on-mysql-level">
<h2>Alternatives to manipulating the labfolder DB on MySQL level<a class="headerlink" href="#alternatives-to-manipulating-the-labfolder-db-on-mysql-level" title="Permalink to this headline">¶</a></h2>
<p>As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are:</p>
<ul class="simple">
<li><em>createUserAccount(email, author, entryContent, verboseOutput, cursor, db)</em>: If an author of an ELOG logbook entry does not yet have a labolder account this account is created on the fly by setting a default (encrypted) password. This password is irrelevant because labfolder checks the entered password with the one from the LDAP server. Note: when setting a password in the DB labfolder’s LDAP authentication needs to be disabled (FEATURE_LDAP_AUTHENTICATION=false) beforehand and enabled again after the setting process is finished.</li>
<li><em>updateAuthor(userID, blockID, cursor, db)</em>: Update the author of an entry. With the script <em>elog2labfolder.py</em> an entry is created with the author that is the person whose labfolder credentials are used to get the login token. Via this method the true author can be set to the passed in <em>userID</em>.</li>
<li><em>updateDateAndTime(date, blockID, cursor, db)</em>: Similar to <em>updateAuthor()</em> this method sets the creation and modification date to the creation time and date of the entry to be imported. This is necessary because otherwise creation and modification date in labfolder are the time and date when the import took place.</li>
</ul>
<p>The labfolder support suggested the following alternative involving using the labfolder API:</p>
<ul class="simple">
<li>User account: A user account can be created via the API 2 endpoint <code class="docutils literal"><span class="pre">/auth/signup</span></code>. The password will be an encrypted dummy password. In order for this to work the LDAP authentication must be turned off when this endpoint is called. After the account creation LDAP authentication should be turned on again. Once the true user of this account logs in labfolder will ignore the dummy password and check the entered password against the password stored in LDAP.</li>
<li>Author: To create a labfolder entry by using the original entry’s author needs a special work-around. <strong>First, make sure to prevent labfolder users from accessing labfolder for the time of the import.</strong> Then, manually change all user passwords in the DB to the same (encrypted) password. Switch off the LDAP authentication and restart labolder. Now, import entry by entry and get a new login token for each new entry. It is only possible to get login tokens for all users because they all have the same known password. If the author of the entry to be imported does not exist yet in the DB you need to create an account via the API 2 endpoint <code class="docutils literal"><span class="pre">/auth/signup</span></code>. Now you reopen the access to the labfolder instance and switch on LDAP again restarting labfolder afterwards. The users can login using their FHI credentials no matter the “universal” password in the DB. If LDAP authentication is not turned on the users could do a password recovery on the login screen and re-set their password to their liking.</li>
<li>Date and time: Since you cannot change creation and modification time stamp of an entry via the API you could instead create custom dates during the import of an entry. The original entry creation timestamp could be “Original entry creation” followed by the creation time and date of the import. All entries can be filtered and searched by the custom dates.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="import_export.html" title="previous chapter">Import and export of projects and entries</a></li>
<li>Next: <a href="installation_cups.html" title="next chapter">Printing via CUPS and attaching files to labfolder logbooks</a></li>
</ul></li>
</ul>
</div>
<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>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2018, Stefan Weiher.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.6</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
|
<a href="_sources/importing_from_elog.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>