Commit c7e87ca0 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue_18' into 'master'

It fixes #11

Closes #11 and #18

See merge request !9
parents 31adb13f 7b5db6d6
......@@ -6,6 +6,7 @@
2. [Requirements](#requirements)
3. [Configuration](#configuration)
* [ICAT Reader](#icat-reader)
* [ICAT+](#icat+)
4. [Logging with Graylog](#logging-with-graylog)
5. [Build](#build)
......@@ -61,19 +62,23 @@ In both cases these folder locations point to the **parent** folder of the datas
## Requirements
MetadataManager has got as optional dependency graypy (https://pypi.python.org/pypi/graypy)
MetadataManager has got as optional dependency graypy (https://pypi.python.org/pypi/graypy) and requests
It can be installed:
```
easy_install graypy
easy_install requests
```
or
```
pip install -U graypy
pip install requests
```
## Configuration
### ICAT Reader
......@@ -105,6 +110,13 @@ In order to configure the access from the MetadataManager to ICAT is necessary t
![icat-properties.png](documentation/icat-properties.png)
### ICAT+
MetadataManager can send notifications to ICAT+. For doing so, some parameters need to be added into the class properties:
```
OBJ_PROPERTY:API_KEY: elogbook-be70ac55-fd08-4840-9b29-b73262958ca8
OBJ_PROPERTY:icatplus_server: "http://lindemaria:8000"
```
### Logging with Graylog
......
......@@ -612,15 +612,22 @@ class MetadataManager (PyTango.Device_4Impl):
PyTango.DevState.STANDBY])
return state_ok
# This sends a notification to the electronic logbook (ICAT+)
def sendNotification(self, category, message):
try:
if requests:
array = [{"format" : "text", "text" : message}]
# The content of the message
content = [{"format" : "plainText", "text" : message}]
datasetName = None
if self.attr_scanName_read :
datasetName = self.attr_scanName_read
print(datasetName)
params = dict(
{
"type" : "notification",
"datasetName" : datasetName,
"category" : category,
"content" : array,
"content" : content,
"creationDate" : str(datetime.now().isoformat())
}
)
......@@ -638,8 +645,8 @@ class MetadataManager (PyTango.Device_4Impl):
def notifyDebug(self, message):
self.sendNotification("debug", message)
def notifyCommandLine(self, message):
self.sendNotification("error", message)
def notifyCommand(self, message):
self.sendNotification("commandLine", message)
def notifyError(self, message):
self.sendNotification("error", message)
......@@ -1076,7 +1083,7 @@ class MetadataManagerClass(PyTango.DeviceClass):
'notifyDebug':
[[PyTango.DevString, "Message"],
[PyTango.DevVoid, "none"]],
'notifyCommandLine':
'notifyCommand':
[[PyTango.DevString, "Message"],
[PyTango.DevVoid, "none"]],
......
......@@ -152,15 +152,15 @@ class MetadataWorker():
def exportFinal(self, dataset, metadatafilename, entries, files, attr_metadataFile_read, attr_proposal_read, attr_sampleName_read, attr_scanName_read, parameters, client):
try:
xmlfilename = self.MakeFileName('data', 'xml', attr_metadataFile_read, attr_proposal_read, attr_sampleName_read, attr_scanName_read,False)
# No more export to XML file
#xmlfilename = self.MakeFileName('data', 'xml', attr_metadataFile_read, attr_proposal_read, attr_sampleName_read, attr_scanName_read,False)
dataset = self.addParametersToDataSet(dataset, parameters)
# send to ingestion
client.sendObject(dataset)
# keep local xml for reference
self.ExportToXMLFile(dataset, xmlfilename)
#self.ExportToXMLFile(dataset, xmlfilename)
# transform
sampleParamMap = []
params = self.toDictionary(dataset,sampleParamMap, initial=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment