Merge pull request #1270 from emanuelschuetze/fix1178
Adds plugin directory for win32 portable version (Fixed #1178).
This commit is contained in:
commit
b8cd2d360b
@ -21,10 +21,10 @@ import openslides
|
||||
from openslides.utils.main import (
|
||||
detect_openslides_type,
|
||||
filesystem2unicode,
|
||||
unicode2filesystem,
|
||||
get_default_user_data_path,
|
||||
get_port,
|
||||
get_win32_portable_path,
|
||||
PortableDirNotWritable
|
||||
PortableDirNotWritable,
|
||||
)
|
||||
|
||||
|
||||
@ -97,11 +97,7 @@ class RunCommandControl(wx.Panel):
|
||||
|
||||
# XXX: subprocess on windows only handles byte strings
|
||||
# with python3 this will hopefully no longer be the case
|
||||
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
||||
cmd = [
|
||||
x.encode(fs_encoding) if isinstance(x, unicode) else x
|
||||
for x in cmd
|
||||
]
|
||||
cmd = [unicode2filesystem(x) for x in cmd]
|
||||
|
||||
creationflags = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
|
||||
self.child_process = subprocess.Popen(
|
||||
@ -640,7 +636,7 @@ class MainWindow(wx.Frame):
|
||||
"assembly system.\n"
|
||||
"OpenSlides is free software; licensed under the MIT license."
|
||||
).replace(u" ", u"\u00a0"))
|
||||
info.SetCopyright(_(u"\u00a9 2011-2013 by OpenSlides team"))
|
||||
info.SetCopyright(_(u"\u00a9 2011-2014 by OpenSlides team"))
|
||||
info.SetWebSite(("http://www.openslides.org/", "www.openslides.org"))
|
||||
|
||||
# XXX: at least on wxgtk this has no effect
|
||||
|
@ -191,7 +191,7 @@ VS_VERSION_INFO VERSIONINFO
|
||||
VALUE "FileDescription", "OpenSlides\\0"
|
||||
VALUE "FileVersion", "{version_str}\\0"
|
||||
VALUE "InternalName", "OpenSlides\\0"
|
||||
VALUE "LegalCopyright", "Copyright \\251 2011-2013\\0"
|
||||
VALUE "LegalCopyright", "Copyright \\251 2011-2014\\0"
|
||||
VALUE "OriginalFilename", "openslides.exe\\0"
|
||||
VALUE "ProductName", "OpenSlides\\0"
|
||||
VALUE "ProductVersion", "{version_str}\\0"
|
||||
@ -372,7 +372,7 @@ def openslides_launcher_update_version_resource():
|
||||
"FileDescription": "OpenSlides",
|
||||
"FileVersion": version_str,
|
||||
"InternalName": "OpenSlides",
|
||||
"LegalCopyright": u"Copyright \xa9 2011-2013",
|
||||
"LegalCopyright": u"Copyright \xa9 2011-2014",
|
||||
"OriginalFilename": "openslides.exe",
|
||||
"ProductName": "OpenSlides",
|
||||
"ProductVersion": version_str,
|
||||
@ -510,6 +510,10 @@ def main():
|
||||
os.path.join(odir, "packages-info"))
|
||||
write_package_info_content(os.path.join(odir, 'packages-info', 'PACKAGES.txt'))
|
||||
|
||||
# Create empty plugins directory
|
||||
plugindir = os.path.join(odir, "openslides", "plugins")
|
||||
os.makedirs(plugindir)
|
||||
|
||||
# AUTHORS, LICENSE, README
|
||||
write_metadatafile('AUTHORS', os.path.join(odir, 'AUTHORS.txt'))
|
||||
write_metadatafile('LICENSE', os.path.join(odir, 'LICENSE.txt'))
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
from openslides.utils.main import filesystem2unicode
|
||||
from openslides.utils.plugins import get_plugins_from_entry_points
|
||||
from openslides.utils.plugins import collect_plugins
|
||||
|
||||
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
|
||||
|
||||
@ -129,4 +129,4 @@ HAYSTACK_CONNECTIONS = {
|
||||
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
|
||||
|
||||
# Adds all automaticly collected plugins
|
||||
INSTALLED_PLUGINS = get_plugins_from_entry_points()
|
||||
INSTALLED_PLUGINS = collect_plugins()
|
||||
|
@ -136,8 +136,8 @@ def get_default_settings_context(user_data_path=None):
|
||||
else:
|
||||
openslides_type = detect_openslides_type()
|
||||
if openslides_type == WINDOWS_PORTABLE_VERSION:
|
||||
default_context['openslides_user_data_path'] = 'get_win32_portable_path()'
|
||||
default_context['import_function'] = 'from openslides.utils.main import get_win32_portable_path'
|
||||
default_context['openslides_user_data_path'] = 'get_win32_portable_user_data_path()'
|
||||
default_context['import_function'] = 'from openslides.utils.main import get_win32_portable_user_data_path'
|
||||
else:
|
||||
path = get_default_user_data_path(openslides_type)
|
||||
default_context['openslides_user_data_path'] = repr(os.path.join(path, 'openslides'))
|
||||
@ -208,6 +208,13 @@ def get_win32_portable_path():
|
||||
return portable_path
|
||||
|
||||
|
||||
def get_win32_portable_user_data_path():
|
||||
"""
|
||||
Returns the user data path to the Windows portable version.
|
||||
"""
|
||||
return os.path.join(get_win32_portable_path(), 'openslides')
|
||||
|
||||
|
||||
def write_settings(settings_path, template=None, **context):
|
||||
"""
|
||||
Creates the settings file at the given path using the given values for the
|
||||
|
@ -1,8 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import pkgutil
|
||||
import sys
|
||||
|
||||
from django.utils.importlib import import_module
|
||||
from pkg_resources import iter_entry_points
|
||||
|
||||
from openslides.utils.main import (
|
||||
detect_openslides_type,
|
||||
WINDOWS_PORTABLE_VERSION,
|
||||
get_win32_portable_user_data_path,
|
||||
)
|
||||
|
||||
plugins = {}
|
||||
|
||||
|
||||
@ -15,6 +25,30 @@ def get_plugins_from_entry_points():
|
||||
return tuple(entry_point.module_name for entry_point in iter_entry_points('openslides_plugins'))
|
||||
|
||||
|
||||
def get_plugins_from_path(path):
|
||||
"""
|
||||
Collects all modules/packages in the given `path`
|
||||
and returns a tuple of their names
|
||||
"""
|
||||
importer = pkgutil.get_importer(path)
|
||||
return tuple(x[0] for x in importer.iter_modules())
|
||||
|
||||
|
||||
def collect_plugins():
|
||||
"""
|
||||
Collect all plugins that can be automatically discovered.
|
||||
"""
|
||||
plugins = get_plugins_from_entry_points()
|
||||
# add all modules in plugins/ dir of portable automatically
|
||||
if detect_openslides_type() == WINDOWS_PORTABLE_VERSION:
|
||||
plugins_path = os.path.join(
|
||||
get_win32_portable_user_data_path(), "plugins")
|
||||
if plugins_path not in sys.path:
|
||||
sys.path.append(plugins_path)
|
||||
plugins += get_plugins_from_path(plugins_path)
|
||||
return plugins
|
||||
|
||||
|
||||
def get_plugin(plugin):
|
||||
"""
|
||||
Returns the imported module. The plugin argument must be a python dotted
|
||||
|
@ -41,7 +41,7 @@ class TestFunctions(TestCase):
|
||||
def test_get_default_settings_context_portable(self, detect_mock):
|
||||
detect_mock.return_value = WINDOWS_PORTABLE_VERSION
|
||||
context = get_default_settings_context()
|
||||
self.assertEqual(context['openslides_user_data_path'], 'get_win32_portable_path()')
|
||||
self.assertEqual(context['openslides_user_data_path'], 'get_win32_portable_user_data_path()')
|
||||
|
||||
def test_setup_django_settings_module(self):
|
||||
setup_django_settings_module('test_dir_dhvnghfjdh456fzheg2f/test_path_bngjdhc756dzwncshdfnx.py')
|
||||
|
Loading…
Reference in New Issue
Block a user