Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango-metadata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICAT
tango-metadata
Commits
801ccedf
Commit
801ccedf
authored
5 years ago
by
Alejandro De Maria Antolinos
Browse files
Options
Downloads
Patches
Plain Diff
It adds an example of usage from python
parent
925e27a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+85
-1
85 additions, 1 deletion
README.md
with
85 additions
and
1 deletion
README.md
+
85
−
1
View file @
801ccedf
...
...
@@ -68,7 +68,9 @@ In both cases these folder locations point to the **parent** folder of the datas
MetadataManager has got as
**optional**
dependency graypy (https://pypi.python.org/pypi/graypy) and requests
It can be installed:
Requests is a requirement for sending notifications to the
**elogbook**
and graypy is required to use
**Graylog**
They can be installed:
```
easy_install graypy
easy_install requests
...
...
@@ -292,6 +294,88 @@ Select the files and follow the instruccions
Go the the requirements section where dependencies are explained: [Requirements](#requirements)
### Usage
#### Python
Example:
```
#!/usr/bin/env python
"""A simple client for MetadataManager and MetaExperiment
"""
import time
import os
import sys
import logging
import PyTango.client
from time import gmtime, strftime
class MetadataManagerClient(object):
metadataManager = None
metaExperiment = None
"""
A client for the MetadataManager and MetaExperiment tango Devices
Attributes:
name: name of the tango device. Example: 'id21/metadata/ingest'
"""
def __init__(self, metadataManagerName, metaExperimentName):
"""
Return a MetadataManagerClient object whose metadataManagerName is *metadataManagerName*
and metaExperimentName is *metaExperimentName*
"""
self.proposal = None
if metadataManagerName:
self.metadataManagerName = metadataManagerName
if metaExperimentName:
self.metaExperimentName = metaExperimentName
print('MetadataManager: %s' % metadataManagerName)
print('MetaExperiment: %s' % metaExperimentName)
""" Tango Devices instances """
try:
MetadataManagerClient.metadataManager = PyTango.client.Device(self.metadataManagerName)
MetadataManagerClient.metaExperiment = PyTango.client.Device(self.metaExperimentName)
except:
print "Unexpected error:", sys.exc_info()[0]
raise
''' Set proposal should be done before stting the data root '''
def setProposal(self, proposal):
try:
MetadataManagerClient.metaExperiment.proposal = proposal
self.proposal = proposal
except:
print "Unexpected error:", sys.exc_info()[0]
raise
def notifyInfo(self, message):
MetadataManagerClient.metadataManager.notifyInfo(message)
def notifyError(self, message):
MetadataManagerClient.metadataManager.notifyError(message)
def notifyDebug(self, message):
MetadataManagerClient.metadataManager.notifyDebug(message)
if __name__ == '__main__':
metadataManagerName = 'id00/metadata/mgr'
metaExperimentName = 'id00/metadata/exp'
client = MetadataManagerClient(metadataManagerName, metaExperimentName)
client.setProposal('ID000000')
client.notifyInfo("This is a info")
client.notifyError("This is a error")
client.notifyDebug("This is debug")
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment