Skip to content
Snippets Groups Projects
getDaqInfoCli.py 1.25 KiB
Newer Older
#!/usr/bin/env python

from daqWebServiceSessionCli import DaqWebServiceSessionCli
from dm.daq_web_service.api.experimentRestApi import ExperimentRestApi
from dm.common.exceptions.invalidRequest import InvalidRequest

class GetDaqInfoCli(DaqWebServiceSessionCli):
    def __init__(self):
        DaqWebServiceSessionCli.__init__(self, validArgCount=self.ANY_NUMBER_OF_POSITIONAL_ARGS)
        self.addOption('', '--id', dest='id', help='Daq id.')

    def checkArgs(self):
        if self.options.id is None:
            raise InvalidRequest('Daq id must be provided.')

    def getId(self):
        return self.options.id

    def runCommand(self):
        self.parseArgs(usage="""
    dm-get-daq-info --id=ID

Description:
    Retrieves detailed information for the specified data acquisition.
        """)
        self.checkArgs()
        api = ExperimentRestApi(self.getLoginUsername(), self.getLoginPassword(), self.getServiceHost(), self.getServicePort(), self.getServiceProtocol())
        daqInfo = api.getDaqInfo(self.getId())
        print daqInfo.getDisplayString(self.getDisplayKeys(), self.getDisplayFormat())

#######################################################################
# Run command.
if __name__ == '__main__':
    cli = GetDaqInfoCli()
    cli.run()