def bucket_delete(c):
    """Deletes the S3 bucket used to host the site"""
    if not confirm("Are you sure you want to delete the bucket %r?" % BUCKET_NAME):
        print('Aborting at user request.')
        exit(1)
    conn = connect_s3(calling_format=BUCKET_CALLING_FORMAT)
    conn.delete_bucket(BUCKET_NAME)
    print('Bucket %r deleted.' % BUCKET_NAME)
Exemple #2
0
def deploy(ctx, env=ENV_DEV, db_url=DEFAULT_DB_URL):
    check_envs(env)
    """ Command: $ fab deploy env db_url """

    if not confirm('Deploy to {} ?'.format(env)):
        raise Exit
    clone_git_src(ctx)
    create_env_file(ctx, env, db_url)

    collect_static(ctx)
    migrate(ctx)
    create_django_su(ctx)
Exemple #3
0
def create_env_file(ctx, env, db_url):
    check_envs(env)
    is_env_file_exists = not ctx.run('test -e {}'.format(ENV_FILE_PATH), warn=True)
    if is_env_file_exists and not confirm('Environment file already exists. Do you want to rewrite it?', assume_yes=False):
        return
    if is_env_file_exists:
        ctx.run('mv {} {}.bak'.format(ENV_FILE_PATH))
    ctx.run('echo export DJANGO_SECRET_KEY={} >> {}'
            .format(generate_django_secret_file(), ENV_FILE_PATH))
    ctx.run('echo export DJANGO_SETTINGS_MODULE={}{} >> {}'
            .format(ENV_DIR, '.settings', ENV_FILE_PATH))
    ctx.run('echo export DATABASE_URL={} >> {}'.format(db_url, ENV_FILE_PATH))
    if env == ENV_DEV:
        ctx.run('echo export DEBUG=True >> {}'.format(ENV_FILE_PATH))
        ctx.run('echo export DJANGO_CONFIGURATION={} >> {}'.format(ENV_DEV, ENV_FILE_PATH))
    elif env == ENV_TEST:
        ctx.run('echo export DEBUG=False >> {}'.format(ENV_FILE_PATH))
        ctx.run('echo export DJANGO_CONFIGURATION={} >> {}'.format(ENV_TEST, ENV_FILE_PATH))
    elif env == ENV_PROD:
        ctx.run('echo export DEBUG=False >> {}'.format(ENV_FILE_PATH))
        ctx.run('echo export DJANGO__CONFIGURATION={} >> {}'.format(ENV_PROD, ENV_FILE_PATH))
    sentry_dsn = input('Enter Sentry DSN: ')
    ctx.run('echo export SENTRY_DSN={} >> {}'.format(sentry_dsn, ENV_FILE_PATH))
Exemple #4
0
 def whitespace_is_trimmed(self, mock_input):
     assert confirm("Are you sure?") is True
Exemple #5
0
 def default_on_empty_response_is_False_if_assume_yes_False(
     self, mock_input
 ):
     assert confirm("Are you sure?", assume_yes=False) is False
Exemple #6
0
 def default_on_empty_response_is_True_by_default(self, mock_input):
     assert confirm("Are you sure?") is True
Exemple #7
0
 def suffix_changes_when_assume_yes_False(self, mock_input):
     confirm("Are you sure?", assume_yes=False)
     assert mock_input.call_args[0][0] == "Are you sure? [y/N] "
Exemple #8
0
 def reprompts_on_bad_input(self, mock_input):
     assert confirm("O rly?") is True
     assert "I didn't understand you" in sys.stderr.getvalue()
Exemple #9
0
 def returns_False_for_nolike_responses(self, mock_input):
     for value in ("n", "N", "no", "NO", "nO", "No"):
         mock_input.return_value = value
         assert confirm("Meh") is False
Exemple #10
0
 def returns_True_for_yeslike_responses(self, mock_input):
     for value in ("y", "Y", "yes", "YES", "yES", "Yes"):
         mock_input.return_value = value
         assert confirm("Meh") is True
Exemple #11
0
 def displays_question_with_yes_no_suffix(self, mock_input):
     confirm("Are you sure?")
     assert mock_input.call_args[0][0] == "Are you sure? [Y/n] "
Exemple #12
0
 def reprompts_on_bad_input(self, mock_input):
     ok_(confirm("O rly?") is True)
     assert_contains(sys.stderr.getvalue(), "I didn't understand you")
Exemple #13
0
 def returns_False_for_nolike_responses(self, mock_input):
     for value in ('n', 'N', 'no', 'NO', 'nO', 'No'):
         mock_input.return_value = value
         ok_(confirm("Meh") is False)
Exemple #14
0
 def returns_True_for_yeslike_responses(self, mock_input):
     for value in ('y', 'Y', 'yes', 'YES', 'yES', 'Yes'):
         mock_input.return_value = value
         ok_(confirm("Meh") is True)