Exemplo n.º 1
0
    def get_stn_info(self, config_dict, options):
        """Build the stn_info structure. Extract first from the config_dict object,
        then from any command-line overrides, then use defaults, then prompt the user
        for values."""

        # Start with values from the config file:
        stn_info = weecfg.get_station_info(config_dict)

        # Get command line overrides, and apply them to stn_info. If that leaves a value
        # unspecified, then get it from the defaults.
        for k in stn_info_defaults:
            # Override only if the option exists and is not None:
            if hasattr(options, k) and getattr(options, k) is not None:
                stn_info[k] = getattr(options, k)
            elif k not in stn_info:
                # Value is still not specified. Get a default value
                stn_info[k] = stn_info_defaults[k]

        # Unless --no-prompt has been specified, give the user a chance
        # to change things:
        if not options.no_prompt:
            prompt_info = weecfg.prompt_for_info(**stn_info)
            stn_info.update(prompt_info)
            driver = weecfg.prompt_for_driver(stn_info.get('driver'))
            stn_info['driver'] = driver
            stn_info.update(weecfg.prompt_for_driver_settings(driver, config_dict))

        return stn_info
Exemplo n.º 2
0
    def get_stn_info(self, config_dict, options):
        """Build the stn_info structure. This generally contains stuff
        that can be injected into the config_dict."""

        # Start with values from the config file:
        stn_info = weecfg.get_station_info(config_dict)

        # Get command line overrides, and apply them to stn_info:
        for k in stn_info:
            # Override only if the option exists and is not None:
            if hasattr(options, k) and getattr(options, k) is not None:
                stn_info[k] = getattr(options, k)

        # If any are still None, use defaults:
        for k in stn_info_defaults:
            if k not in stn_info or stn_info[k] is None:
                if hasattr(options, k) and getattr(options, k) is not None:
                    stn_info[k] = getattr(options, k)
                else:
                    stn_info[k] = stn_info_defaults[k]

        # Unless --no-prompt has been specified, give the user a chance
        # to change things:
        if not options.no_prompt:
            stn_info.update(weecfg.prompt_for_info(**stn_info))
            driver = weecfg.prompt_for_driver(stn_info.get('driver'))
            stn_info['driver'] = driver
            stn_info.update(
                weecfg.prompt_for_driver_settings(driver, config_dict))

        return stn_info
Exemplo n.º 3
0
    def get_stn_info(self, config_dict, options):
        """Build the stn_info structure. This generally contains stuff
        that can be injected into the config_dict."""

        # Start with values from the config file:
        stn_info = weecfg.get_station_info(config_dict)

        # Get command line overrides, and apply them to stn_info:
        for k in stn_info:
            # Override only if the option exists and is not None:
            if hasattr(options, k) and getattr(options, k) is not None:
                stn_info[k] = getattr(options, k)

        # If any are still None, use defaults:
        for k in stn_info_defaults:
            if k not in stn_info or stn_info[k] is None:
                if hasattr(options, k) and getattr(options, k) is not None:
                    stn_info[k] = getattr(options, k)
                else:
                    stn_info[k] = stn_info_defaults[k]

        # Unless --no-prompt has been specified, give the user a chance
        # to change things:
        if not options.no_prompt:
            stn_info.update(weecfg.prompt_for_info(**stn_info))
            driver = weecfg.prompt_for_driver(stn_info.get('driver'))
            stn_info['driver'] = driver
            stn_info.update(weecfg.prompt_for_driver_settings(driver))

        return stn_info