Last active
October 4, 2017 11:58
-
-
Save rema7/fbffcd4601c4edb841f1f1be5627c4d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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