From cf9281472dd18d5d2a7ca8b45cbb3e18079773aa Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Thu, 6 Aug 2015 11:11:48 +0300 Subject: [PATCH 01/18] Test for DATABASES in settings --- tests/django.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/django.py b/tests/django.py index 81fcb26..fa829d6 100644 --- a/tests/django.py +++ b/tests/django.py @@ -4,6 +4,7 @@ import re import sqlite3 import sys +import textwrap from djangocms_installer import config, django, install from djangocms_installer.config.settings import (MIGRATION_MODULES_BASE, @@ -534,3 +535,22 @@ def test_database_setup(self): query = project_db.execute('SELECT * FROM auth_user') self.assertTrue(query) + +class TestBaseDjango(unittest.TestCase): + def test_build_settings(self): + """Tests django.__init__._build_settings function.""" + config_data = config.parse(['--db=postgres://user:pwd@host:5432/dbname', + '--cms-version=stable', '--django=%s' % dj_ver, + '-q', '-p .', 'example_prj']) + settings = django._build_settings(config_data) + self.assertTrue(textwrap.dedent(''' + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'HOST': 'host', + 'NAME': 'dbname', + 'PASSWORD': 'pwd', + 'PORT': '5432', + 'USER': 'user' + } + }''').strip() in settings) From 844164ca3e972216bcf34758a6843786f997c290 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Thu, 6 Aug 2015 11:13:25 +0300 Subject: [PATCH 02/18] Set DATABASES to multiline to be more readable --- djangocms_installer/django/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 133c8b1..61c1193 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -12,6 +12,7 @@ import subprocess import sys import tempfile +import textwrap import zipfile from six import BytesIO @@ -329,7 +330,12 @@ def _build_settings(config_data): text.append("CMS_PERMISSION = %s" % vars.CMS_PERMISSION) text.append("CMS_PLACEHOLDER_CONF = %s" % vars.CMS_PLACEHOLDER_CONF) - text.append("DATABASES = {\n%s'default':\n%s%s\n}" % (spacer, spacer * 2, config_data.db_parsed)) + text.append(textwrap.dedent(""" + DATABASES = { + 'default': { + %s + } + }""").strip() % (",\n" + spacer * 2).join(["'%s': '%s'" % (key, val) for key, val in sorted(config_data.db_parsed.items(), key=lambda x: x[0])])) if config_data.django_version >= 1.7: text.append("MIGRATION_MODULES = {\n%s%s\n}" % ( From 0db7858c9c0d332493e3ae65c888910a5f5d4846 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 8 Aug 2015 10:41:55 +0200 Subject: [PATCH 03/18] Update Django supported versions --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 4815ae2..8d1d37e 100644 --- a/README.rst +++ b/README.rst @@ -67,9 +67,9 @@ The current supported version matrix is the following: +----------------+-------------+-------------+-------------+-------------+-------------+ | django CMS 3.0 | Supported | Supported | Supported | Supported | Unsupported | +----------------+-------------+-------------+-------------+-------------+-------------+ -| django CMS 3.1 | Unsupported | Unsupported | Supported | Supported | WiP | +| django CMS 3.1 | Unsupported | Unsupported | Supported | Supported | Supported | +----------------+-------------+-------------+-------------+-------------+-------------+ -| django CMS dev | Unsupported | Unsupported | Supported | Supported | WiP | +| django CMS dev | Unsupported | Unsupported | Supported | Supported | Supported | +----------------+-------------+-------------+-------------+-------------+-------------+ Any beta and develop version of Django and django CMS, by its very nature, From 3a70aabf8c5af943fed9dff22f04208469c1fa89 Mon Sep 17 00:00:00 2001 From: Sherwyn Date: Tue, 11 Aug 2015 15:47:08 +0800 Subject: [PATCH 04/18] Update documentation --- docs/libraries.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/libraries.rst b/docs/libraries.rst index 896a185..1f9eaae 100644 --- a/docs/libraries.rst +++ b/docs/libraries.rst @@ -3,7 +3,7 @@ Libraries installation issues ============================= -While this wizard try to handle most of the things for you, it doesn't check for +While this wizard tries to handle most of the things for you, it doesn't check for all the proper native (non python) libraries to be installed. Before running this, please check you have the proper header and libraries installed and available for packages to be installed. @@ -15,7 +15,7 @@ Libraries you would want to check: * postgresql (for ``psycopg``) * libmysqlclient (for ``Mysql-Python``) -The actualy package name may vary depending on the platform / distribution you +The actual package name may vary depending on the platform / distribution you are using; you should make sure you have the library headers file installed (mostly contained in package with `-dev` in its name: e.g. `libjpeg-dev` for `libjpeg` library). @@ -27,9 +27,12 @@ Below are provided examples for Debian/Ubuntu, for other Linux distributions or other operating system details may vary: * Pillow: ``sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev`` -* postgres: ``sudo apt-get install libqd-dev`` +* Postgres: ``sudo apt-get install libqd-dev`` * MySQL: ``sudo apt-get install libmysqlclient-dev`` +If you are using yum to install packages, use ``yum search xx`` to search for any missing packages + +* Pillow: ``sudo yum install libjpeg-devel libpng-devel libtiff-devel freetype-devel zlib-devel`` Fixing libraries installation issues ------------------------------------ @@ -47,6 +50,8 @@ the package is compiled with some functionality missing, you have to first deinstall it (`pip uninstall *package-name*`), then install the correct library and the execute ``djangocms-installer`` again. +* Reinstall ``pip install --upgrade --force-reinstall --no-deps djangocms-installer`` + For older Debian / Ubuntu releases, a manual fix may be needed to properly fix compilation issues: see `stackoverflow`_ From fe5cbf62d68a2810c69642a0af5a5ad65b281699 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Fri, 7 Aug 2015 16:00:42 +0300 Subject: [PATCH 05/18] Add config-file test --- tests/config.py | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/tests/config.py b/tests/config.py index 881f893..ee8dc5b 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import print_function +from argparse import Namespace +import copy import os import sys @@ -8,10 +10,11 @@ from tzlocal import get_localzone from djangocms_installer import config +from djangocms_installer.config.data import CMS_VERSION_MATRIX, DJANGO_VERSION_MATRIX from djangocms_installer.install import check_install from djangocms_installer.utils import less_than_version, supported_versions -from .base import BaseTestClass +from .base import unittest, BaseTestClass class TestConfig(BaseTestClass): @@ -582,3 +585,99 @@ def test_show_requirements(self): config.show_requirements(conf_data) finally: sys.stdout = sys.__stdout__ + + +class TestBaseConfig(unittest.TestCase): + base_dir = os.path.dirname(os.path.dirname(__file__)) + config_dir = os.path.join(base_dir, 'tests/fixtures/configs') + args = ['--config-file', '-s', '-q', 'example_prj'] + config_fixture = Namespace(**{ + 'bootstrap': False, + 'cms_version': CMS_VERSION_MATRIX['stable'], + 'db': 'sqlite://localhost/project.db', + 'django_version': DJANGO_VERSION_MATRIX['stable'], + 'dump_reqs': False, + 'extra_settings': None, + 'filer': False, + 'i18n': 'yes', + 'languages': ['en'], + 'no_db_driver': False, + 'no_deps': False, + 'noinput': True, + 'no_sync': False, + 'no_user': False, + 'permissions': 'yes', + 'plugins': False, + 'project_directory': '.', + 'project_name': 'example_prj', + 'requirements_file': None, + 'reversion': 'yes', + 'skip_project_dir_check': True, + 'starting_page': False, + 'template': None, + 'templates': False, + 'timezone': get_localzone(), + 'use_timezone': 'yes', + 'utc': False + }) + + def conf(self, filename): + return os.path.join(self.config_dir, filename) + + def unused(self, config_data): + """Remove not configurable keys.""" + for attr in ('aldryn', 'config_file', 'db_driver', 'db_parsed', + 'project_path', 'settings_path', 'urlconf_path'): + delattr(config_data, attr) + # When `requirements` arg is used then requirements attr isn't set. + if hasattr(config_data, 'requirements'): + delattr(config_data, 'requirements') + + @patch('sys.stdout') + @patch('sys.stderr') + def test_parse_config_file(self, *args): + """Tests .config.__init__._parse_config_file function.""" + with self.assertRaises(SystemExit) as error: + config_data = config.parse(self.args[0:1] + [self.conf('config-not-exists.ini')] + self.args[1:]) + self.assertEqual(7, error.exception.code) + + args = self.args[0:1] + [self.conf('config-01.ini')] + self.args[1:] + config_data = config.parse(args) + self.unused(config_data) + self.assertEqual(self.config_fixture, config_data) + + fixture = copy.copy(self.config_fixture) + test_data = ( + ('config-02.ini', 'db', 'postgres://user:pwd@host:54321/dbname'), + ('config-03.ini', 'i18n', 'no'), + ('config-04.ini', 'use_timezone', 'no'), + ('config-05.ini', 'timezone', 'Europe/London'), + ('config-06.ini', 'reversion', 'no'), + ('config-07.ini', 'permissions', 'no'), + ('config-08.ini', 'languages', ['en', 'ru']), + ('config-09.ini', 'django_version', 1.8), + ('config-10.ini', 'i18n', 'no'), + ('config-11.ini', 'project_directory', '/test/me'), + ('config-12.ini', 'bootstrap', True), + ('config-13.ini', 'templates', '.'), + ('config-14.ini', 'starting_page', True), + ('config-15.ini', 'plugins', True), + ('config-16.ini', 'dump_reqs', True), + ('config-17.ini', 'noinput', True), + ('config-18.ini', 'filer', True), + ('config-19.ini', 'requirements_file', '/test/reqs'), + ('config-20.ini', 'no_deps', True), + ('config-21.ini', 'no_db_driver', True), + ('config-22.ini', 'no_sync', True), + ('config-23.ini', 'no_user', True), + ('config-24.ini', 'template', '/test/template'), + ('config-25.ini', 'extra_settings', '/test/extra_settings'), + ('config-26.ini', 'skip_project_dir_check', True), + ('config-27.ini', 'utc', True), + ) + for filename, key, val in test_data: + setattr(fixture, key, val) # Change value. + args = self.args[0:1] + [self.conf(filename)] + self.args[1:] # Load new config. + config_data = config.parse(args) + self.unused(config_data) + self.assertEqual(fixture, config_data) # Check if config value and changed value equals. From 0753745dc707690b6ebe0f5840ed2ca13a794590 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Fri, 7 Aug 2015 16:42:22 +0300 Subject: [PATCH 06/18] Add default config fixtures --- tests/fixtures/configs/config-01.ini | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/fixtures/configs/config-01.ini diff --git a/tests/fixtures/configs/config-01.ini b/tests/fixtures/configs/config-01.ini new file mode 100644 index 0000000..ec33ae2 --- /dev/null +++ b/tests/fixtures/configs/config-01.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = sqlite://localhost/project.db +i18n = yes +use-tz = yes +timezone = +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false From 8cb097c10222f44fa406524c162077f0c32f540a Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Fri, 7 Aug 2015 18:14:22 +0300 Subject: [PATCH 07/18] Change options one by one --- tests/fixtures/configs/config-02.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-03.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-04.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-05.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-06.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-07.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-08.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-09.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-10.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-11.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-12.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-13.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-14.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-15.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-16.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-17.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-18.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-19.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-20.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-21.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-22.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-23.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-24.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-25.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-26.ini | 27 +++++++++++++++++++++++++++ tests/fixtures/configs/config-27.ini | 27 +++++++++++++++++++++++++++ 26 files changed, 702 insertions(+) create mode 100644 tests/fixtures/configs/config-02.ini create mode 100644 tests/fixtures/configs/config-03.ini create mode 100644 tests/fixtures/configs/config-04.ini create mode 100644 tests/fixtures/configs/config-05.ini create mode 100644 tests/fixtures/configs/config-06.ini create mode 100644 tests/fixtures/configs/config-07.ini create mode 100644 tests/fixtures/configs/config-08.ini create mode 100644 tests/fixtures/configs/config-09.ini create mode 100644 tests/fixtures/configs/config-10.ini create mode 100644 tests/fixtures/configs/config-11.ini create mode 100644 tests/fixtures/configs/config-12.ini create mode 100644 tests/fixtures/configs/config-13.ini create mode 100644 tests/fixtures/configs/config-14.ini create mode 100644 tests/fixtures/configs/config-15.ini create mode 100644 tests/fixtures/configs/config-16.ini create mode 100644 tests/fixtures/configs/config-17.ini create mode 100644 tests/fixtures/configs/config-18.ini create mode 100644 tests/fixtures/configs/config-19.ini create mode 100644 tests/fixtures/configs/config-20.ini create mode 100644 tests/fixtures/configs/config-21.ini create mode 100644 tests/fixtures/configs/config-22.ini create mode 100644 tests/fixtures/configs/config-23.ini create mode 100644 tests/fixtures/configs/config-24.ini create mode 100644 tests/fixtures/configs/config-25.ini create mode 100644 tests/fixtures/configs/config-26.ini create mode 100644 tests/fixtures/configs/config-27.ini diff --git a/tests/fixtures/configs/config-02.ini b/tests/fixtures/configs/config-02.ini new file mode 100644 index 0000000..51ef4c6 --- /dev/null +++ b/tests/fixtures/configs/config-02.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = yes +use-tz = yes +timezone = +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-03.ini b/tests/fixtures/configs/config-03.ini new file mode 100644 index 0000000..3699851 --- /dev/null +++ b/tests/fixtures/configs/config-03.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = yes +timezone = +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-04.ini b/tests/fixtures/configs/config-04.ini new file mode 100644 index 0000000..b7a5e20 --- /dev/null +++ b/tests/fixtures/configs/config-04.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-05.ini b/tests/fixtures/configs/config-05.ini new file mode 100644 index 0000000..5756262 --- /dev/null +++ b/tests/fixtures/configs/config-05.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-06.ini b/tests/fixtures/configs/config-06.ini new file mode 100644 index 0000000..9723b7b --- /dev/null +++ b/tests/fixtures/configs/config-06.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-07.ini b/tests/fixtures/configs/config-07.ini new file mode 100644 index 0000000..bcb2053 --- /dev/null +++ b/tests/fixtures/configs/config-07.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-08.ini b/tests/fixtures/configs/config-08.ini new file mode 100644 index 0000000..3883800 --- /dev/null +++ b/tests/fixtures/configs/config-08.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-09.ini b/tests/fixtures/configs/config-09.ini new file mode 100644 index 0000000..ec6d37d --- /dev/null +++ b/tests/fixtures/configs/config-09.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-10.ini b/tests/fixtures/configs/config-10.ini new file mode 100644 index 0000000..b4f5b8c --- /dev/null +++ b/tests/fixtures/configs/config-10.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-11.ini b/tests/fixtures/configs/config-11.ini new file mode 100644 index 0000000..b8ea73a --- /dev/null +++ b/tests/fixtures/configs/config-11.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-12.ini b/tests/fixtures/configs/config-12.ini new file mode 100644 index 0000000..e0c9af5 --- /dev/null +++ b/tests/fixtures/configs/config-12.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-13.ini b/tests/fixtures/configs/config-13.ini new file mode 100644 index 0000000..7814010 --- /dev/null +++ b/tests/fixtures/configs/config-13.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-14.ini b/tests/fixtures/configs/config-14.ini new file mode 100644 index 0000000..d0b80a6 --- /dev/null +++ b/tests/fixtures/configs/config-14.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-15.ini b/tests/fixtures/configs/config-15.ini new file mode 100644 index 0000000..37bf9e4 --- /dev/null +++ b/tests/fixtures/configs/config-15.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-16.ini b/tests/fixtures/configs/config-16.ini new file mode 100644 index 0000000..4a42c9c --- /dev/null +++ b/tests/fixtures/configs/config-16.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-17.ini b/tests/fixtures/configs/config-17.ini new file mode 100644 index 0000000..75e1181 --- /dev/null +++ b/tests/fixtures/configs/config-17.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-18.ini b/tests/fixtures/configs/config-18.ini new file mode 100644 index 0000000..3d1c250 --- /dev/null +++ b/tests/fixtures/configs/config-18.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-19.ini b/tests/fixtures/configs/config-19.ini new file mode 100644 index 0000000..2525b25 --- /dev/null +++ b/tests/fixtures/configs/config-19.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-20.ini b/tests/fixtures/configs/config-20.ini new file mode 100644 index 0000000..8730890 --- /dev/null +++ b/tests/fixtures/configs/config-20.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-21.ini b/tests/fixtures/configs/config-21.ini new file mode 100644 index 0000000..c8a8f1d --- /dev/null +++ b/tests/fixtures/configs/config-21.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-22.ini b/tests/fixtures/configs/config-22.ini new file mode 100644 index 0000000..14564c3 --- /dev/null +++ b/tests/fixtures/configs/config-22.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-23.ini b/tests/fixtures/configs/config-23.ini new file mode 100644 index 0000000..da87be5 --- /dev/null +++ b/tests/fixtures/configs/config-23.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = true +template = +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-24.ini b/tests/fixtures/configs/config-24.ini new file mode 100644 index 0000000..b222ee8 --- /dev/null +++ b/tests/fixtures/configs/config-24.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = true +template = /test/template +extra-settings = +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-25.ini b/tests/fixtures/configs/config-25.ini new file mode 100644 index 0000000..23858a2 --- /dev/null +++ b/tests/fixtures/configs/config-25.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = true +template = /test/template +extra-settings = /test/extra_settings +skip-empty-check = false +utc = false diff --git a/tests/fixtures/configs/config-26.ini b/tests/fixtures/configs/config-26.ini new file mode 100644 index 0000000..7f53ea2 --- /dev/null +++ b/tests/fixtures/configs/config-26.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = true +template = /test/template +extra-settings = /test/extra_settings +skip-empty-check = true +utc = false diff --git a/tests/fixtures/configs/config-27.ini b/tests/fixtures/configs/config-27.ini new file mode 100644 index 0000000..9ae3517 --- /dev/null +++ b/tests/fixtures/configs/config-27.ini @@ -0,0 +1,27 @@ +[djangocms_installer] +db = postgres://user:pwd@host:54321/dbname +i18n = no +use-tz = no +timezone = Europe/London +reversion = no +permissions = no +languages = en,ru +django-version = 1.8 +cms-version = 3.1 +parent-dir = /test/me +bootstrap = yes +templates = . +starting-page = yes +list-plugins = true +dump-requirements = true +no-input = true +filer = true +requirements = /test/reqs +no-deps = true +no-db-driver = true +no-sync = true +no-user = true +template = /test/template +extra-settings = /test/extra_settings +skip-empty-check = true +utc = true From 726f496f5a87696735325f7bb30fa84aee0500f0 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Fri, 7 Aug 2015 16:06:50 +0300 Subject: [PATCH 08/18] Add sample config --- config.ini.sample | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 config.ini.sample diff --git a/config.ini.sample b/config.ini.sample new file mode 100644 index 0000000..ec33ae2 --- /dev/null +++ b/config.ini.sample @@ -0,0 +1,27 @@ +[djangocms_installer] +db = sqlite://localhost/project.db +i18n = yes +use-tz = yes +timezone = +reversion = yes +permissions = yes +languages = +django-version = stable +cms-version = stable +parent-dir = . +bootstrap = no +templates = no +starting-page = no +list-plugins = false +dump-requirements = false +no-input = false +filer = false +requirements = +no-deps = false +no-db-driver = false +no-sync = false +no-user = false +template = +extra-settings = +skip-empty-check = false +utc = false From 0db4fb5cc8456d56dc74fe54d9b7f77c8c11af78 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Fri, 7 Aug 2015 16:42:37 +0300 Subject: [PATCH 09/18] Add config.ini module. Refs #110 --- djangocms_installer/config/__init__.py | 10 +++- djangocms_installer/config/ini.py | 73 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 djangocms_installer/config/ini.py diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index b8c34f5..6e466ec 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -9,7 +9,7 @@ from tzlocal import get_localzone -from . import data +from . import data, ini from .internal import DbAction, validate_project from .. import compat, utils from ..utils import less_than_version, supported_versions @@ -20,6 +20,9 @@ def parse(args): Define the available arguments """ parser = argparse.ArgumentParser(description='Bootstrap a django CMS project.') + parser.add_argument('--config-file', dest='config_file', action='store', + default=None, + help='Configuration file for djangocms_installer') parser.add_argument('--db', '-d', dest='db', action=DbAction, default='sqlite://localhost/project.db', help='Database configuration (in URL format)') @@ -103,7 +106,10 @@ def parse(args): for action in parser._positionals._actions: if action.dest == 'timezone': action.default = 'UTC' - args = parser.parse_args(args) + + # If config_args then pretend that config args came from the stdin and run parser again. + config_args = ini.parse_config_file(parser, args) + args = parser.parse_args(config_args + args) # First of all, check if the project name is valid if not validate_project(args.project_name): diff --git a/djangocms_installer/config/ini.py b/djangocms_installer/config/ini.py new file mode 100644 index 0000000..937bfb1 --- /dev/null +++ b/djangocms_installer/config/ini.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +from __future__ import print_function + +import sys + +try: + from configparser import ConfigParser # Python 3. +except ImportError: + from ConfigParser import ConfigParser # Python 2. + + +SECTION = 'djangocms_installer' + + +def parse_config_file(parser, stdin_args): + """Parse config file. + + Returns a list of additional args. + """ + config_args = [] + + # Temporary switch required args and save them to restore. + required_args = [] + for action in parser._actions: + if action.required: + required_args.append(action) + action.required = False + + parsed_args = parser.parse_args(stdin_args) + + # Restore required args. + for action in required_args: + action.required = True + + if not parsed_args.config_file: + return config_args + + config = ConfigParser() + if not config.read(parsed_args.config_file): + sys.stderr.write("Config file '%s' doesn't exists\n" % parsed_args.config_file) + sys.exit(7) # It isn't used anythere. + + config_args = _convert_config_to_stdin(config, parser) + return config_args + + +def _convert_config_to_stdin(config, parser): + """Convert config options to stdin args. + + Especially boolean values, for more information + @see https://docs.python.org/3.4/library/configparser.html#supported-datatypes + """ + keys_empty_values_not_pass = ( + '--extra-settings', '--languages', '--requirements', '--template', '--timezone') + args = [] + for key, val in config.items(SECTION): + keyp = '--%s' % key + action = parser._option_string_actions[keyp] + + if action.const: + try: + if config.getboolean(SECTION, key): + args.append(keyp) + except ValueError: + args.extend([keyp, val]) # Pass it as is to get the error from ArgumentParser. + elif any([i for i in keys_empty_values_not_pass if i in action.option_strings]): + # Some keys with empty values shouldn't be passed into args to use their defaults from ArgumentParser. + if val != '': + args.extend([keyp, val]) + else: + args.extend([keyp, val]) + + return args From cabfad03c9894406053fde354aa302609923a222 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Mon, 10 Aug 2015 14:01:42 +0300 Subject: [PATCH 10/18] Add config-dump test --- tests/config.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/config.py b/tests/config.py index ee8dc5b..a1c198c 100644 --- a/tests/config.py +++ b/tests/config.py @@ -621,12 +621,21 @@ class TestBaseConfig(unittest.TestCase): 'utc': False }) + def __init__(self, *args, **kwargs): + self.config_not_exists = self.conf('config-dump.ini') + + super(TestBaseConfig, self).__init__(*args, **kwargs) + + def tearDown(self): + if os.path.isfile(self.config_not_exists): + os.remove(self.config_not_exists) + def conf(self, filename): return os.path.join(self.config_dir, filename) def unused(self, config_data): """Remove not configurable keys.""" - for attr in ('aldryn', 'config_file', 'db_driver', 'db_parsed', + for attr in ('aldryn', 'config_dump', 'config_file', 'db_driver', 'db_parsed', 'project_path', 'settings_path', 'urlconf_path'): delattr(config_data, attr) # When `requirements` arg is used then requirements attr isn't set. @@ -681,3 +690,24 @@ def test_parse_config_file(self, *args): config_data = config.parse(args) self.unused(config_data) self.assertEqual(fixture, config_data) # Check if config value and changed value equals. + + @patch('sys.stdout') + @patch('sys.stderr') + def test_dump_config_file(self, *args): + """Tests .config.ini.dump_config_file function.""" + config_exists = self.conf('config-01.ini') + + with self.assertRaises(SystemExit) as error: + config_data = config.parse(['--config-dump', config_exists] + self.args[1:] + ['-p', '.']) + self.assertEqual(8, error.exception.code) + + config_data = config.parse(['--config-dump', self.config_not_exists] + self.args[1:] + ['-p', '.']) + self.assertTrue(os.path.isfile(self.config_not_exists)) + + fixture = copy.copy(self.config_fixture) + setattr(fixture, 'timezone', get_localzone().zone) + # Load dumped config. + args = self.args[0:1] + [self.config_not_exists] + self.args[1:] + config_data = config.parse(args) + self.unused(config_data) + self.assertEqual(fixture, config_data) From 1c9aaf9bf50bc413e5ad59612a1cacdadaa269f5 Mon Sep 17 00:00:00 2001 From: Alexander Pervakov Date: Tue, 11 Aug 2015 10:14:12 +0300 Subject: [PATCH 11/18] Allow to dump current config to file. Refs #110 --- djangocms_installer/config/__init__.py | 10 ++++++ djangocms_installer/config/ini.py | 49 ++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 6e466ec..da55850 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -23,6 +23,9 @@ def parse(args): parser.add_argument('--config-file', dest='config_file', action='store', default=None, help='Configuration file for djangocms_installer') + parser.add_argument('--config-dump', dest='config_dump', action='store', + default=None, + help='Dump configuration file with current args') parser.add_argument('--db', '-d', dest='db', action=DbAction, default='sqlite://localhost/project.db', help='Database configuration (in URL format)') @@ -135,6 +138,10 @@ def parse(args): "please choose a different one\n" % args.project_path) sys.exit(4) + if args.config_dump and os.path.isfile(args.config_dump): + sys.stdout.write('Cannot dump because given configuration file "%s" is exists.\n' % args.config_dump) + sys.exit(8) + for item in data.CONFIGURABLE_OPTIONS: action = parser._option_string_actions[item] choices = default = "" @@ -302,6 +309,9 @@ def parse(args): setattr(args, 'urlconf_path', os.path.join(args.project_directory, args.project_name, 'urls.py').strip()) + if args.config_dump: + ini.dump_config_file(args.config_dump, args, parser) + return args diff --git a/djangocms_installer/config/ini.py b/djangocms_installer/config/ini.py index 937bfb1..aaac42b 100644 --- a/djangocms_installer/config/ini.py +++ b/djangocms_installer/config/ini.py @@ -8,6 +8,8 @@ except ImportError: from ConfigParser import ConfigParser # Python 2. +from .data import CMS_VERSION_MATRIX, DJANGO_VERSION_MATRIX + SECTION = 'djangocms_installer' @@ -44,6 +46,53 @@ def parse_config_file(parser, stdin_args): return config_args +def dump_config_file(filename, args, parser=None): + """Dump args to config file.""" + config = ConfigParser() + config.add_section(SECTION) + if parser is None: + for attr in args: + config.set(SECTION, attr, args.attr) + else: + keys_empty_values_not_pass = ( + '--extra-settings', '--languages', '--requirements', '--template', '--timezone') + + #_positionals._option_string_actions + for action in parser._actions: + if action.dest in ('help', 'config_file', 'config_dump', 'project_name'): + continue + + keyp = action.option_strings[0] + option_name = keyp.lstrip('-') + option_value = getattr(args, action.dest) + if any([i for i in keys_empty_values_not_pass if i in action.option_strings]): + if action.dest == 'timezone': + config.set(SECTION, option_name, option_value.zone) + elif action.dest == 'languages': + if len(option_value) == 1 and option_value[0] == 'en': + config.set(SECTION, option_name, '') + else: + config.set(SECTION, option_name, ','.join()) + else: + config.set(SECTION, option_name, option_value if option_value else '') + elif action.choices == ('yes', 'no'): + config.set(SECTION, option_name, 'yes' if option_value else 'no') + elif action.dest == 'templates': + config.set(SECTION, option_name, option_value if option_value else 'no') + elif action.dest == 'cms_version': + version = 'stable' if option_value == CMS_VERSION_MATRIX['stable'] else option_value + config.set(SECTION, option_name, version) + elif action.dest == 'django_version': + version = 'stable' if option_value == DJANGO_VERSION_MATRIX['stable'] else option_value + config.set(SECTION, option_name, version) + elif action.const: + config.set(SECTION, option_name, 'true' if option_value else 'false') + else: + config.set(SECTION, option_name, str(option_value)) + with open(filename, 'w') as fp: + config.write(fp) + + def _convert_config_to_stdin(config, parser): """Convert config options to stdin args. From b13ac396f81e58e04368b58578f2774a4681a6b5 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 20 Aug 2015 23:19:38 +0200 Subject: [PATCH 12/18] Better strategy to configure migration modules --- djangocms_installer/config/settings.py | 66 ++++++++++---------------- djangocms_installer/django/__init__.py | 51 ++++++++++++-------- tests/django.py | 12 ++--- 3 files changed, 61 insertions(+), 68 deletions(-) diff --git a/djangocms_installer/config/settings.py b/djangocms_installer/config/settings.py index fe9cf65..856fe64 100644 --- a/djangocms_installer/config/settings.py +++ b/djangocms_installer/config/settings.py @@ -184,46 +184,30 @@ } -SOUTH_MIGRATION_MODULES = ( - ('easy_thumbnails', 'easy_thumbnails.south_migrations'), - ('djangocms_text_ckeditor', 'djangocms_text_ckeditor.south_migrations'), -) - -MIGRATION_MODULES_COMMON = ( - ('djangocms_column', 'djangocms_column.migrations_django'), - ('djangocms_flash', 'djangocms_flash.migrations_django'), - ('djangocms_googlemap', 'djangocms_googlemap.migrations_django'), - ('djangocms_inherit', 'djangocms_inherit.migrations_django'), - ('djangocms_link', 'djangocms_link.migrations_django'), - ('djangocms_style', 'djangocms_style.migrations_django'), -) - -MIGRATION_MODULES_STANDARD = ( - ('djangocms_file', 'djangocms_file.migrations_django'), - ('djangocms_picture', 'djangocms_picture.migrations_django'), - ('djangocms_teaser', 'djangocms_teaser.migrations_django'), - ('djangocms_video', 'djangocms_video.migrations_django'), -) +APPHOOK_RELOAD_APPLICATIONS = [ + 'aldryn_apphook_reload' +] +APPHOOK_RELOAD_MIDDLEWARE_CLASS = 'aldryn_apphook_reload.middleware.ApphookReloadMiddleware' -MIGRATION_MODULES_FILER = ( - ('cmsplugin_filer_image', 'cmsplugin_filer_image.migrations_django'), - ('cmsplugin_filer_file', 'cmsplugin_filer_file.migrations_django'), - ('cmsplugin_filer_folder', 'cmsplugin_filer_folder.migrations_django'), - ('cmsplugin_filer_teaser', 'cmsplugin_filer_teaser.migrations_django'), - ('cmsplugin_filer_utils', 'cmsplugin_filer_utils.migrations_django'), - ('cmsplugin_filer_video', 'cmsplugin_filer_video.migrations_django'), +MIGRATIONS_CHECK_MODULES = ( + 'cms', + 'menus', + 'filer', + 'cmsplugin_filer_image', + 'cmsplugin_filer_file', + 'cmsplugin_filer_folder', + 'cmsplugin_filer_teaser', + 'cmsplugin_filer_utils', + 'cmsplugin_filer_video', + 'djangocms_text_ckeditor', + 'djangocms_column', + 'djangocms_flash', + 'djangocms_googlemap', + 'djangocms_inherit', + 'djangocms_link', + 'djangocms_style', + 'djangocms_file', + 'djangocms_picture', + 'djangocms_teaser', + 'djangocms_video', ) - -MIGRATION_MODULES_BASE = ( - ('cms', 'cms.migrations_django'), - ('menus', 'menus.migrations_django'), -) + MIGRATION_MODULES_COMMON + MIGRATION_MODULES_STANDARD - -MIGRATION_MODULES_BASE_FILER = ( - ('cms', 'cms.migrations_django'), - ('menus', 'menus.migrations_django'), -) + MIGRATION_MODULES_COMMON + MIGRATION_MODULES_FILER - -MIGRATION_MODULES_3_1 = MIGRATION_MODULES_COMMON + MIGRATION_MODULES_STANDARD - -MIGRATION_MODULES_3_1_FILER = MIGRATION_MODULES_COMMON + MIGRATION_MODULES_FILER \ No newline at end of file diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 61c1193..4bdb98d 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -1,21 +1,25 @@ # -*- coding: utf-8 -*- from __future__ import print_function -from copy import copy, deepcopy + import glob import os import re -try: - from shlex import quote as shlex_quote -except ImportError: - from pipes import quote as shlex_quote import shutil import subprocess import sys import tempfile import textwrap import zipfile -from six import BytesIO +from copy import copy, deepcopy +from importlib import import_module + +try: + from shlex import quote as shlex_quote +except ImportError: + from pipes import quote as shlex_quote + +from six import BytesIO from ..compat import iteritems from ..utils import chdir @@ -43,6 +47,22 @@ def create_project(config_data): subprocess.check_call(' '.join([sys.executable, os.path.join(os.path.dirname(sys.executable), 'django-admin.py'), 'startproject'] + args), shell=True) + +def _detect_migration_layout(vars, apps): + SOUTH_MODULES = {} + DJANGO_MODULES = {} + for module in vars.MIGRATIONS_CHECK_MODULES: + if module in apps: + try: + import_module('%s.migrations_django' % module) + DJANGO_MODULES[module] = '%s.migrations_django' % module + SOUTH_MODULES[module] = '%s.migrations' % module + except Exception as e: + print(module, e) + pass + return DJANGO_MODULES, SOUTH_MODULES + + def _install_aldryn(config_data): import requests media_project = os.path.join(config_data.project_directory, 'dist', 'media') @@ -246,23 +266,14 @@ def _build_settings(config_data): if config_data.cms_version == 2.4: apps.extend(vars.CMS_2_APPLICATIONS) apps.extend(vars.MPTT_APPS) - MIGRATION_MODULES = () elif config_data.cms_version == 3.0: apps = list(vars.CMS_3_HEAD) + apps apps.extend(vars.MPTT_APPS) apps.extend(vars.CMS_3_APPLICATIONS) - if config_data.filer: - MIGRATION_MODULES = vars.MIGRATION_MODULES_BASE_FILER - else: - MIGRATION_MODULES = vars.MIGRATION_MODULES_BASE else: apps = list(vars.CMS_3_HEAD) + apps apps.extend(vars.TREEBEARD_APPS) apps.extend(vars.CMS_3_APPLICATIONS) - if config_data.filer: - MIGRATION_MODULES = vars.MIGRATION_MODULES_3_1_FILER - else: - MIGRATION_MODULES = vars.MIGRATION_MODULES_3_1 if config_data.cms_version == 2.4: if config_data.filer: @@ -337,16 +348,18 @@ def _build_settings(config_data): } }""").strip() % (",\n" + spacer * 2).join(["'%s': '%s'" % (key, val) for key, val in sorted(config_data.db_parsed.items(), key=lambda x: x[0])])) + DJANGO_MIGRATION_MODULES, SOUTH_MIGRATION_MODULES = _detect_migration_layout(vars, apps) + if config_data.django_version >= 1.7: text.append("MIGRATION_MODULES = {\n%s%s\n}" % ( - spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in MIGRATION_MODULES]))) + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in DJANGO_MIGRATION_MODULES.items()]))) + else: + text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in SOUTH_MIGRATION_MODULES.items()]))) if config_data.filer: text.append("THUMBNAIL_PROCESSORS = (\n%s%s\n)" % ( spacer, (",\n" + spacer).join(["'%s'" % var for var in vars.THUMBNAIL_PROCESSORS]))) - if config_data.django_version <= 1.6: - text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( - spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.SOUTH_MIGRATION_MODULES]))) return "\n\n".join(text) diff --git a/tests/django.py b/tests/django.py index fa829d6..68a0687 100644 --- a/tests/django.py +++ b/tests/django.py @@ -7,8 +7,6 @@ import textwrap from djangocms_installer import config, django, install -from djangocms_installer.config.settings import (MIGRATION_MODULES_BASE, - MIGRATION_MODULES_3_1_FILER) from .base import unittest, IsolatedTestClass dj_ver = '1.7' if sys.version_info >= (2, 7) else '1.6' @@ -244,9 +242,8 @@ def test_patch_django_17_settings(self): ## checking for django options self.assertFalse('south' in project.settings.INSTALLED_APPS) - for module in MIGRATION_MODULES_BASE: - self.assertTrue(module[0] in project.settings.MIGRATION_MODULES.keys()) - self.assertTrue(module[1] in project.settings.MIGRATION_MODULES.values()) + self.assertFalse('cms' in project.settings.MIGRATION_MODULES) + self.assertFalse('djangocms_text_ckeditor' in project.settings.MIGRATION_MODULES) def test_patch_31(self): config_data = config.parse(['--db=sqlite://localhost/test.db', @@ -294,9 +291,8 @@ def test_patch_django_17_31(self): ## checking for django options self.assertFalse('south' in project.settings.INSTALLED_APPS) - for module in MIGRATION_MODULES_3_1_FILER: - self.assertTrue(module[0] in project.settings.MIGRATION_MODULES.keys()) - self.assertTrue(module[1] in project.settings.MIGRATION_MODULES.values()) + self.assertFalse('filer' in project.settings.MIGRATION_MODULES) + self.assertFalse('djangocms_text_ckeditor' in project.settings.MIGRATION_MODULES) @unittest.skipIf(sys.version_info <= (2, 7), reason="django 1.7 does not support python 2.6") From e754090082ce006274dc0a99c0f5c664b3062dd4 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 15:57:23 +0200 Subject: [PATCH 13/18] Small test requirements refactor --- requirements_dev.txt => requirements-test.txt | 3 ++- tox.ini | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) rename requirements_dev.txt => requirements-test.txt (69%) diff --git a/requirements_dev.txt b/requirements-test.txt similarity index 69% rename from requirements_dev.txt rename to requirements-test.txt index 61ca229..5699f0b 100644 --- a/requirements_dev.txt +++ b/requirements-test.txt @@ -1,5 +1,6 @@ -r requirements.txt flake8 tox -unittest2 mock +pillow +coverage diff --git a/tox.ini b/tox.ini index f5f13e9..11c986e 100644 --- a/tox.ini +++ b/tox.ini @@ -7,14 +7,8 @@ passenv = LANG recreate = True commands = {env:COMMAND:python} setup.py test deps = - -r{toxinidir}/requirements.txt - pillow - coverage + -r{toxinidir}/requirements-test.txt py26: unittest2 - py26: mock<1.1 - py27: mock - py33: mock - py34: mock [testenv:coverage] commands = From bde638193a071bc070f08b2fd1929bdaff5f3f61 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 15:57:56 +0200 Subject: [PATCH 14/18] Dynamic check for migrations structure --- djangocms_installer/django/__init__.py | 5 +++-- tests/base.py | 16 ++++++++++++++-- tests/django.py | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 4bdb98d..546eb2a 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -12,6 +12,7 @@ import zipfile from copy import copy, deepcopy + from importlib import import_module try: @@ -51,14 +52,14 @@ def create_project(config_data): def _detect_migration_layout(vars, apps): SOUTH_MODULES = {} DJANGO_MODULES = {} + for module in vars.MIGRATIONS_CHECK_MODULES: if module in apps: try: import_module('%s.migrations_django' % module) DJANGO_MODULES[module] = '%s.migrations_django' % module SOUTH_MODULES[module] = '%s.migrations' % module - except Exception as e: - print(module, e) + except Exception: pass return DJANGO_MODULES, SOUTH_MODULES diff --git a/tests/base.py b/tests/base.py index cf66ee6..e061806 100644 --- a/tests/base.py +++ b/tests/base.py @@ -6,13 +6,14 @@ import sys import tempfile +from copy import copy +from six import StringIO + if sys.version_info[:2] < (2, 7): import unittest2 as unittest else: import unittest -from six import StringIO - SYSTEM_ACTIVATE = os.path.join(os.path.dirname(sys.executable), 'activate_this.py') @@ -74,6 +75,7 @@ def _create_project_dir(self): print("creating virtualenv", self.virtualenv_dir) def tearDown(self): + from djangocms_installer.config.settings import MIGRATIONS_CHECK_MODULES if self.verbose: print("deactivating virtualenv", self.virtualenv_dir) if os.path.exists(SYSTEM_ACTIVATE): @@ -85,6 +87,16 @@ def tearDown(self): exec(code, dict(__file__=SYSTEM_ACTIVATE)) sys.executable = os.path.join(os.path.dirname(SYSTEM_ACTIVATE), 'python') super(IsolatedTestClass, self).tearDown() + modules = copy(sys.modules) + for module in modules: + if (module.endswith('.migrations') + or module.endswith('.south_migrations') + or module.endswith('.django_migrations')): + main_module = module.rpartition('.')[0] + if module in sys.modules: + del sys.modules[module] + if main_module in sys.modules: + del sys.modules[main_module] def setUp(self): super(IsolatedTestClass, self).setUp() diff --git a/tests/django.py b/tests/django.py index 68a0687..1f86904 100644 --- a/tests/django.py +++ b/tests/django.py @@ -242,7 +242,7 @@ def test_patch_django_17_settings(self): ## checking for django options self.assertFalse('south' in project.settings.INSTALLED_APPS) - self.assertFalse('cms' in project.settings.MIGRATION_MODULES) + self.assertTrue('cms' in project.settings.MIGRATION_MODULES) self.assertFalse('djangocms_text_ckeditor' in project.settings.MIGRATION_MODULES) def test_patch_31(self): From e7970c6160e51be7a9ea6e69ad654fcc70d1625b Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 17:31:47 +0200 Subject: [PATCH 15/18] Aggresssively deletes modules in tearDown --- djangocms_installer/django/__init__.py | 2 +- tests/base.py | 10 ++-------- tests/django.py | 4 ++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 546eb2a..ee0a5a3 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -56,7 +56,7 @@ def _detect_migration_layout(vars, apps): for module in vars.MIGRATIONS_CHECK_MODULES: if module in apps: try: - import_module('%s.migrations_django' % module) + mod = import_module('%s.migrations_django' % module) # NOQA DJANGO_MODULES[module] = '%s.migrations_django' % module SOUTH_MODULES[module] = '%s.migrations' % module except Exception: diff --git a/tests/base.py b/tests/base.py index e061806..b6a4c6f 100644 --- a/tests/base.py +++ b/tests/base.py @@ -89,14 +89,8 @@ def tearDown(self): super(IsolatedTestClass, self).tearDown() modules = copy(sys.modules) for module in modules: - if (module.endswith('.migrations') - or module.endswith('.south_migrations') - or module.endswith('.django_migrations')): - main_module = module.rpartition('.')[0] - if module in sys.modules: - del sys.modules[module] - if main_module in sys.modules: - del sys.modules[main_module] + if 'django' in module: + del sys.modules[module] def setUp(self): super(IsolatedTestClass, self).setUp() diff --git a/tests/django.py b/tests/django.py index 1f86904..08cc1f3 100644 --- a/tests/django.py +++ b/tests/django.py @@ -242,7 +242,7 @@ def test_patch_django_17_settings(self): ## checking for django options self.assertFalse('south' in project.settings.INSTALLED_APPS) - self.assertTrue('cms' in project.settings.MIGRATION_MODULES) + self.assertFalse('cms' in project.settings.MIGRATION_MODULES) self.assertFalse('djangocms_text_ckeditor' in project.settings.MIGRATION_MODULES) def test_patch_31(self): @@ -509,7 +509,7 @@ def test_database_setup_filer(self): def test_database_setup(self): config_data = config.parse(['--db=sqlite://localhost/test.db', - '-q', '--cms-version=3.0', '--django=%s' % dj_ver, + '-q', '--cms-version=3.1', '--django=%s' % dj_ver, '-p'+self.project_dir, 'cms_project']) install.requirements(config_data.requirements) django.create_project(config_data) From 739b9715ff6585e3501558163a53753f558bd0f2 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 18:28:19 +0200 Subject: [PATCH 16/18] Fix python 2.6 --- djangocms_installer/django/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index ee0a5a3..d79a8ad 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -13,8 +13,6 @@ from copy import copy, deepcopy -from importlib import import_module - try: from shlex import quote as shlex_quote except ImportError: @@ -56,7 +54,7 @@ def _detect_migration_layout(vars, apps): for module in vars.MIGRATIONS_CHECK_MODULES: if module in apps: try: - mod = import_module('%s.migrations_django' % module) # NOQA + mod = __import__('%s.migrations_django' % module) # NOQA DJANGO_MODULES[module] = '%s.migrations_django' % module SOUTH_MODULES[module] = '%s.migrations' % module except Exception: From a823a8360d3fdd2c4f1d35920f0710e02e02f037 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 18:59:15 +0200 Subject: [PATCH 17/18] Add documentation for config option --- AUTHORS.rst | 1 + HISTORY.rst | 7 +++++ djangocms_installer/__init__.py | 2 +- docs/conf.py | 3 +- docs/faq.rst | 3 +- docs/reference.rst | 7 +++-- docs/usage.rst | 49 ++++++++++++++++++++++++++++++++- 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index e6addf7..be2f24d 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,6 +13,7 @@ Contributors ------------ * Aaron Boman +* Alexander Pervakov * Carlo Ascani * Claudio Luck * Enkel Mitrushi diff --git a/HISTORY.rst b/HISTORY.rst index 51375e1..5000de7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,13 @@ History ------- +0.8.0 (XXXX-XX-XX) +++++++++++++++++++ + +* Options can now be provided via an ini file for easy scripting +* Better migration modules discovery strategy +* Minor fixes + 0.7.9 (2015-07-21) ++++++++++++++++++ diff --git a/djangocms_installer/__init__.py b/djangocms_installer/__init__.py index 56b4975..e49f196 100644 --- a/djangocms_installer/__init__.py +++ b/djangocms_installer/__init__.py @@ -2,4 +2,4 @@ # -*- coding: utf-8 -*- __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.7.9' +__version__ = '0.8.0.dev3' diff --git a/docs/conf.py b/docs/conf.py index f537922..08d7612 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import os +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/docs/faq.rst b/docs/faq.rst index fdfebc8..5c72ba0 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -27,7 +27,8 @@ FAQ **djangocms-installer** uses `dj-database-url`_ to get database configuration parameters; refer to this package for more details. -#. The installer dies with an error like ``ImportError: Could not import settings 'foo.bar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named foo.bar.settings``, +#. The installer dies with an error like + ``ImportError: Could not import settings 'foo.bar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named foo.bar.settings``, what's happening? Chances are you have ``DJANGO_SETTINGS_MODULE`` set in you environment, diff --git a/docs/reference.rst b/docs/reference.rst index 887e7d9..859d3ac 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -57,6 +57,9 @@ advanced usage: * ``--no-input``, ``-q``: If given **djangocms installer** run in :ref:`batch_mode`; * ``--filer``, ``-f``: Install and configure django-filer plugins; +* ``--config-file``: Provides the configuration options via a ini file; see :ref:`ini_mode`; +* ``--config-dump``: Dumps the configuration in a format suitable for ``-config-file`` + option; see :ref:`ini_mode`; * ``--dump-requirements``, ``-R``: Dumps the generated requirements to stdout and exits; see :ref:`dump_mode`; * ``--requirements``, ``-r``: You can use a custom requirements files instead of the @@ -71,11 +74,11 @@ advanced usage: project; * ``--extra-settings``: Path to a file with extra variables to append to generated settings file. It doesn't need to be a Python file, its content is blindly copied in the project settings. -*``--aldryn``, ``-a``: Use `aldryn-boilerplate`_; this downloads **aldryn-boilerplate** and copies +* ``--aldryn``, ``-a``: Use `aldryn-boilerplate`_; this downloads **aldryn-boilerplate** and copies it to the project, adapting the project layout according to boilerplate specifications; the use of aldryn-boilerplate requires manual actions, look at `aldryn-boilerplate documentation`_ for further informations. -*``--skip-empty-check``, ``-s``: Skip the check if the project dir contains files or directory; +* ``--skip-empty-check``, ``-s``: Skip the check if the project dir contains files or directory; in case of error when setting up the project, ``djangocms-installer`` may ask you to remove the directory, be careful if using this option as you may remove files not related to the project set up by the installer. diff --git a/docs/usage.rst b/docs/usage.rst index 8f4d553..5254b6b 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -58,6 +58,51 @@ This can be helpful to customize the virtualenv: See :ref:`arguments` for arguments reference +.. _ini_mode: + +Config file mode +---------------- + +In config file mode, all (or some) options can be provided via an external configuration file. + +See a `complete example`_ +with all available arguments. + +Is it possible to either provide all the values in the config file: + +.. code-block:: shell + + djangocms_installer --config-file /path/to/config.ini project_name + +Or just some, or overriding by using the command line arguments: + +.. code-block:: shell + + djangocms_installer --config-file /path/general-config.ini -p /path/other/proj -s -q project_name + +.. note:: If config.ini not contains `no-input = true` and `-q` argument isn't set then one + act as a placeholder with default values for wizard. + + +Dump config files +^^^^^^^^^^^^^^^^^ + +Values passed to the installer can be dumped for later reuse: + +.. code-block:: shell + + djangocms_installer --config-dump /path/config.ini -p . project_name + +if installation fails dump can be used to fix some arguments and re-run installer with dumped config: + +.. code-block:: shell + + djangocms_installer --config-dump /path/config.ini --db postgres://wrong-usr:pwd@host/db -p . project_name + # fails + + djangocms_installer --config-file /path/config.ini --db postgres://correct-user:pwd@host/db -p . project_name + # succeed + Custom settings --------------- @@ -106,4 +151,6 @@ Use different templates directory You can create the base project with a custom templateset by using the ``--templates`` parameter. Be aware that while **djangocms installer** will copy the files for you, it won't update the ``CMS_TEMPLATES`` settings -parameter, so you'll need to modify that after installation. \ No newline at end of file +parameter, so you'll need to modify that after installation. + +.. _complete example: https://github.com/nephila/djangocms-installer/blob/develop/config.ini.sample From 2c339da2c685fa7c85bd39020d04d06e2848e808 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 29 Aug 2015 17:41:39 +0200 Subject: [PATCH 18/18] Linting code --- djangocms_installer/config/__init__.py | 4 ++-- djangocms_installer/config/data.py | 8 ++++---- djangocms_installer/config/ini.py | 2 +- djangocms_installer/install/__init__.py | 3 +-- djangocms_installer/share/starting_page.py | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index da55850..c0475c0 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -78,7 +78,7 @@ def parse(args): # Advanced options. These have a predefined default and are not managed # by config wizard. - #parser.add_argument('--aldryn', '-a', dest='aldryn', action='store_true', + # parser.add_argument('--aldryn', '-a', dest='aldryn', action='store_true', # default=False, help="Use Aldryn-boilerplate as project template") parser.add_argument('--no-input', '-q', dest='noinput', action='store_true', default=False, help="Don't run the configuration wizard, just use the provided values") @@ -109,7 +109,7 @@ def parse(args): for action in parser._positionals._actions: if action.dest == 'timezone': action.default = 'UTC' - + # If config_args then pretend that config args came from the stdin and run parser again. config_args = ini.parse_config_file(parser, args) args = parser.parse_args(config_args + args) diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index dfd4d45..f6111ef 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -7,13 +7,13 @@ '--permissions', '--bootstrap', '--templates', '--starting-page'] -DJANGOCMS_DEVELOP = 'https://github.com/divio/django-cms/archive/develop.zip?%s' % time.time() ## to avoid getting this from caches or mirrors +DJANGOCMS_DEVELOP = 'https://github.com/divio/django-cms/archive/develop.zip?%s' % time.time() DJANGOCMS_RC = 'https://github.com/divio/django-cms/archive/3.0c2.zip' DJANGOCMS_BETA = 'https://github.com/divio/django-cms/archive/3.0.0.beta3.zip' DJANGOCMS_SUPPORTED = ('2.4', '3.0', '3.1', 'stable', 'develop') -DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip?%s' % time.time() ## to avoid getting this from caches or mirrors -DJANGO_BETA = 'https://github.com/django/django/archive/master.zip?%s' % time.time() ## to avoid getting this from caches or mirrors +DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip?%s' % time.time() +DJANGO_BETA = 'https://github.com/django/django/archive/master.zip?%s' % time.time() DJANGO_SUPPORTED = ('1.4', '1.5', '1.6', '1.7', '1.8', 'stable') CMS_VERSION_MATRIX = { @@ -35,7 +35,7 @@ 3.2: (1.6, 1.8), } -REQUIREMENTS ={ +REQUIREMENTS = { 'default': [ 'django-classy-tags>=0.3.4.1', 'html5lib', diff --git a/djangocms_installer/config/ini.py b/djangocms_installer/config/ini.py index aaac42b..182334b 100644 --- a/djangocms_installer/config/ini.py +++ b/djangocms_installer/config/ini.py @@ -57,7 +57,7 @@ def dump_config_file(filename, args, parser=None): keys_empty_values_not_pass = ( '--extra-settings', '--languages', '--requirements', '--template', '--timezone') - #_positionals._option_string_actions + # positionals._option_string_actions for action in parser._actions: if action.dest in ('help', 'config_file', 'config_dump', 'project_name'): continue diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 072db6c..aab1f62 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -20,7 +20,6 @@ def check_install(config_data): Many other errors will go undetected """ errors = [] - size = 128, 128 # PIL tests try: @@ -73,7 +72,7 @@ def cleanup(requirements): # pragma: no cover args = ['uninstall', '-q', '-y'] args.extend(requirements.split()) - exit_status = pip.main(args) + pip.main(args) return True diff --git a/djangocms_installer/share/starting_page.py b/djangocms_installer/share/starting_page.py index a81885f..abf9013 100644 --- a/djangocms_installer/share/starting_page.py +++ b/djangocms_installer/share/starting_page.py @@ -31,8 +31,8 @@ def create_pages(): try: # try to get a feature placeholder placeholder_feature = page.placeholders.get(slot='feature') - p = add_plugin(placeholder_feature, 'TextPlugin', lang, - body=content['feature']) + add_plugin(placeholder_feature, 'TextPlugin', lang, + body=content['feature']) except Placeholder.DoesNotExist: # fallback, add it to the add_plugin(placeholder['main'], 'TextPlugin', lang, body=content['feature']) @@ -57,4 +57,4 @@ def create_pages(): if __name__ == '__main__': if LooseVersion(django.get_version()) >= LooseVersion('1.7'): django.setup() - create_pages() \ No newline at end of file + create_pages()