Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def deploy(parser, options, args, config):
    """Deploy current repository to pytheon"""

    binary = utils.vcs_binary()

    if binary == 'git':
        state = utils.call(binary, 'status', '-s', silent=True)
    else:
        state = utils.call(binary, 'status', silent=True)
    if state:
        parser.error('You have some uncommited changes. Deploy aborted.')

    for filename in ('buildout.cfg', 'deploy.ini'):
        if os.path.isfile(filename):
            break

    if binary == 'git':
        utils.call('git', 'push', 'pytheon', 'master')
    else:
        utils.call('hg', 'push', 'pytheon')

    log.info('Deploy success')