Esempio n. 1
0
 def proc_kwargs(self, **kwargs):
     print_kwargs(kwargs)
     loglevel   = kwargs.get('loglevel', 'DEBUG').upper()
     logdir     = kwargs.get('logdir', './')
     savelog    = kwargs.get('savelog', False)
     if is_in_command_line('-l', '--loglevel'): cp.log_level.setValue(loglevel)
     cp.log_prefix.setValue(logdir)
     cp.save_log_at_exit.setValue(savelog)
Esempio n. 2
0
    def unpack(self, parser):
        """parser parameters:
          -  host      
          -  port      
          -  experiment
          -  detector  
          -  ctype     
          -  run       
          -  run_end       
          -  time_stamp
          -  time_sec
          -  version   
          -  iofname
          -  comment
          -  dbname
        """
        (popts, pargs) = parser.parse_args()
        #args = pargs
        #defs = vars(parser.get_default_values())

        self.mode = mode = pargs[0] if len(pargs) > 0 else 'print'

        kwargs = vars(popts)

        time_sec, time_stamp = dbu.time_and_timestamp(**kwargs)
        kwargs['time_sec'] = int(time_sec)
        kwargs['time_stamp'] = time_stamp
        kwargs['cli_mode'] = mode

        self.kwargs = kwargs
        self.defs = vars(parser.get_default_values())

        self.loglevel = kwargs.get('loglevel', 'DEBUG').upper()

        fmt = '%(asctime)s %(name)s %(lineno)d %(levelname)s: %(message)s'
        config_logger(loglevel=self.loglevel, fmt=fmt)

        if self.loglevel == 'DEBUG':
            from psana.pyalgos.generic.Utils import print_kwargs, print_parser
            print(40 * '_')
            print_parser(parser)
            print_kwargs(kwargs)
            fmt = '%(asctime)s %(name)s %(lineno)d %(levelname)s: %(message)s'
Esempio n. 3
0
    def proc_parser(self, parser=None):
        self.parser = parser

        if parser is None:
            return

        (popts, pargs) = parser.parse_args()
        self.args = pargs
        self.opts = vars(popts)
        self.defs = vars(parser.get_default_values())

        host = popts.host  # self.opts['host']
        port = popts.port  # self.opts['port']
        cp.user = popts.user
        cp.upwd = popts.upwd
        exp = popts.experiment
        det = popts.detector
        loglevel = popts.loglevel.upper()
        logdir = popts.logdir

        #if host     != self.defs['host']       : cp.cdb_host.setValue(host)
        #if port     != self.defs['port']       : cp.cdb_port.setValue(port)
        #if exp      != self.defs['experiment'] : cp.exp_name.setValue(exp)
        #if det      != self.defs['detector']   : cp.data_source.setValue(det)
        #if loglevel != self.defs['loglevel']   : cp.log_level.setValue(loglevel)
        #if logdir   != self.defs['logdir']     : cp.log_prefix.setValue(logdir)

        if is_in_command_line(None, '--host'): cp.cdb_host.setValue(host)
        if is_in_command_line(None, '--port'): cp.cdb_port.setValue(port)
        if is_in_command_line('-e', '--experiment'): cp.exp_name.setValue(exp)
        if is_in_command_line('-d', '--detector'): cp.data_source.setValue(det)
        if is_in_command_line('-l', '--loglevel'):
            cp.log_level.setValue(loglevel)
        if is_in_command_line('-L', '--logdir'): cp.log_prefix.setValue(logdir)

        if loglevel == 'DEBUG':
            print(40 * '_')
            print_parser(parser)
            print_kwargs(self.opts)
Esempio n. 4
0
    def unpack(self, parser):
        """parser parameters:
          -  host      
          -  port      
          -  experiment
          -  detector  
          -  ctype     
          -  run       
          -  run_end       
          -  time_stamp
          -  time_sec
          -  version   
          -  iofname
          -  comment
          -  dbname
        """
        (popts, pargs) = parser.parse_args()
        #args = pargs
        #opts = vars(popts)
        #defs = vars(parser.get_default_values())
        #host = kwargs.get('host', None),

        self.mode = mode = pargs[0] if len(pargs) > 0 else 'print'

        kwargs = vars(popts)

        time_sec, time_stamp = dbu.time_and_timestamp(**kwargs)
        kwargs['time_sec'] = str(time_sec)
        kwargs['time_stamp'] = time_stamp

        self.kwargs = kwargs
        self.defs = vars(parser.get_default_values())

        print_parser(parser)
        print_kwargs(kwargs)

        level = kwargs.get('loglevel', 'DEBUG')
        config_logger(loglevel=level)
Esempio n. 5
0
    def proc_opts(self, **opts):

        host = opts.get('host', None)  # self.opts['host']
        port = opts.get('port', None)  # self.opts['port']
        cp.user = opts.get('user', None)
        cp.upwd = opts.get('upwd', None)
        exp = opts.get('experiment', None)
        det = opts.get('detector', None)
        logdir = opts.get('logdir', None)
        loglevel = opts.get('loglevel', None).upper()
        if isinstance(loglevel, str): loglevel = loglevel.upper()

        if is_in_command_line(None, '--host'): cp.cdb_host.setValue(host)
        if is_in_command_line(None, '--port'): cp.cdb_port.setValue(port)
        if is_in_command_line('-e', '--experiment'): cp.exp_name.setValue(exp)
        if is_in_command_line('-d', '--detector'): cp.data_source.setValue(det)
        if is_in_command_line('-l', '--loglevel'):
            cp.log_level.setValue(loglevel)
        if is_in_command_line('-L', '--logdir'): cp.log_prefix.setValue(logdir)

        if loglevel == 'DEBUG':
            print(40 * '_')
            print_kwargs(opts)
            exit('TEST EXIT')