Skip to content
Snippets Groups Projects
Forked from DM / dm-docs
261 commits behind, 396 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
dsProcessFileNotificationPlugin.py 1.23 KiB
#!/usr/bin/env python

import os
from dm.common.utility.loggingManager import LoggingManager
from dm.common.processing.plugins.fileProcessor import FileProcessor
from dm.ds_web_service.api.dsRestApiFactory import DsRestApiFactory

class DsProcessFileNotificationPlugin(FileProcessor):

    def __init__(self):
        FileProcessor.__init__(self)
        self.dsFileApi = DsRestApiFactory.getFileRestApi()
        self.logger = LoggingManager.getInstance().getLogger(self.__class__.__name__)

    def processFile(self, fileInfo):
        experimentFilePath = fileInfo.get('experimentFilePath')
        experiment = fileInfo.get('experiment')
        experimentName = experiment.get('name')
        self.logger.debug('Processing file %s for experiment %s' % (experimentFilePath, experimentName))

        # Prepare dictionary for processing. Only send needed data.
        fileInfo2 = {}
        fileInfo2['experimentFilePath'] = experimentFilePath
        fileInfo2['experimentName'] = experimentName
        fileInfo2['daqInfo'] = experiment.get('daqInfo')
        self.dsFileApi.processFile(experimentFilePath, experimentName, fileInfo2)

#######################################################################
# Testing.
if __name__ == '__main__':
    pass