Skip to content

Instantly share code, notes, and snippets.

@rema7
Last active October 4, 2017 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rema7/fbffcd4601c4edb841f1f1be5627c4d8 to your computer and use it in GitHub Desktop.
Save rema7/fbffcd4601c4edb841f1f1be5627c4d8 to your computer and use it in GitHub Desktop.
import os
from invoke import task, Collection
import settings as app_settings
LOCAL_SETTINGS = 'settings_local.py'
@task
def init_config(ctx, db_connection, silent=False):
settings_local = '''
DB_CONNECTION = '{db_connection}'
'''.format(db_connection=db_connection)
settings_local_path = os.path.join(
app_settings.PROJECT_ROOT, LOCAL_SETTINGS)
if os.path.isfile(settings_local_path):
if silent:
exit(0)
print('{} already exists'.format(LOCAL_SETTINGS))
exit(1)
with open(settings_local_path, 'w') as settings_file:
settings_file.write(settings_local)
ns = Collection()
ns.add_task(init_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment