From ca3cfae8b3dc244a380e0f8e026eeb18bee9cf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 27 Feb 2016 18:27:03 +0100 Subject: [PATCH] Changed name of '--development' option and name of the respective directory. Fixed #2001 --- .gitignore | 4 ++-- CHANGELOG | 3 ++- README.rst | 8 +++++++- openslides/__main__.py | 34 +++++++++++++++++----------------- openslides/utils/main.py | 22 +++++++++++----------- setup.cfg | 2 +- tests/old/utils/test_main.py | 4 ++-- 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index cfe1cb267..c49dc0900 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,8 @@ node_modules/* bower_components/* -# Development user data (settings, database, media, search index, static files) -development/* +# Local user data (settings, database, media, search index, static files) +personal_data/* openslides/static/* # Package building/IDE diff --git a/CHANGELOG b/CHANGELOG index d7293c68b..eac166448 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,7 +56,8 @@ Other: - Updated to Bootstrap 3. - Used SockJS for automatic update of AngularJS driven single page frontend. - Refactored plugin API. -- Refactored start script and management commands. +- Refactored start script and management commands. Changed command line + options and path for local installation. - Refactored tests. - Used Bower and gulp to manage third party JavaScript and Cascading Style Sheets libraries. diff --git a/README.rst b/README.rst index 8ef3ccc57..f43317329 100644 --- a/README.rst +++ b/README.rst @@ -149,6 +149,12 @@ To get help on the command line options run:: openslides --help +You can store settings, database and other personal files in a local +subdirectory and use these files e. g. if you want to run multiple +instances of OpenSlides:: + + openslides --local-installation + V. Development ============== @@ -214,7 +220,7 @@ Installation and start of the development version python manage.py start - This will create a new development directoy with settings.py and database. + This will create a new directoy with settings.py and database. To get help on the command-line options run:: diff --git a/openslides/__main__.py b/openslides/__main__.py index 7b7312c6b..3bed8dc74 100644 --- a/openslides/__main__.py +++ b/openslides/__main__.py @@ -10,8 +10,8 @@ from openslides.utils.main import ( ExceptionArgumentParser, UnknownCommand, get_default_settings_path, - get_development_settings_path, - is_development, + get_local_settings_path, + is_local_installation, setup_django_settings_module, start_browser, write_settings, @@ -32,8 +32,8 @@ def main(): if unknown_command: # Run a command, that is defined by the django management api - development = is_development() - setup_django_settings_module(development=development) + local_installation = is_local_installation() + setup_django_settings_module(local_installation=local_installation) execute_from_command_line(sys.argv) else: # Run a command that is defined here @@ -45,7 +45,7 @@ def get_parser(): """ Parses all command line arguments. """ - if len(sys.argv) == 1 and not is_development(): + if len(sys.argv) == 1 and not is_local_installation(): sys.argv.append('start') # Init parser @@ -104,9 +104,9 @@ def get_parser(): help='The used settings file. The file is created, if it does not exist.') subcommand_start.set_defaults(callback=start) subcommand_start.add_argument( - '--development', + '--local-installation', action='store_true', - help='Option for development purposes.') + help='Store settings and user files in a local directory.') # Subcommand createsettings createsettings_help = 'Creates the settings file.' @@ -121,9 +121,9 @@ def get_parser(): default=None, help='The used settings file. The file is created, even if it exists.') subcommand_createsettings.add_argument( - '--development', + '--local-installation', action='store_true', - help='Option for development purposes.') + help='Store settings and user files in a local directory.') # Help text for several Django subcommands django_subcommands = ( @@ -147,11 +147,11 @@ def start(args): Starts OpenSlides: Runs migrations and runs runserver. """ settings_path = args.settings_path - development = is_development() + local_installation = is_local_installation() if settings_path is None: - if development: - settings_path = get_development_settings_path() + if local_installation: + settings_path = get_local_settings_path() else: settings_path = get_default_settings_path() @@ -161,7 +161,7 @@ def start(args): # Set the django setting module and run migrations # A manual given environment variable will be overwritten - setup_django_settings_module(settings_path, development=development) + setup_django_settings_module(settings_path, local_installation=local_installation) execute_from_command_line(['manage.py', 'migrate']) @@ -178,14 +178,14 @@ def createsettings(args): Creates settings for OpenSlides. """ settings_path = args.settings_path - development = is_development() + local_installation = is_local_installation() context = {} - if development: + if local_installation: if settings_path is None: - settings_path = get_development_settings_path() + settings_path = get_local_settings_path() context = { - 'openslides_user_data_path': repr(os.path.join(os.getcwd(), 'development', 'var')), + 'openslides_user_data_path': repr(os.path.join(os.getcwd(), 'personal_data', 'var')), 'debug': 'True'} settings_path = write_settings(settings_path, **context) diff --git a/openslides/utils/main.py b/openslides/utils/main.py index b0a3b9893..b584048ef 100644 --- a/openslides/utils/main.py +++ b/openslides/utils/main.py @@ -82,16 +82,16 @@ def get_default_settings_path(openslides_type=None): return os.path.join(parent_directory, 'openslides', 'settings.py') -def get_development_settings_path(): +def get_local_settings_path(): """ - Returns the path to a local development settings. + Returns the path to a local settings. - On Unix systems: 'development/var/settings.py' + On Unix systems: 'personal_data/var/settings.py' """ - return os.path.join('development', 'var', 'settings.py') + return os.path.join('personal_data', 'var', 'settings.py') -def setup_django_settings_module(settings_path=None, development=None): +def setup_django_settings_module(settings_path=None, local_installation=None): """ Sets the environment variable ENVIRONMENT_VARIABLE, that means 'DJANGO_SETTINGS_MODULE', to the given settings. @@ -106,8 +106,8 @@ def setup_django_settings_module(settings_path=None, development=None): return if settings_path is None: - if development: - settings_path = get_development_settings_path() + if local_installation: + settings_path = get_local_settings_path() else: settings_path = get_default_settings_path() @@ -307,10 +307,10 @@ def translate_customizable_strings(language_code): activate(current_language) -def is_development(): +def is_local_installation(): """ - Returns True if the command is called for development. + Returns True if the command is called for a local installation - This is the case if manage.py is used, or when the --development flag is set. + This is the case if manage.py is used, or when the --local-installation flag is set. """ - return True if '--development' in sys.argv or 'manage.py' in sys.argv[0] else False + return True if '--local-installation' in sys.argv or 'manage.py' in sys.argv[0] else False diff --git a/setup.cfg b/setup.cfg index 421791833..1f36c66b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ source = openslides [coverage:html] -directory = development/tmp/htmlcov +directory = personal_data/tmp/htmlcov [flake8] max_line_length = 150 diff --git a/tests/old/utils/test_main.py b/tests/old/utils/test_main.py index f1903c044..b6513d2b8 100644 --- a/tests/old/utils/test_main.py +++ b/tests/old/utils/test_main.py @@ -55,8 +55,8 @@ class TestFunctions(TestCase): self.assertEqual(main.get_default_settings_path(main.WINDOWS_PORTABLE_VERSION), 'portable/openslides/settings.py') - def test_get_development_settings_path(self): - self.assertEqual(main.get_development_settings_path(), os.sep.join(('development', 'var', 'settings.py'))) + def test_get_local_settings_path(self): + self.assertEqual(main.get_local_settings_path(), os.sep.join(('personal_data', 'var', 'settings.py'))) def test_setup_django_settings_module(self): main.setup_django_settings_module('test_dir_dhvnghfjdh456fzheg2f/test_path_bngjdhc756dzwncshdfnx.py')