Commit d53b0707 authored by sveseli's avatar sveseli
Browse files

add more examples

parent 6cbc91c8
#!/usr/bin/env python
import sys
import os
from dm import ExperimentDsApi
# This example assumes that the DM environment has been set by
# sourcing DM_INSTALL_ROOT/etc/dm.setup.sh:
# - DM_LOGIN_FILE should point to a file containing <username>|<password>
# - DM_DS_WEB_SERVICE_URL should point to the DM DS service
class ExperimentManager():
def __init__(self):
self.experimentDsApi = ExperimentDsApi()
def createExperiment(self, experimentName):
experiment = self.experimentDsApi.addExperiment(name=experimentName, stationName=os.environ.get('DM_STATION_NAME'), typeName='TEST')
return experiment
if __name__ == '__main__':
if len(sys.argv) != 2:
print('Usage: %s <experimentName>' % sys.argv[0])
sys.exit(1)
experimentName = sys.argv[1]
manager = ExperimentManager()
print(manager.createExperiment(experimentName))
#!/usr/bin/env python
import sys
from dm import ExperimentDaqApi
# This example assumes that the DM environment has been set by
# sourcing DM_INSTALL_ROOT/etc/dm.setup.sh:
# - DM_LOGIN_FILE should point to a file containing <username>|<password>
# - DM_DAQ_WEB_SERVICE_URL should point to the DM DAQ service
class DataUploader():
def __init__(self):
self.experimentDaqApi = ExperimentDaqApi()
def uploadDirectory(self, experimentName, dataDirectory):
# Experiment should already exist for this to work
uploadInfo = self.experimentDaqApi.upload(experimentName, dataDirectory)
return uploadInfo
if __name__ == '__main__':
if len(sys.argv) != 3:
print('Usage: %s <experimentName> <dataDirectory>' % sys.argv[0])
sys.exit(1)
experimentName = sys.argv[1]
dataDirectory = sys.argv[2]
uploader = DataUploader()
print(uploader.uploadDirectory(experimentName, dataDirectory))
......@@ -3,13 +3,14 @@
import sys
from dm import ExperimentDaqApi
# This example assumes that the DM environment has been set by
# sourcing DM_INSTALL_ROOT/etc/dm.setup.sh:
# - DM_LOGIN_FILE should point to a file containing <username>|<password>
# - DM_DAQ_WEB_SERVICE_URL should point to the DM DAQ service
class DataUploader():
def __init__(self):
# This assumes environment has been set
# DM_LOGIN_FILE should point to file containing <username>|<password>
# DM_DAQ_WEB_SERVICE_URL should point to the DM DAQ service
# Sourcing DM_INSTALL_ROOT/etc/dm.setup.sh should work
self.experimentDaqApi = ExperimentDaqApi()
def uploadFile(self, experimentName, dataDirectory, filePath):
......
Supports Markdown
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