Skip to content
Permalink
Browse files
Add support for cloud profiles in config, closes #7
  • Loading branch information
brogand93 committed Jun 22, 2014
1 parent 95fd991 commit d0cb4ffab4873f5fa904c4a90214e7852d9e0987
Showing 2 changed files with 42 additions and 4 deletions.
@@ -19,13 +19,29 @@

import os
import sys
import argparse

from flask import Flask
from ConfigParser import SafeConfigParser

from gstack.core import db


def _generate_args():
parser = argparse.ArgumentParser()

parser.add_argument(
'profile',
help='The profile to run gstack with, default is initial',
default='initial',
nargs='?'
)

args = parser.parse_args()

return vars(args)


def _load_config_file():
config_file = os.path.join(
os.path.expanduser('~'),
@@ -49,7 +65,7 @@ def _load_database():
return 'sqlite:///' + database_file


def _config_from_config_profile(config_file, profile='initial'):
def _config_from_config_profile(config_file, profile):
config = SafeConfigParser()
config.read(config_file)

@@ -65,9 +81,11 @@ def configure_app(settings=None):
if settings:
app.config.from_object(settings)
else:
args = _generate_args()
profile = args.pop('profile')
config_file = _load_config_file()
database_uri = _load_database()
_config_from_config_profile(config_file)
_config_from_config_profile(config_file, profile)
app.config['SQLALCHEMY_DATABASE_URI'] = database_uri


@@ -18,6 +18,7 @@


import os
import argparse
import ConfigParser

from alembic import command
@@ -39,13 +40,32 @@ def _create_config_folder():


def _create_config_file(config_folder):
args = _generate_args()
profile = args.pop('profile')
config_file_path = config_folder + '/gstack.conf'
config = _modify_config_profile(config_file_path)
config = _modify_config_profile(config_file_path, profile)
config_file = open(config_file_path, 'w+')
config.write(config_file)


def _modify_config_profile(config_file, profile='initial'):
def _generate_args():
parser = argparse.ArgumentParser(
'Command line utility for configuring gstack'
)

parser.add_argument(
'profile',
help='The profile to configure, default is initial',
default='initial',
nargs='?'
)

args = parser.parse_args()

return vars(args)


def _modify_config_profile(config_file, profile):
config = ConfigParser.SafeConfigParser()
config.read(config_file)

0 comments on commit d0cb4ff

Please sign in to comment.