elog2labfolder/_build/html/_sources/importing_from_elog.rst.txt
author weiher
Mon, 05 Feb 2018 16:51:33 +0100
changeset 11 ccfe3c7fa0d2
child 15 523ca1dfd077
permissions -rw-r--r--
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     1
Importing projects from e.g. the ELOGbook to Labfolder at the FHI
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     2
=================================================================
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     3
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     4
The ELOG entries of a certain project need to be exported as *Raw* which looks like this::
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     5
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     6
	$@MID@$: 12
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     7
	Date: Tue, 03 Dec 2013 12:15:14 +0100
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     8
	Author: Wieland Schöllkopf
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
     9
	Author Email: mailto:wschoell@fhi-berlin.mpg.de
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    10
	Category: Shift summary
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    11
	Subject: 1st solid-state experiment with FHI FEL
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    12
	Severity: DOCU
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    13
	Keywords:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    14
	Record date: 1386069171
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    15
	Attachment:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    16
	Encoding: HTML
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    17
	========================================
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    18
	<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>
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    19
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    20
The entry shown above looks like this in the ELOG webinterface:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    21
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    22
.. image:: _static/elog_entry.png
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    23
   :width: 100 %
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    24
   :align: center
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    25
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    26
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. "ö". 
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    27
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    28
After importing the above ELOG entry into labfolder this entry appears like that:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    29
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    30
.. image:: _static/entry_after_import.png
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    31
   :width: 100 %
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    32
   :align: center
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    33
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    34
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    35
Using python to import from ELOG to labfolder
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    36
---------------------------------------------
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    37
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    38
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::
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    39
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    40
	$ git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    41
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    42
The script *elog2labfolder.py* 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 *myPythonAPIv1.py* and *myPythonAPIv2.py*. 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. *getListOfAuthors.py* gives you a list of all authors in a raw ELOG export file.
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    43
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    44
Alternatives to the manipulating the labfolder DB on MySQL level
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    45
----------------------------------------------------------------
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    46
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    47
As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    48
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    49
* *createUserAccount(email, author, entryContent, verboseOutput, cursor, db)*: If an author of an ELOG logbook entry has not yet 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) and enabled again after the setting process is finished.
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    50
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    51
* *updateAuthor(userID, blockID, cursor, db)*: Update the author of an entry. With the script *elog2labfolder.py* 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 *userID*.
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    52
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    53
* *updateDateAndTime(date, blockID, cursor, db)*: Similar to *updateAuthor()* 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 are the time and date of the import of the entry.
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    54
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    55
The labfolder support suggested the following alternative involving using the labfolder API:
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    56
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    57
* ... siehe E-Mail (gesendet) vom 15.12. ...
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    58
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    59
ccfe3c7fa0d2 Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
diff changeset
    60