src/wiotp/sdk/application/config.py
def parseConfigFile(configFilePath):
    """
    Parse a yaml configuration file into a Python dictionary suitable for passing to the 
    device client constructor as the `options` parameter
    
    # Example Configuration File
    
    identity:
      appId: myApp
    auth:
      key: a-23gh56-sdsdajhjnee
      token: Ab$76s)asj8_s5
    options:
      domain: internetofthings.ibmcloud.com
      logLevel: error|warning|info|debug
      mqtt:
        port: 8883
        transport: tcp
        cleanStart: false
        sessionExpiry: 3600
        keepAlive: 60
        sharedSubscription: false
        caFile: /path/to/certificateAuthorityFile.pem
      http:
        verify: true    
    """

    try:
        with open(configFilePath) as f:
            data = yaml.load(f)
    except (OSError, IOError) as e:
        # In 3.3, IOError became an alias for OSError, and FileNotFoundError is a subclass of OSError
        reason = "Error reading device configuration file '%s' (%s)" % (configFilePath, e)
        raise ConfigurationException(reason)

    if "options" in data and "logLevel" in data["options"]:
        if data["options"]["logLevel"] not in ["error", "warning", "info", "debug"]:
            raise ConfigurationException("Optional setting options.logLevel must be one of error, warning, info, debug")
        else:
            # Convert log levels from string to int (we need to upper case our strings from the config)
            data["options"]["logLevel"] = logging.getLevelName(data["options"]["logLevel"].upper())

    return data
def parseConfigFile(configFilePath):
    """
    Parse a yaml configuration file into a Python dictionary suitable for passing to the 
    device client constructor as the `options` parameter
    
    # Example Configuration File
    
    identity:
      appId: myApp
    auth:
      key: a-23gh56-sdsdajhjnee
      token: Ab$76s)asj8_s5
    options:
      domain: internetofthings.ibmcloud.com
      logLevel: error|warning|info|debug
      mqtt:
        port: 8883
        transport: tcp
        cleanStart: false
        sessionExpiry: 3600
        keepAlive: 60
        sharedSubscription: false
        caFile: /path/to/certificateAuthorityFile.pem
      http:
        verify: true    
    """

    try:
        with open(configFilePath) as f:
            data = yaml.load(f)
    except (OSError, IOError) as e:
        # In 3.3, IOError became an alias for OSError, and FileNotFoundError is a subclass of OSError
        reason = "Error reading device configuration file '%s' (%s)" % (configFilePath, e)
        raise ConfigurationException(reason)

    if "options" in data and "logLevel" in data["options"]:
        if data["options"]["logLevel"] not in ["error", "warning", "info", "debug"]:
            raise ConfigurationException("Optional setting options.logLevel must be one of error, warning, info, debug")
        else:
            # Convert log levels from string to int (we need to upper case our strings from the config)
            data["options"]["logLevel"] = logging.getLevelName(data["options"]["logLevel"].upper())

    return data
Parse a yaml configuration file into a Python dictionary suitable for passing to the 
    device client constructor as the `options` parameter
    
    # Example Configuration File
    
    identity:
      appId: myApp
    auth:
      key: a-23gh56-sdsdajhjnee
      token: Ab$76s)asj8_s5
    options:
      domain: internetofthings.ibmcloud.com
      logLevel: error|warning|info|debug
      mqtt:
        port: 8883
        transport: tcp
        cleanStart: false
        sessionExpiry: 3600
        keepAlive: 60
        sharedSubscription: false
        caFile: /path/to/certificateAuthorityFile.pem
      http:
        verify: true