<commit_before>"""Helper functions used in views"""
import os
import tempfile
import logging
import yaml

from pyramid.response import Response

from libcloud.compute.types import Provider
from libcloud.compute.types import NodeState
from libcloud.compute.providers import get_driver
from libcloud.compute.base import Node
from libcloud.compute.types import Provider

from fabric.api import env
from fabric.api import run

from mist.io.config import EC2_PROVIDERS, COMMAND_TIMEOUT


log = logging.getLogger('mist.io')


def load_settings(settings):
    """Gets settings from settings.yaml local file.

    The settings argument gets updated. It is the global_config of pyramid. If
    there is no such file, it creates one for later use and sets some sensible
    defaults without writing them in file.
    """
    try:
        config_file = open('settings.yaml', 'r')
    except IOError:
        log.warn('settings.yaml does not exist.')
        config_file = open('settings.yaml', 'w')
        config_file.close()<commit_msg>add default curl ca-bundle path in CA_CERTS_PATH<commit_after>"""Helper functions used in views"""
import os
import tempfile
import logging
import yaml

from pyramid.response import Response

from libcloud.compute.types import Provider
from libcloud.compute.types import NodeState
from libcloud.compute.providers import get_driver
from libcloud.compute.base import Node
from libcloud.compute.types import Provider

from fabric.api import env
from fabric.api import run

from mist.io.config import EC2_PROVIDERS, COMMAND_TIMEOUT

# add curl ca-bundle default path to prevent libcloud certificate error
import libcloud.security
libcloud.security.CA_CERTS_PATH.append('/usr/share/curl/ca-bundle.crt')

log = logging.getLogger('mist.io')


def load_settings(settings):
    """Gets settings from settings.yaml local file.

    The settings argument gets updated. It is the global_config of pyramid. If
    there is no such file, it creates one for later use and sets some sensible
    defaults without writing them in file.
    """
    try:
        config_file = open('settings.yaml', 'r')
    except IOError:
        log.warn('settings.yaml does not exist.')
        config_file = open('settings.yaml', 'w')
        config_file.close()
{'fraction_non_alphanumeric': 0.07573073516386182, 'fraction_numerical': 0.0008857395925597874, 'mean_word_length': 4.053691275167785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4083675', 'n_tokens_mistral': 632, 'n_tokens_neox': 607, 'n_words': 232}