diff options
author | mahesh | 2017-03-20 17:04:46 +0530 |
---|---|---|
committer | mahesh | 2017-03-20 17:04:46 +0530 |
commit | b5daabb45621ac47c98382303800cb7a240827c2 (patch) | |
tree | f3369879e3170a2a5e831fe6763a4615d27e2bec /yaksh/scripts/cli.py | |
parent | ac292ed1099b49f9d0e8a7ed3699bacdd8031de3 (diff) | |
parent | 23ecd8fa33e7fa2e953aa9715ae45a2869a044a0 (diff) | |
download | online_test-b5daabb45621ac47c98382303800cb7a240827c2.tar.gz online_test-b5daabb45621ac47c98382303800cb7a240827c2.tar.bz2 online_test-b5daabb45621ac47c98382303800cb7a240827c2.zip |
Merge branch 'master' of https://github.com/fossee/online_test into fill_in_the_blanks
Diffstat (limited to 'yaksh/scripts/cli.py')
-rw-r--r-- | yaksh/scripts/cli.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/yaksh/scripts/cli.py b/yaksh/scripts/cli.py index 4a58e48..a1a49ee 100644 --- a/yaksh/scripts/cli.py +++ b/yaksh/scripts/cli.py @@ -101,10 +101,6 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR): 'fixture_dir': fixture_dir}) urls_template_path = path.join(TEMPLATE_DIR, 'demo_urls.py') urls_target_path = path.join(project_path, 'demo_urls.py') - command = ("python ../manage.py migrate --run-syncdb " - "--noinput --settings={0}.demo_settings").format( - project_name) - loaddata_command = ("python ../manage.py loaddata " "--settings={0}.demo_settings {1}").format( project_name, fixture_path) @@ -115,14 +111,18 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR): ) # Create demo_urls file _render_demo_files(urls_template_path, urls_target_path) - # Run syncdb - subprocess.call( - "{0}; {1}".format(command, loaddata_command), shell=True - ) + # Create database and load initial data + command_path = path.join(top_dir, 'manage.py') + _check_migrations(project_name, command_path) + _migrate(project_name, command_path) + subprocess.call(loaddata_command, shell=True) def run_demo(project_name, top_dir): with _chdir(top_dir): + command_path = path.join(top_dir, 'manage.py') + _check_migrations(project_name, command_path) + _migrate(project_name, command_path) command = ("python manage.py runserver " "--settings={0}.demo_settings").format(project_name) subprocess.call(command, shell=True) @@ -136,6 +136,18 @@ def run_server(args=None): print("Error: {0}\nExiting yaksh code server".format(e)) +def _check_migrations(project_name, command_path): + migrations = ("python {0} makemigrations --settings={1}.demo_settings" + ).format(command_path, project_name) + subprocess.call(migrations, shell=True) + + +def _migrate(project_name, command_path): + migrate = ("python {0} migrate --settings={1}.demo_settings" + ).format(command_path, project_name) + subprocess.call(migrate, shell=True) + + def _render_demo_files(template_path, output_path, context=None): with open(template_path, 'r') as template_file: content = template_file.read() |