예제 #1
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    development = is_development()

    if settings_path is None:
        if development:
            settings_path = get_development_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(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)

    execute_from_command_line(['manage.py', 'migrate'])

    if not args.no_browser:
        start_browser('http://0.0.0.0:8000')

    # Start the webserver
    execute_from_command_line(['manage.py', 'runserver', '0.0.0.0:8000'])
예제 #2
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    local_installation = is_local_installation()

    if settings_path is None:
        if local_installation:
            settings_path = get_local_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(args)

    # Set the django setting module and run migrations
    # A manual given environment variable will be overwritten
    setup_django_settings_module(settings_path, local_installation=local_installation)

    execute_from_command_line(['manage.py', 'migrate'])

    # Open the browser
    if not args.no_browser:
        if args.host == '0.0.0.0':
            # Windows does not support 0.0.0.0, so use 'localhost' instead
            start_browser('http://localhost:%s' % args.port)
        else:
            start_browser('http://%s:%s' % (args.host, args.port))

    # Start the webserver
    # Tell django not to reload. OpenSlides uses the reload method from tornado
    execute_from_command_line(['manage.py', 'runserver', '%s:%s' % (args.host, args.port), '--noreload'])
예제 #3
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    development = is_development()

    if settings_path is None:
        if development:
            settings_path = get_development_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(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)

    execute_from_command_line(['manage.py', 'migrate'])

    if not args.no_browser:
        start_browser('http://localhost:8000')

    # Start the webserver
    # Tell django not to reload. OpenSlides uses the reload method from tornado
    execute_from_command_line(['manage.py', 'runserver', '0.0.0.0:8000', '--noreload'])
예제 #4
0
 def test_start_browser(self,  mock_webbrowser, mock_time, mock_Thread):
     browser_mock = MagicMock()
     mock_webbrowser.get.return_value = browser_mock
     start_browser('http://localhost:8234')
     self.assertTrue(mock_Thread.called)
     inner_function = mock_Thread.call_args[1]['target']
     inner_function()
     browser_mock.open.assert_called_with('http://localhost:8234')
예제 #5
0
 def test_start_browser(self, mock_webbrowser, mock_time, mock_Thread):
     browser_mock = MagicMock()
     mock_webbrowser.get.return_value = browser_mock
     start_browser('http://localhost:8234')
     self.assertTrue(mock_Thread.called)
     inner_function = mock_Thread.call_args[1]['target']
     inner_function()
     browser_mock.open.assert_called_with('http://localhost:8234')
예제 #6
0
def runserver(settings, args):
    """
    Runs tornado webserver. Runs the function start_browser if the respective
    argument is given.
    """
    ensure_settings(settings, args)
    port = get_port(address=args.address, port=args.port)
    if args.start_browser:
        browser_url = get_browser_url(address=args.address, port=port)
        start_browser(browser_url)

    # Now the settings is available and the function can be imported.
    from openslides.utils.tornado_webserver import run_tornado
    run_tornado(args.address, port, not args.no_reload)
예제 #7
0
def runserver(settings, args):
    """
    Runs tornado webserver. Runs the function start_browser if the respective
    argument is given.
    """
    ensure_settings(settings, args)
    port = get_port(address=args.address, port=args.port)
    if args.start_browser:
        browser_url = get_browser_url(address=args.address, port=port)
        start_browser(browser_url)

    # Now the settings is available and the function can be imported.
    from openslides.utils.tornado_webserver import run_tornado
    run_tornado(args.address, port)
예제 #8
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    local_installation = is_local_installation()

    if settings_path is None:
        if local_installation:
            settings_path = get_local_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(args)

    # Set the django setting module and run migrations
    # A manual given environment variable will be overwritten
    setup_django_settings_module(settings_path, local_installation=local_installation)

    execute_from_command_line(['manage.py', 'migrate'])

    # Open the browser
    if not args.no_browser:
        if args.host == '0.0.0.0':
            # Windows does not support 0.0.0.0, so use 'localhost' instead
            start_browser('http://localhost:%s' % args.port)
        else:
            start_browser('http://%s:%s' % (args.host, args.port))

    # Start the webserver
    # Use flag --noreload to tell Django not to reload the server.
    # Use flag --insecure to serve static files even if DEBUG is False.
    # Use flag --nothreading to tell Django Channels to run in single thread mode.
    execute_from_command_line([
        'manage.py',
        'runserver',
        '{}:{}'.format(args.host, args.port),
        '--noreload',
        '--insecure',
        '--nothreading',
    ])
예제 #9
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    local_installation = is_local_installation()

    if settings_path is None:
        if local_installation:
            settings_path = get_local_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(args)

    # Set the django setting module and run migrations
    # A manual given environment variable will be overwritten
    setup_django_settings_module(settings_path,
                                 local_installation=local_installation)

    execute_from_command_line(['manage.py', 'migrate'])

    # Open the browser
    if not args.no_browser:
        if args.host == '0.0.0.0':
            # Windows does not support 0.0.0.0, so use 'localhost' instead
            start_browser('http://localhost:%s' % args.port)
        else:
            start_browser('http://%s:%s' % (args.host, args.port))

    # Start the webserver
    # Use flag --noreload to tell Django not to reload the server.
    # Use flag --insecure to serve static files even if DEBUG is False.
    # Use flag --nothreading to tell Django Channels to run in single thread mode.
    execute_from_command_line([
        'manage.py', 'runserver', '{}:{}'.format(args.host, args.port),
        '--noreload', '--insecure', '--nothreading'
    ])
예제 #10
0
def start(args):
    """
    Starts OpenSlides: Runs migrations and runs runserver.
    """
    settings_path = args.settings_path
    local_installation = is_local_installation()

    if settings_path is None:
        if local_installation:
            settings_path = get_local_settings_path()
        else:
            settings_path = get_default_settings_path()

    # Write settings if it does not exists.
    if not os.path.isfile(settings_path):
        createsettings(args)

    # Set the django setting module and run migrations
    # A manual given environment variable will be overwritten
    setup_django_settings_module(settings_path,
                                 local_installation=local_installation)

    execute_from_command_line(['manage.py', 'migrate'])

    # Open the browser
    if not args.no_browser:
        if args.host == '0.0.0.0':
            # Windows does not support 0.0.0.0, so use 'localhost' instead
            start_browser('http://localhost:%s' % args.port)
        else:
            start_browser('http://%s:%s' % (args.host, args.port))

    # Start the webserver
    # Tell django not to reload. OpenSlides uses the reload method from tornado
    execute_from_command_line([
        'manage.py', 'runserver',
        '%s:%s' % (args.host, args.port), '--noreload'
    ])