Ejemplo n.º 1
0
Archivo: app.py Proyecto: peval/faraday
def setup_storage_path():
    default_path = join(expanduser("~"), '.faraday/storage')
    if not os.path.exists(default_path):
        logger.info('Creating directory {0}'.format(default_path))
        os.mkdir(default_path)
    config = ConfigParser()
    config.read(server.config.LOCAL_CONFIG_FILE)
    config.add_section('storage')
    config.set('storage', 'path', default_path)
    with open(server.config.LOCAL_CONFIG_FILE, 'w') as configfile:
        config.write(configfile)

    return default_path
Ejemplo n.º 2
0
def setup_storage_path():
    default_path = join(expanduser("~"), '.faraday/storage')
    if not os.path.exists(default_path):
        logger.info('Creating directory {0}'.format(default_path))
        os.mkdir(default_path)
    config = ConfigParser()
    config.read(server.config.LOCAL_CONFIG_FILE)
    config.add_section('storage')
    config.set('storage', 'path', default_path)
    with open(server.config.LOCAL_CONFIG_FILE, 'w') as configfile:
        config.write(configfile)

    return default_path
Ejemplo n.º 3
0
def save_new_secret_key(app):
    if not os.path.exists(LOCAL_CONFIG_FILE):
        copy_default_config_to_local()
    config = ConfigParser()
    config.read(LOCAL_CONFIG_FILE)
    rng = SystemRandom()
    secret_key = "".join([rng.choice(string.ascii_letters + string.digits) for _ in range(25)])
    app.config['SECRET_KEY'] = secret_key
    try:
        config.set('faraday_server', 'secret_key', secret_key)
    except NoSectionError:
        config.add_section('faraday_server')
        config.set('faraday_server', 'secret_key', secret_key)
    with open(LOCAL_CONFIG_FILE, 'w') as configfile:
        config.write(configfile)
Ejemplo n.º 4
0
    def _check_current_config(self, config):
        try:
            config.get('database', 'connection_string')
            reconfigure = None
            while not reconfigure:
                reconfigure = raw_input('Database section {yellow} already found{white}. Do you want to reconfigure database? (yes/no) '.format(yellow=Fore.YELLOW, white=Fore.WHITE))
                if reconfigure.lower() == 'no':
                    return False
                elif reconfigure.lower() == 'yes':
                   continue
                else:
                    reconfigure = None
        except NoSectionError:
            config.add_section('database')

        return True
Ejemplo n.º 5
0
    def _check_current_config(self, config):
        try:
            config.get('database', 'connection_string')
            reconfigure = None
            while not reconfigure:
                reconfigure = raw_input('Database section {yellow} already found{white}. Do you want to reconfigure database? (yes/no) '.format(yellow=Fore.YELLOW, white=Fore.WHITE))
                if reconfigure.lower() == 'no':
                    return False
                elif reconfigure.lower() == 'yes':
                   continue
                else:
                    reconfigure = None
        except NoSectionError:
            config.add_section('database')

        return True
Ejemplo n.º 6
0
def save_new_secret_key(app):
    if not os.path.exists(LOCAL_CONFIG_FILE):
        copy_default_config_to_local()
    config = ConfigParser()
    config.read(LOCAL_CONFIG_FILE)
    rng = SystemRandom()
    secret_key = "".join(
        [rng.choice(string.ascii_letters + string.digits) for _ in range(25)])
    app.config['SECRET_KEY'] = secret_key
    try:
        config.set('faraday_server', 'secret_key', secret_key)
    except NoSectionError:
        config.add_section('faraday_server')
        config.set('faraday_server', 'secret_key', secret_key)
    with open(LOCAL_CONFIG_FILE, 'w') as configfile:
        config.write(configfile)