예제 #1
0
def manage(config):
    """django's manage wrapper to take care of the configuration"""
    from pytheon.utils import Config
    config = Config.from_file(config)
    config = dict(config['app:main'].items())
    settings = django_settings(config)
    from django.core.management import execute_manager
    execute_manager(settings)
예제 #2
0
파일: commands.py 프로젝트: pytheon/pytheon
def create(parser, options, args):
    """create your pytheon project"""
    binary = utils.vcs_binary()

    global_config = utils.user_config()
    if not os.path.isfile(global_config._filename):
        global_config.pytheon = dict(
                username=options.username or utils.get_input('Username'),
            )
        global_config.write()
    rc = global_config.pytheon

    config = utils.project_config(filename=options.buildout)
    if not os.path.isfile(config._filename):
        if not options.project_name:
            options.project_name = utils.get_input('Project name',
                           default=os.path.basename(os.getcwd()))
        config.deploy = dict(
                version='1',
                use='gunicorn',
                project_name=options.project_name,
            )
    if options.project_name:
        config.deploy.project_name = options.project_name
    config.write()

    kw = dict(username=rc.username, project_name=config.deploy.project_name)
    if binary == 'git':
        remote = os.environ.get('PYTHEON_REMOTE',
                        '[email protected]:%(project_name)s.git').rstrip('/')
        remote = remote % kw
        utils.call(binary, 'remote', 'add', 'pytheon', remote, silent=True)

    else:
        remote = os.environ.get('PYTHEON_REMOTE',
                        '[email protected]/%(project_name)s').rstrip('/')
        remote = remote % kw
        filename = '.hg/hgrc'
        config = Config.from_file(filename)
        config.paths.pytheon = remote
        config.write()

    commit(binary, config._filename)

    return http.request('/v1/applications', name=config.deploy.project_name)
예제 #3
0
__all__ = ("CONFIG", "Config", "utils", "log")

ETC_DIR = os.path.join(os.environ.get("PYTHEON_PREFIX", "/"), "etc", "pytheon")


EGGS_DIR = os.environ.get("PYTHEON_EGGS_DIR", None)

if not EGGS_DIR:
    for dirname in ("/var/share", "/var/lib"):
        dirname = os.path.join(dirname, "pytheon", "eggs")
        if os.path.isdir(dirname):
            EGGS_DIR = dirname

if not EGGS_DIR or not os.path.isdir(EGGS_DIR):
    cfg = Config.from_file(os.path.expanduser(join("~", ".buildout", "default.cfg")))
    EGGS_DIR = cfg.buildout["eggs-directory"] or None

if not EGGS_DIR or not os.path.isdir(EGGS_DIR):
    raise OSError("Can't find pytheon eggs directory")

defaults = dict([("default_%s" % k[8:].lower(), v) for k, v in os.environ.items() if k.startswith("PYTHEON_")])
defaults["here"] = ETC_DIR
defaults["default_eggs_dir"] = EGGS_DIR
os.environ["PYTHON_EGGS"] = EGGS_DIR

if not os.path.isdir(ETC_DIR):
    CONFIG = Config(defaults=defaults)
    CONFIG.pytheon = dict(eggs_dir=EGGS_DIR)
else:
    CONFIG = Config.from_file(join(ETC_DIR, "pytheon.ini"), **defaults)