fileUpload.py 1.01 KB
Newer Older
sveseli's avatar
sveseli committed
1
2
3
4
5
#!/usr/bin/env python

import sys
from dm import ExperimentDaqApi

sveseli's avatar
sveseli committed
6
7
8
9
10
# 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 

sveseli's avatar
sveseli committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class DataUploader():

    def __init__(self):
        self.experimentDaqApi = ExperimentDaqApi()
        
    def uploadFile(self, experimentName, dataDirectory, filePath):
        # Experiment should already exist for this to work
        uploadInfo = self.experimentDaqApi.upload(experimentName, dataDirectory, {'filePath' : filePath})
        return uploadInfo

if __name__ == '__main__':
    if len(sys.argv) != 4:
        print('Usage: %s <experimentName> <dataDirectory> <filePath>' % sys.argv[0])
        sys.exit(1)
    experimentName = sys.argv[1]
    dataDirectory = sys.argv[2]
    filePath = sys.argv[3]
    uploader = DataUploader()
    print(uploader.uploadFile(experimentName, dataDirectory, filePath))