def main(): if len(sys.argv) == 1: # default to local environment = 'local' else: environment = sys.argv[1] syncdb = 'python manage.py syncdb --traceback' if environment == 'local': open('_otree_experiments/db.sqlite3', 'w').write('') os.system(syncdb) # then launch from PyCharm else: # heroku if environment == 'production': confirmed = raw_input('Enter "y" if you are sure you want to reset the production database.').lower() == 'y' if not confirmed: print 'exit.' return reset_db = 'heroku pg:reset DATABASE --confirm {}'.format(heroku_apps[environment]) os.system(reset_db) commit_and_push.run(environment) heroku_run_command = 'heroku run {} --remote {}' syncdb = heroku_run_command.format(syncdb, environment) os.system(syncdb)
def main(): environment = sys.argv[1] syncdb = 'python manage.py syncdb --traceback' create_session = 'python manage.py create_session' if environment == 'local': open('{{ project_name }}/db.sqlite3', 'w').write('') os.system(syncdb) os.system(create_session) # then launch from PyCharm else: # heroku if environment == 'production': confirmed = raw_input('Enter "y" if you are sure you want to reset the production database.').lower() == 'y' if not confirmed: print 'exit.' return reset_db = 'heroku pg:reset DATABASE --confirm {}'.format(heroku_apps[environment]) os.system(reset_db) commit_and_push.run(environment) heroku_run_command = 'heroku run {} --remote {}' syncdb = heroku_run_command.format(syncdb, environment) create_session = heroku_run_command.format(create_session, environment) os.system(syncdb) print create_session os.system(create_session)
def main(): environment = sys.argv[1] num_participants = 50 app_name = 'your_app_name_here' syncdb = 'python manage.py syncdb' create_objects = 'python manage.py create_objects --app_name={} --participants={}'.format(app_name, num_participants) if environment == 'local': open('ptree_experiments/db.sqlite3', 'w').write('') os.system(syncdb) os.system(create_objects) # then launch from PyCharm else: # heroku if environment == 'production': confirmed = raw_input('Enter "y" to confirm deletion of your production database').lower() == 'y' if not confirmed: sys.exit(0) # replace the below app names with your heroku app names heroku_apps = {'dev': 'heroku-app-name-dev', 'staging': 'heroku-app-name-staging', 'production': 'heroku-app-name-production'} reset_db = 'heroku pg:reset DATABASE --confirm {}'.format(heroku_apps[environment]) os.system(reset_db) commit_and_push.run(environment) heroku_run_command = 'heroku run {} --remote {}' syncdb = heroku_run_command.format(syncdb, environment) create_objects = heroku_run_command.format(create_objects, environment) os.system(syncdb) os.system(create_objects)