def update_environment()

in Modules/Azure/Scaffolding/Python/WebRole/wfastcgi.py [0:0]


def update_environment():
    cur_dir = path.dirname(path.dirname(__file__))
    web_config = path.join(cur_dir, 'Web.config')
    if os.path.exists(web_config):
        try:
            with file(web_config) as wc:
                doc = minidom.parse(wc)
                config = doc.getElementsByTagName('configuration')
                for configSection in config:
                    appSettings = configSection.getElementsByTagName('appSettings')
                    for appSettingsSection in appSettings:
                        values = appSettingsSection.getElementsByTagName('add')
                        for curAdd in values:
                            key = curAdd.getAttribute('key')
                            value = curAdd.getAttribute('value')
                            if key and value:
                                os.environ[key] = value
        except:
            # unable to read file
            log(traceback.format_exc())
            pass