Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • release_2_3_2_Bug20709
  • historicalarchivingservers-2.6.3
  • historicalarchivingservers-2.6.2
  • historicalarchivingservers-2.6.1
  • historicalarchivingservers-2.6.0
  • historicalarchivingservers-2.5.10
  • historicalarchivingservers-2.5.9
  • hdbtdbArchivingServers-2.5.8
  • hdbtdbArchivingServers-2.5.7
  • hdbtdbArchivingServers-2.5.6
  • hdbtdbArchivingServers-2.5.5
  • hdbtdbArchivingServers-2.5.4
  • hdbtdbArchivingServers-2.5.3
  • hdbtdbArchivingServers-2.5.2
  • hdbtdbArchivingServers-2.5.1
  • hdbtdbArchivingServers-2.5.0
  • hdbtdbArchivingServers-2.4.9
  • hdbtdbArchivingServers-2.4.8
  • hdbtdbArchivingServers-2.4.7
  • hdbtdbArchivingServers-2.4.6
  • hdbtdbArchivingServers-2.4.5
22 results

pom.xml

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    FofbTool 4.00 KiB
    #!/usr/bin/env python
    ###################################################################################################
    #   COMMAND LINE INTERFACE
    ###################################################################################################
    #
    # This file gives the Command Line Interface for FofbTool
    #
    ###################################################################################################
    
    if __name__ == '__main__':
        import logging
        import argparse
        import os
        import sys
    
        # Safer import: add the parent dir in path
        sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
        import FofbTool.Utils
        import FofbTool.Configuration # Still needs for one function, TODO
    
    
        # Get the module logger
        logger = logging.getLogger("FofbTool")
    
        # Add a Stream handler to the module logger
        sh=logging.StreamHandler()
        sh.setLevel(logging.DEBUG)
        sh.setFormatter(logging.Formatter("{levelname:8}: {message}", style='{'))
        logger.addHandler(sh)
    
        parser = argparse.ArgumentParser("FofbTool")
        parser.add_argument("--log", default="info",
                help="Log level (error, warning, info, debug)")
    
        parser.add_argument("--conf-file", type=str,
                help="Path to config file to apply.")
    
        parser.add_argument("--DS-init-opcua", action="store_true",
                help="Run init on opcua devices.")
        parser.add_argument("--DS-init-watcher", action="store_true",
                help="Run init on the Fofb-Watcher device, and then the Fofb-Command.")
        parser.add_argument("--DS-conf", action="store_true",
                help="Applying attribute configuration on Tango Device Servers. This is required after restart of devices.")
    
        parser.add_argument("--stop", action="store_true",
                help="Stop command for the CCN and ComBPM applications blocks.")
        parser.add_argument("--stop-combpm", action="store_true",
                help="Stop command for the ComBPM applications blocks.")
        parser.add_argument("--stop-ccn", action="store_true",
                help="Stop command for the ComBPM applications blocks.")
    
        parser.add_argument("--configure", choices=["combpm", "ccn", "comcorr", "corr", "all", "every"], nargs="+",
                help="Configuration commands for the Fofb applications blocs."+
                " 'all' is for all com, not configuring corrector. 'every' configure everything.")
    
        parser.add_argument("--start", action="store_true",
                help="Start command for the CCN and ComBPM applications blocks.")
        parser.add_argument("--start-combpm", action="store_true",
                help="Start command for the ComBPM applications blocks.")
        parser.add_argument("--start-ccn", action="store_true",
                help="Start command for the ComBPM applications blocks.")
    
    
        args = parser.parse_args()
    
        # Set log level from args
        logger.setLevel(getattr(logging, args.log.upper()))
    
        logger.debug(args)
    
        if "conf_file" in args:
            FofbTool.Configuration.loadconfig(args.conf_file)
        FofbTool.Configuration.logdebugconf()
    
        ## Device Server related commands
        if args.DS_init_opcua:
            FofbTool.Utils.init_opcua()
    
        if args.DS_init_watcher:
            FofbTool.Utils.init_watcher()
    
        if args.DS_conf:
            FofbTool.Utils.confds_opcua()
    
        if args.stop or args.stop_combpm:
            FofbTool.Utils.stop_all_combpm()
        if args.stop or args.stop_ccn:
            FofbTool.Utils.stop_all_ccn()
    
        if not args.configure is None:
            for conf in args.configure:
                if conf in ("combpm", "all", "every"):
                    FofbTool.Utils.conf_all_combpm()
                if conf in ("comcorr", "all", "every"):
                    FofbTool.Utils.conf_all_comcorr()
                if conf in ("ccn", "all", "every"):
                    FofbTool.Utils.conf_all_ccn()
                if conf in ("corr", "every"):
                    FofbTool.Configuration.centralnode_configure_corr()
    
        if args.start or args.start_combpm:
            FofbTool.Utils.start_all_combpm()
        if args.start or args.start_ccn:
            FofbTool.Utils.start_all_ccn()