Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hammonds
dm-docs
Commits
d53b0707
Commit
d53b0707
authored
Jan 31, 2019
by
sveseli
Browse files
add more examples
parent
6cbc91c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/createExperiment.py
0 → 100755
View file @
d53b0707
#!/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
))
examples/directoryUpload.py
0 → 100755
View file @
d53b0707
#!/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
))
examples/
singleF
ileUpload.py
→
examples/
f
ileUpload.py
View file @
d53b0707
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment