Commit 7eb68816 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'master' into 'master'

Add uploadfromBase64

Closes #38

See merge request icat/tango-metadata!24
parents bb18e08b 5a704564
# Metadata Manager and Experiment
- [Metadata Manager and Experiment](#Metadata-Manager-and-Experiment)
- [Dataset Location](#Dataset-Location)
- [DataFolderPattern](#DataFolderPattern)
- [Specific dataset Location](#Specific-dataset-Location)
- [Requirements](#Requirements)
- [Debian 6](#Debian-6)
- [Configuration](#configuration)
......@@ -22,7 +19,6 @@
- [Python](#Python)
- [Simulation](#Simulation)
7. [Simulation](#simulation)
## Dataset Location
......@@ -373,6 +369,14 @@ if __name__ == '__main__':
client.notifyDebug("This is debug")
```
### Upload Base64 image
In order to upload a base64 image a new method has been implemented. Example:
```
MetadataManagerInstance.uploadBase64("iVBORw0KGgoAAAANSUhEUgAAArsAAAL/CAYAAABmqg/4AAAgAElEQVR4Xuy9CZPbWLKke5i7VHV7q97G5r3//8ee2ZvbfXuvknIhiTH3CD8InGSmUlIuJNNlUxcgAG4OVs9XIT/uq2mapuY")
```
......
......@@ -643,17 +643,42 @@ class MetadataManager (tango.LatestDeviceImpl):
# Some versions of requests have not got this configuration
#requests.adapters.DEFAULT_RETRIES = 1
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
#print(self.icatplus_server + "/investigations/" + str(self.get_proposal()) + "/instrument/" + self.beamlineID.lower() +"/events/notification?sessionId=" + self.API_KEY)
print(self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + self.beamlineID.lower() + "/event")
url = self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + str(self.beamlineID.lower()) + "/event"
self.logger.debug(url)
requests.post(url,
data=(json.dumps(params)),
headers=headers)
#timeout=0.1
else:
self.logger.info("No requests installed")
except Exception as e:
sys.excepthook(*sys.exc_info())
pass
def uploadBase64(self, base64):
try:
if requests:
params = dict(
{
"base64" : base64,
"creationDate" : str(datetime.now().isoformat())
}
)
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
url = self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + str(self.beamlineID.lower()) + "/event/createFrombase64"
self.logger.debug(url)
requests.post(url,
data=(json.dumps(params)),
headers=headers,
timeout=0.1)
except Exception as e:
else:
self.logger.info("No requests installed")
except Exception as e:
sys.excepthook(*sys.exc_info())
pass
def notifyInfo(self, message):
self.sendNotification("notification", "info", message)
......@@ -1104,6 +1129,9 @@ class MetadataManagerClass(tango.DeviceClass):
'ClearDatasetParentLocation':
[[tango.DevVoid, "none"],
[tango.DevVoid, "none"]],
'uploadBase64':
[[tango.DevString, "Message"],
[tango.DevVoid, "none"]],
'notifyError':
[[tango.DevString, "Message"],
[tango.DevVoid, "none"]],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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