author | weiher |
Mon, 05 Feb 2018 16:51:33 +0100 | |
changeset 11 | ccfe3c7fa0d2 |
parent 3 | b71be85a294c |
child 13 | a21f3604f1db |
permissions | -rw-r--r-- |
3 | 1 |
Importing projects from e.g. the ELOGbook to Labfolder at the FHI |
2 |
================================================================= |
|
3 |
||
4 |
The ELOG entries of a certain project need to be exported as *Raw* which looks like this:: |
|
5 |
||
6 |
$@MID@$: 12 |
|
7 |
Date: Tue, 03 Dec 2013 12:15:14 +0100 |
|
8 |
Author: Wieland Schöllkopf |
|
9 |
Author Email: mailto:wschoell@fhi-berlin.mpg.de |
|
10 |
Category: Shift summary |
|
11 |
Subject: 1st solid-state experiment with FHI FEL |
|
12 |
Severity: DOCU |
|
13 |
Keywords: |
|
14 |
Record date: 1386069171 |
|
15 |
Attachment: |
|
16 |
Encoding: HTML |
|
17 |
======================================== |
|
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> |
|
19 |
||
11
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
diff
changeset
|
20 |
The entry shown above looks like this in the ELOG webinterface: |
3 | 21 |
|
22 |
.. image:: _static/elog_entry.png |
|
23 |
:width: 100 % |
|
24 |
:align: center |
|
25 |
||
11
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
27 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
diff
changeset
|
28 |
After importing the above ELOG entry into labfolder this entry appears like that: |
3 | 29 |
|
11
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
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:
3
diff
changeset
|
32 |
:align: center |
3 | 33 |
|
34 |
||
11
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
36 |
--------------------------------------------- |
3 | 37 |
|
11
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
39 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
41 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
43 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
45 |
---------------------------------------------------------------- |
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
diff
changeset
|
46 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
48 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
50 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
52 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
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:
3
diff
changeset
|
54 |
|
ccfe3c7fa0d2
Erweiterung der Doku um ein Kapitel zum Import und Export; das Kapitel ist noch nicht ganz fertig
weiher
parents:
3
diff
changeset
|
55 |
The labfolder support |
3 | 56 |
|
57 |